POST https://api.46elks.com/a1/calls
Parameters | Example | Description |
---|---|---|
from | +46700000000 | 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 | +46700000000 | The phone number of the recipient, in E.164 format. |
voice_start | http://yourapp.example/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 actions without any logic, like: {"connect":"+46700000000"}. |
Parameters | Example | Description |
---|---|---|
whenhangup | https://yourapp.example/callend | URL to send call data to when call ends. |
timeout | 60 | Seconds to wait for the to-number to pickup before stopping call. |
The voice_start is not loaded until the call connects (when someone answers the phone call).
Include the 'whenhangup'
parameter as a parameter in the initial request if you want to get a webhook when the call
ends including if the calls fails to connect in the first instance.
curl https://api.46elks.com/a1/calls \
-u <Username>:<API Password> \
-d from=+46700000000 \
-d to=+46700000000 \
-d voice_start='{"play":"https://yourserver.example/files/hello.mp3"}'
import HTTPotion.base
authdata = [basic_auth: {'<API_USERNAME>',
'<API_PASSWORD>'}]
request = %{
"from" => "+46700000000",
"to" => "+46700000000",
"voice_start" => "{"play":"https://yourserver.example/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("API_USERNAME","API_PASSWORD")
.field("to", "+46700000000")
.field("from", "+46700000000")
.field("voice_start", "{"play":"https://yourserver.example/files/hello.mp3"}")
.asString();
System.out.println(response.getBody());
}
catch (Exception e){
System.out.println(e);
}
}
}
function sendcalls ($calls) {
$username = "API_USERNAME";
$password = "API_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" => "+46700000000",
"to" => "+46700000000",
"voice_start" => '{"play":"https://yourserver.example/files/hello.mp3"}',
);
echo sendcalls($calls);
import requests
auth = (
'API_USERNAME',
'API_PASSWORD'
)
fields = {
'from': '+46700000000',
'to': '+46700000000',
'voice_start': '{"play":"https://yourserver.example/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 'API_USERNAME', 'API_PASSWORD'
req.set_form_data(
:from => '+46700000000',
:to => '+46704508449',
:voice_start => '{"play":"https://yourserver.example/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
const axios = require("axios");
const makeCall = async () => {
try {
// API credentials
const username = '';
const password = '';
const authKey = Buffer.from(username + ":" + password).toString("base64");
// Set the SMS endpoint
const url = "https://api.46elks.com/a1/calls";
// Request data object
var data = {
from: "+46700000001",
to: "+46700000002",
voice_start: '{"connect":"+46700000003"}'
}
data = new URLSearchParams(data);
data = data.toString();
// Set the headers
const config = {
headers: {
"Authorization": "Basic " + authKey
}
};
// Send request
const res = await axios.post(url, data, config);
console.log(res.data);
} catch (err) {
console.error(err);
}
};
makeCall();
More examples
C -
C# -
Go -
Node.js (fetch) -
Google App Script -
Haskell -
Postman
{
"direction": "outgoing",
"from": "+46700000000",
"created": "2016-11-03T15:08:14.609873",
"to": "+46700000000",
"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 call was created. |
state | string |
Current state of the call. Possible values are "success", "busy", "failed". |
from | string | Caller id of the call. |
to | string | The phone number the call is made to. |
direction | string |
The direction of the call. Always "outgoing" when an call is initated by an API request. |