Phone Numbers
Configure a Twilio number's webhook
Point an imported Twilio number’s voice webhook and status callback at Verbeo, inside your own Twilio account.
POST
/
phone-number
/
{id}
/
twilio-webhook
Configure a Twilio number's webhook
curl --request POST \
--url https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook', 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.verbeo.ai/v1/phone-number/{id}/twilio-webhook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.verbeo.ai/v1/phone-number/{id}/twilio-webhook")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"voice_url": "<string>",
"status_callback_url": "<string>"
}Sets the voice webhook and the status callback of a number imported from Twilio to Verbeo’s, using the Twilio credentials stored with the number. Until this has run, calls to the number do not reach Verbeo.
Run it once after the import, and again whenever the number’s webhook has been changed in the Twilio console — a number pointed elsewhere silently stops reaching your assistant.
It applies to a number whose
provider is twilio. A SIP-trunk number has no Twilio webhook: its calls are routed by the trunk.
Path parameters
string
required
UUID of the phone number.
Request
The request has no body.curl -X POST "https://api.verbeo.ai/v1/phone-number/7d9f3b52-4c1e-4a8e-9b1a-2f6c0d4e8a11/twilio-webhook" \
-H "Authorization: Bearer YOUR_API_KEY"
const id = "7d9f3b52-4c1e-4a8e-9b1a-2f6c0d4e8a11";
const res = await fetch(`https://api.verbeo.ai/v1/phone-number/${id}/twilio-webhook`, {
method: "POST",
headers: { Authorization: `Bearer ${process.env.VERBEO_API_KEY}` },
});
const { data: webhook } = await res.json();
import os, requests
number_id = "7d9f3b52-4c1e-4a8e-9b1a-2f6c0d4e8a11"
webhook = requests.post(
f"https://api.verbeo.ai/v1/phone-number/{number_id}/twilio-webhook",
headers={"Authorization": f"Bearer {os.environ['VERBEO_API_KEY']}"},
).json()["data"]
Response
200 OK with the two URLs the number now points at.
{
"success": true,
"data": {
"voice_url": "https://…/functions/v1/twilio-webhook-inbound",
"status_callback_url": "https://…/functions/v1/twilio-call-status"
}
}
string
required
Where Twilio now sends the number’s incoming calls.
string
required
Where Twilio now reports each call’s status.
Errors
| Code | Status | When |
|---|---|---|
VALIDATION_FAILED | 422 | The number was not imported from Twilio; it has no stored credentials; Twilio rejected the Account SID or Auth Token; or the number is not in that Twilio account. The message says which. |
NOT_FOUND | 404 | No such phone number, or it belongs to another workspace. |
BAD_GATEWAY | 502 | Twilio could not be reached, or answered with an error of its own. The message carries its status. |
Was this page helpful?
⌘I
Configure a Twilio number's webhook
curl --request POST \
--url https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook', 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.verbeo.ai/v1/phone-number/{id}/twilio-webhook",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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.verbeo.ai/v1/phone-number/{id}/twilio-webhook")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.verbeo.ai/v1/phone-number/{id}/twilio-webhook")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"voice_url": "<string>",
"status_callback_url": "<string>"
}