POST https://api.46elks.com/a1/calls
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://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":"+46766861004"}. |
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=+46766861020 \
-d to=+46766861004 \
-d voice_start='{"play":"https://yourserver.example/files/hello.mp3"}'
import HTTPotion.base
authdata = [basic_auth: {'<API_USERNAME>',
'<API_PASSWORD>'}]
request = %{
"from" => "+46766861020",
"to" => "+46766861004",
"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", "+46766861004")
.field("from", "+46766861020")
.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" => "+46766861020",
"to" => "+46766861004",
"voice_start" => '{"play":"https://yourserver.example/files/hello.mp3"}',
);
echo sendcalls($calls);
import requests
auth = (
'API_USERNAME',
'API_PASSWORD'
)
fields = {
'from': '+46766861020',
'to': '+46766861004',
'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 => '+46766861020',
: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 https = require('https')
const querystring = require('querystring')
const username = 'API_USERNAME'
const password = 'API_PASSWORD'
const postFields = {
from: '+46766861020',
to: '+46704508449',
voice_start: '{"play":"https://46elks.com/static/sound/make-call.mp3"}'
}
const key = Buffer.from(username + ':' + password).toString("base64");
const postData = querystring.stringify(postFields)
const options = {
hostname: 'api.46elks.com',
path: '/a1/calls',
method: 'POST',
headers: {
'Authorization': 'Basic ' + key
}
}
const callback = (response) => {
var str = ''
response.on('data', (chunk) => {
str += chunk
})
response.on('end', () => {
console.log(str)
})
}
var request = https.request(options, callback)
request.write(postData)
request.end()
More examples
C -
C# -
Go -
Google App Script -
Haskell -
Postman
{
"direction": "outgoing",
"from": "+46766861004",
"created": "2016-11-03T15:08:14.609873",
"to": "+46766861004",
"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. |