Make a phone call

Request

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

Request parameters

Parameters Example Description
from +46766861004 A valid phone number in e.164 format. Can be one of your voice enabled 46elks numbers, the phone number you signed up with, or an unlocked number.
to +46766861004 The phone number of the recipient, in E.164 format.
voice_start http://hello.io/call A webhook URL that returns the first action to execute. See Call actions for details. It is also possible to add a JSON struct for direct call action with out logic like: {"connect":"+46723175800"}.

Sample code

curl https://api.46elks.com/a1/calls \
  -u <Username>:<API Password> \
  -d from=+46766861020 \
  -d to=+46766861004 \
  -d voice_start='{"play":"https://yourserver.com/files/hello.mp3"}'
import HTTPotion.base
authdata = [basic_auth: {'',

request = %{
            "from"    => "+46766861020",
            "to"      => "+46766861004",
            "voice_start" => "{"play":"https://yourserver.com/files/hello.mp3"}"
           }

request_data = URI.encode_query(request)

HTTPotion.start
HTTPotion.post("https://api.46elks.com/a1/calls",
  [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/calls")
        .basicAuth("","")
        .field("to", "+46766861004")
        .field("from", "+46766861020")
        .field("voice_start", "{"play":"https://yourserver.com/files/hello.mp3"}")
        .asString();

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

    catch (Exception e){
        System.out.println(e);
    }
  }
}
function sendcalls ($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/calls",
    false, $context);

  if (!strstr($http_response_header[0],"200 OK"))
    return $http_response_header[0];
  return $response;
}
$calls = array(
  "from" => "+46766861020",   /* Can be up to 11 alphanumeric characters */
  "to" => "+46766861004",  /* The mobile number you want to send to */
  "voice_start" => '{"play":"https://yourserver.com/files/hello.mp3"}',
);
echo sendcalls($calls);
import requests

auth = (
    '',
    ''
    )

fields = {
    'from': '+46766861020',
    'to': '+46723175800',
    'voice_start': '{"play":"https://yourserver.com/files/hello.mp3"}'
    }

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

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

uri = URI('https://api.46elks.com/a1/calls')
req = Net::HTTP::Post.new(uri)
req.basic_auth '', ''
req.set_form_data(
  :from => '+46766861020',
  :to => '+46704508449',
  :voice_start => '{"play":"https://yourserver.com/files/hello.mp3"}'
)

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

Parameters Example Description
whenhangup https://hello.io/callend Url to send call data to when call ends.
timeout 60 Seconds to wait for the to number to pickup before stopping call.

Response

Example JSON response
{
  "direction": "outgoing",
  "from": "+46723175800",
  "created": "2016-11-03T15:08:14.609873",
  "to": "+46723175800",
  "state": "ongoing",
  "id": "c719b1eefbf65b1f89c013e6433dbf537"
}
    
Attribute Type Description
id string Unique id of the call. Used to track the call during its lifetime and in history.
created string Time in UTC when the SMS was created.
state string Current state of the call.
Possible values are "success", "busy", "failed".
from string Caller id of the call, same as from parameter. When call was initated.
to string The phonenumber the call is made to.
direction string The direction of the call.
Always "outgoing" when an call is initated by an API request.