Phone calls and SMS for developers

Check the docs or try this two-way SMS demo

Our API makes it easy for you to add custom telephony features that are perfectly suited to the way you do things – because let’s face it, sometimes ‘off the shelf’ just doesn't cut it.

Sample code for our API

curl -X POST \
-u apiusername:apipassword \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'from=ElkCo' \
-d 'to=+46723175800' \
-d "message=It's cold outside, bring a sweater" \
'https://api.46elks.com/a1/SMS'
curl -X POST \
-u apiusername:apipassword \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'from=+46766861234' \
-d 'to=+46723175800' \
-d 'voice_start={"connect":"+46340890510"}' \
'https://api.46elks.com/a1/Calls'
import requests

# Your 46elks credentials
# You can find these in the dashboard after creating an account
API_USERNAME = "apiusername"
API_PASSWORD = "apipassword"

# Make a request to the 46elks API
response = requests.post(
    "https://api.46elks.com/a1/SMS",
    auth = (API_USERNAME, API_PASSWORD),
    data = {
        "from": "ElkCo",
        "to": "+46723175800",
        "message": "It's cold outside, bring a sweater!"
    }
)

# Check that the request was succesful
if response.status_code == requests.codes.ok:
    print("Sent! The API responded:")
    print(response.text)
else:
    # Error handling code...
    print("Error: %s" % response.text)
import requests

# Your 46elks credentials
# You can find these in the dashboard after creating an account
API_USERNAME = "apiusername"
API_PASSWORD = "apipassword"

# Make a request to the 46elks API
response = requests.post(
    "https://api.46elks.com/a1/Calls",
    auth = (API_USERNAME, API_PASSWORD),
    data = {
        "from": "+46766861234",
        "to": "+46723175800",
        "voice_start": "{'connect':'+461890510'}"
    }
)

# Check that the request was succesful
if response.status_code == requests.codes.ok:
    print("Sent! The API responded:")
    print(response.text)
else:
    # Error handling code...
    print("Error: %s" % response.text)
<?php
  $url = 'https://api.46elks.com/a1/SMS';
  $username = 'apiusername';
  $password = 'apipassword';
  $sms = array('from' => 'ElkCo',
               'to' => '+46709751949',
               'message' => "It's cold outside, bring a sweater!");
              
  $context = stream_context_create(array(
      'http' => array(
          'method' => 'POST',
          'header'  => "Authorization: Basic ".
              base64_encode($username.':'.$password). "\r\n".
              "Content-type: application/x-www-form-urlencoded\r\n",
          'content' => http_build_query($sms),
          'timeout' => 10
          )
      ));

  $response = file_get_contents($url, false, $context);
  print $response;
?>
<?php
  $url = 'https://api.46elks.com/a1/Calls';
  $username = 'apiusername';
  $password = 'apipassword';
  $call = array('from' => '+46709751949',
               'to' => '+46709751949',
               'voice_start' => '{"connect":"+461890510"}');
              
  $context = stream_context_create(array(
      'http' => array(
          'method' => 'POST',
          'header'  => "Authorization: Basic ".
              base64_encode($username.':'.$password). "\r\n".
              "Content-type: application/x-www-form-urlencoded\r\n",
          'content' => http_build_query($call),
          'timeout' => 10
          )
      ));

  $response = file_get_contents($url, false, $context );
  print $response;
?>
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace elktest {
  class Program {
    public static string user = "apiusername";
    public static string pwd = "apipassword";
    private static HttpClient client;
    static void Main(string[] args)
    {
      client = new HttpClient();
      client.BaseAddress = new Uri("https://api.46elks.com");

      client.DefaultRequestHeaders.Authorization =
        new AuthenticationHeaderValue(
          "Basic",
          Convert.ToBase64String(
            System.Text.ASCIIEncoding.ASCII.GetBytes(
              string.Format("{0}:{1}", user, pwd)
            )
          )
        );
        
      var content = new FormUrlEncodedContent(new[] {
        new KeyValuePair < string, string > ("from", "ElkCo"),
        new KeyValuePair < string, string > (
          "to", "+46735417172"),
        new KeyValuePair < string, string > (
          "message",
          "It's cold outside, bring a sweater!"),
      });

      HttpResponseMessage response = client
        .PostAsync("/a1/SMS", content).Result;
      string result = response.Content.ReadAsStringAsync().Result;
      Console.WriteLine(result);
    }
  }
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace elktest {
  class Program {
    public static string user = "apiusername";
    public static string pwd = "apipassword";
    private static HttpClient client;
    static void Main(string[] args)
    {
      client = new HttpClient();
      client.BaseAddress = new Uri("https://api.46elks.com");

      client.DefaultRequestHeaders.Authorization =
        new AuthenticationHeaderValue(
          "Basic",
          Convert.ToBase64String(
            System.Text.ASCIIEncoding.ASCII.GetBytes(
              string.Format("{0}:{1}", user, pwd)
            )
          )
        );

      var content = new FormUrlEncodedContent(new[] {
        new KeyValuePair < string, string > ("from", "+46766861004"),
        new KeyValuePair < string, string > (
          "to", "+46735417172"),
        new KeyValuePair < string, string > (
          "voice_start", '{"connect":"+461890510"}'),
        }
      );

      HttpResponseMessage response = client
        .PostAsync("/a1/Calls", content).Result;
      string result = response.Content.ReadAsStringAsync().Result;
      Console.WriteLine(result);
    }
  }
}
POST https://apiusername:apipassword@api.46elks.com/a1/SMS
application/x-www-form-urlencoded
from=ElkCo
to=+46723175800
message="It's cold outside, bring a sweater!"
POST https://apiusername:apipassword@api.46elks.com/a1/Calls
application/x-www-form-urlencoded
from=+46766861234
to=+46723175800
voice_start={"connect":"+46340890510"}
{
  "ivr": "http://myserver.se/welcome.wav",
  "1": {
    "play": "http://myserver.se/info.wav"
  },
  "2": {
    {
    "play": "http://myserver.se/entervoicemail.wav",
    "next": {
      "record": "http://myserver.se/newvoicemail"
    }
  }
  "3": {
    "ivr": "http://myserver.se/enterpin.wav",
    "digits": 5,
    "next": "http://myserver.se/usercode"
  }
  "4": {
    "connect": "+46723175800"
  }
}
Show me the API documentation

Checkout these examples of what others have done with our API

You'll be in good company
when using 46elks

kodcentrum logo, organization that trusts 46elks

We do local globally

We have global aspirations, but our focus lies at being able to collaborate with developers at grass roots level, offering you services like billing in local currency and support that you can count on.

Select your country to learn more about
what is available in your region.

world map - 46elks available globally

Adding voice and SMS to your application is easy Create your account