Allocate a virtual phone number

Request

POST https://api.46elks.com/a1/numbers

Request parameters

Parameter Example Description
country se A two-letter (ISO alpha 2) country code.
capabilities sms,voice A comma-seperated string denoting the capabilities the number should have. For example "sms", "sms,voice" or "sms,mms,voice".

Sample code

curl https://api.46elks.com/a1/numbers \
  -u <Username>:<API Password> \
  -d country=se \
  -d capabilities=sms,voice 
import HTTPotion.base
authdata = [basic_auth: {'',

request = %{
            "country"    => "se",
            "capabilities"      => "sms,voice"
           }

request_data = URI.encode_query(request)

HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/numbers",
  [body: request_data , ibrowse: authdata]
)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

public class UnirestSendcalls {
  public static void main(String[] args) {
    try {
      System.out.println("Sending calls");

      HttpResponse response = Unirest.post("https://api.46elks.com/a1/numbers")
        .basicAuth("","")
        .field("capabilities", "sms,voice")
        .field("country", "se")
        .asString();

      System.out.println(response.getBody());
      }

    catch (Exception e){
        System.out.println(e);
    }
  }
}
function allocatenumber ($calls) {
  $username = "USERNAME";
  $password = "PASSWORD";
  $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($calls),
      'timeout' => 10
  )));
  $response = file_get_contents("https://api.46elks.com/a1/numbers",
    false, $context);

  if (!strstr($http_response_header[0],"200 OK"))
    return $http_response_header[0];
  return $response;
}
$number = array(
  "country" => "se",
  "capabilities" => "sms,voice"  
);
echo allocatenumber($number);
import requests

auth = (
    '',
    ''
    )

fields = {
    'country': 'se',
    'capabilities': 'sms,voice'
    }

response = requests.post(
    "https://api.46elks.com/a1/numbers",
    data=fields,
    auth=auth
    )

print(response.text)
require 'net/http'

uri = URI('https://api.46elks.com/a1/numbers')
req = Net::HTTP::Post.new(uri)
req.basic_auth '', ''
req.set_form_data(
  :country => 'se',
  :capabilities => 'sms,voice'
)

res = Net::HTTP.start(
    uri.host,
    uri.port,
    :use_ssl => uri.scheme == 'https') do |http|
  http.request req
end

puts res.body

More examples
C - C# - Go - Google App Script - Haskell - Node.js - Postman

Optional request parameters

Parameter Example Description
sms_url http://hello.io/new_sms
{forward":"+46766861004"}
Url / JSON handling incomming sms
voice_start http://hello.io/new_call
{"connect":"+46766861004"}
Url / JSON handling incomming calls
mms_url http://hello.io/new_mms Url handling incomming mms

Response

Example JSON response
{
  "id": "n57c8f48af76bf986a14f251b35389e8b",
  "active": "yes",
  "country": "se",
  "number": "+46766861001",
  "capabilities": [ "sms", "voice", "mms" ],
}
Parameter Type Description
id string ID of the allocated number
active string If the number is active or not, allways "yes" on newly allocated numbers
country string A two-letter (ISO alpha 2) country code.
number string The phone number in E.164 format.
capabilities list A comma-seperated string denoting the capabilities the number should have. For example "sms", "sms,voice" or "sms,mms,voice".