curl --request POST \
--url https://api.revring.ai/v1/sip-trunks/connect/twilio \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"twilio": {
"accountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authToken": "<string>",
"apiKeySid": "<string>",
"apiKeySecret": "<string>"
},
"numbers": [
"+14155550123"
],
"agentId": "<string>",
"friendlyName": "Twilio (connected)"
}
'import requests
url = "https://api.revring.ai/v1/sip-trunks/connect/twilio"
payload = {
"twilio": {
"accountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authToken": "<string>",
"apiKeySid": "<string>",
"apiKeySecret": "<string>"
},
"numbers": ["+14155550123"],
"agentId": "<string>",
"friendlyName": "Twilio (connected)"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
twilio: {
accountSid: 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authToken: '<string>',
apiKeySid: '<string>',
apiKeySecret: '<string>'
},
numbers: ['+14155550123'],
agentId: '<string>',
friendlyName: 'Twilio (connected)'
})
};
fetch('https://api.revring.ai/v1/sip-trunks/connect/twilio', 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.revring.ai/v1/sip-trunks/connect/twilio",
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([
'twilio' => [
'accountSid' => 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'authToken' => '<string>',
'apiKeySid' => '<string>',
'apiKeySecret' => '<string>'
],
'numbers' => [
'+14155550123'
],
'agentId' => '<string>',
'friendlyName' => 'Twilio (connected)'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.revring.ai/v1/sip-trunks/connect/twilio"
payload := strings.NewReader("{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.revring.ai/v1/sip-trunks/connect/twilio")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.revring.ai/v1/sip-trunks/connect/twilio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"trunk": {},
"twilio": {
"trunkSid": "TKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"domainName": "revring-ab12cd34ef.pstn.twilio.com",
"originationUri": "sip:sip.revring.ai"
},
"numbers": [
{
"e164": "<string>",
"previousRouting": "voice webhook example.com"
}
],
"agent": {
"id": "<string>",
"numbers": [
"<string>"
]
}
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Connect Twilio
Connects Twilio numbers in one step: creates an Elastic SIP trunk in your Twilio account with origination to sip.revring.ai and a fresh termination credential, moves the chosen numbers onto it, and creates the matching RevRing trunk. With agentId, the numbers are also assigned to that agent for inbound calls (and the trunk becomes its outbound trunk if it has none). If any step fails, everything created in Twilio is removed and your numbers keep their current routing.
curl --request POST \
--url https://api.revring.ai/v1/sip-trunks/connect/twilio \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"twilio": {
"accountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authToken": "<string>",
"apiKeySid": "<string>",
"apiKeySecret": "<string>"
},
"numbers": [
"+14155550123"
],
"agentId": "<string>",
"friendlyName": "Twilio (connected)"
}
'import requests
url = "https://api.revring.ai/v1/sip-trunks/connect/twilio"
payload = {
"twilio": {
"accountSid": "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"authToken": "<string>",
"apiKeySid": "<string>",
"apiKeySecret": "<string>"
},
"numbers": ["+14155550123"],
"agentId": "<string>",
"friendlyName": "Twilio (connected)"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
twilio: {
accountSid: 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authToken: '<string>',
apiKeySid: '<string>',
apiKeySecret: '<string>'
},
numbers: ['+14155550123'],
agentId: '<string>',
friendlyName: 'Twilio (connected)'
})
};
fetch('https://api.revring.ai/v1/sip-trunks/connect/twilio', 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.revring.ai/v1/sip-trunks/connect/twilio",
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([
'twilio' => [
'accountSid' => 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'authToken' => '<string>',
'apiKeySid' => '<string>',
'apiKeySecret' => '<string>'
],
'numbers' => [
'+14155550123'
],
'agentId' => '<string>',
'friendlyName' => 'Twilio (connected)'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.revring.ai/v1/sip-trunks/connect/twilio"
payload := strings.NewReader("{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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.revring.ai/v1/sip-trunks/connect/twilio")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.revring.ai/v1/sip-trunks/connect/twilio")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"twilio\": {\n \"accountSid\": \"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\",\n \"authToken\": \"<string>\",\n \"apiKeySid\": \"<string>\",\n \"apiKeySecret\": \"<string>\"\n },\n \"numbers\": [\n \"+14155550123\"\n ],\n \"agentId\": \"<string>\",\n \"friendlyName\": \"Twilio (connected)\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"trunk": {},
"twilio": {
"trunkSid": "TKxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"domainName": "revring-ab12cd34ef.pstn.twilio.com",
"originationUri": "sip:sip.revring.ai"
},
"numbers": [
{
"e164": "<string>",
"previousRouting": "voice webhook example.com"
}
],
"agent": {
"id": "<string>",
"numbers": [
"<string>"
]
}
}
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}{
"error": "<string>",
"message": "<string>"
}Authorizations
API key for authentication. Generate API keys from the RevRing dashboard.
Body
Your Twilio account credentials. Used for this request only and never stored. Provide authToken, or apiKeySid with apiKeySecret.
Show child attributes
Show child attributes
E.164 numbers on the Twilio account to connect
1 - 50 elementsAgent that answers these numbers
Name of the RevRing trunk
128Response
Connected
Show child attributes
Show child attributes