Make an outbound call
curl --request POST \
--url https://api.zeroruntime.ai/v2/sip/call \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"sipCallFrom": "+14155550100",
"sipCallTo": "+14155550199",
"routingRuleId": "rr_2554md",
"metadata": {
"orderId": "ord_1042"
}
}
'import requests
url = "https://api.zeroruntime.ai/v2/sip/call"
payload = {
"sipCallFrom": "+14155550100",
"sipCallTo": "+14155550199",
"routingRuleId": "rr_2554md",
"metadata": { "orderId": "ord_1042" }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sipCallFrom: '+14155550100',
sipCallTo: '+14155550199',
routingRuleId: 'rr_2554md',
metadata: {orderId: 'ord_1042'}
})
};
fetch('https://api.zeroruntime.ai/v2/sip/call', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zeroruntime.ai/v2/sip/call",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sipCallFrom' => '+14155550100',
'sipCallTo' => '+14155550199',
'routingRuleId' => 'rr_2554md',
'metadata' => [
'orderId' => 'ord_1042'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zeroruntime.ai/v2/sip/call"
payload := strings.NewReader("{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.zeroruntime.ai/v2/sip/call")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zeroruntime.ai/v2/sip/call")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Call initiated successfully",
"data": {
"id": "3f1c9a52-7b0e-4d61-9a2f-5e8c1d4b7a90",
"type": "outbound",
"status": "initiated",
"from": "+14155550100",
"to": "+14155550199",
"roomId": "abcd-efgh-ijkl",
"gatewayId": "c907…",
"ruleId": "rr_2554md",
"region": "us002",
"metadata": {
"orderId": "ord_1042"
},
"timelog": [
{
"status": "initiated",
"timestamp": "2023-11-07T05:31:56Z"
}
]
}
}{
"message": "No outbound gateway attached to +14155550100"
}{
"message": "Outbound gateway not found"
}Calls
Make an outbound call
Calls sipCallTo from sipCallFrom and connects the agent from the outbound routing rule. The rule also decides the room, recording, DTMF and SIP headers.
You need a number with an outbound gateway, registered with Create number with SIP gateways or bought in the dashboard, and an outbound routing rule on it with an agentId.
POST
/
v2
/
sip
/
call
Make an outbound call
curl --request POST \
--url https://api.zeroruntime.ai/v2/sip/call \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"sipCallFrom": "+14155550100",
"sipCallTo": "+14155550199",
"routingRuleId": "rr_2554md",
"metadata": {
"orderId": "ord_1042"
}
}
'import requests
url = "https://api.zeroruntime.ai/v2/sip/call"
payload = {
"sipCallFrom": "+14155550100",
"sipCallTo": "+14155550199",
"routingRuleId": "rr_2554md",
"metadata": { "orderId": "ord_1042" }
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sipCallFrom: '+14155550100',
sipCallTo: '+14155550199',
routingRuleId: 'rr_2554md',
metadata: {orderId: 'ord_1042'}
})
};
fetch('https://api.zeroruntime.ai/v2/sip/call', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.zeroruntime.ai/v2/sip/call",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'sipCallFrom' => '+14155550100',
'sipCallTo' => '+14155550199',
'routingRuleId' => 'rr_2554md',
'metadata' => [
'orderId' => 'ord_1042'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zeroruntime.ai/v2/sip/call"
payload := strings.NewReader("{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.zeroruntime.ai/v2/sip/call")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zeroruntime.ai/v2/sip/call")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sipCallFrom\": \"+14155550100\",\n \"sipCallTo\": \"+14155550199\",\n \"routingRuleId\": \"rr_2554md\",\n \"metadata\": {\n \"orderId\": \"ord_1042\"\n }\n}"
response = http.request(request)
puts response.read_body{
"message": "Call initiated successfully",
"data": {
"id": "3f1c9a52-7b0e-4d61-9a2f-5e8c1d4b7a90",
"type": "outbound",
"status": "initiated",
"from": "+14155550100",
"to": "+14155550199",
"roomId": "abcd-efgh-ijkl",
"gatewayId": "c907…",
"ruleId": "rr_2554md",
"region": "us002",
"metadata": {
"orderId": "ord_1042"
},
"timelog": [
{
"status": "initiated",
"timestamp": "2023-11-07T05:31:56Z"
}
]
}
}{
"message": "No outbound gateway attached to +14155550100"
}{
"message": "Outbound gateway not found"
}Authorizations
Your API token, sent raw (no Bearer prefix).
Body
application/json
The number to call, in E.164 with the +.
Example:
"+14155550199"
Your number to call from, in E.164 with the +.
Example:
"+14155550100"
An outbound routing rule. Leave it out to use the first outbound rule on sipCallFrom.
Example:
"rr_2554md"
How the callee appears in the room.
Show child attributes
Show child attributes
Your own data for this call. Stored on the call and passed to the agent.