curl --request POST \
--url https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"userId": "64f0a1b2c3d4e5f6a7b8c9d4",
"phoneNumber": "+14165550100",
"aiEnabled": true,
"aiAgentId": "64f0a1b2c3d4e5f6a7b8cc00"
}
'import requests
url = "https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle"
payload = {
"userId": "64f0a1b2c3d4e5f6a7b8c9d4",
"phoneNumber": "+14165550100",
"aiEnabled": True,
"aiAgentId": "64f0a1b2c3d4e5f6a7b8cc00"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
userId: '64f0a1b2c3d4e5f6a7b8c9d4',
phoneNumber: '+14165550100',
aiEnabled: true,
aiAgentId: '64f0a1b2c3d4e5f6a7b8cc00'
})
};
fetch('https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle', 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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle",
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([
'userId' => '64f0a1b2c3d4e5f6a7b8c9d4',
'phoneNumber' => '+14165550100',
'aiEnabled' => true,
'aiAgentId' => '64f0a1b2c3d4e5f6a7b8cc00'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle"
payload := strings.NewReader("{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Configuration saved"
}{
"error": "Agent not synced to ElevenLabs",
"code": "AGENT_NOT_SYNCED"
}{
"success": false,
"error": "Call not found"
}{
"success": false,
"error": "Call not found"
}Toggle AI on/off for a phone number (superadmin)
Atomically enables or disables AI handling on a single user-owned phone number. When enabling: validates the number is assigned to the Sinch EST trunk, imports it into ElevenLabs (linking to the chosen agent), and assigns it to the Sinch EST trunk. When disabling: removes it from ElevenLabs and the trunk. Fails fast (without DB writes) if the selected agent isn’t synced to ElevenLabs or if provider-side operations error — preventing silent drift. Superadmin only.
curl --request POST \
--url https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"userId": "64f0a1b2c3d4e5f6a7b8c9d4",
"phoneNumber": "+14165550100",
"aiEnabled": true,
"aiAgentId": "64f0a1b2c3d4e5f6a7b8cc00"
}
'import requests
url = "https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle"
payload = {
"userId": "64f0a1b2c3d4e5f6a7b8c9d4",
"phoneNumber": "+14165550100",
"aiEnabled": True,
"aiAgentId": "64f0a1b2c3d4e5f6a7b8cc00"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
userId: '64f0a1b2c3d4e5f6a7b8c9d4',
phoneNumber: '+14165550100',
aiEnabled: true,
aiAgentId: '64f0a1b2c3d4e5f6a7b8cc00'
})
};
fetch('https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle', 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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle",
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([
'userId' => '64f0a1b2c3d4e5f6a7b8c9d4',
'phoneNumber' => '+14165550100',
'aiEnabled' => true,
'aiAgentId' => '64f0a1b2c3d4e5f6a7b8cc00'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle"
payload := strings.NewReader("{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://your-instance.example.com/api/calls/voice-ai/phone-number/toggle")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://your-instance.example.com/api/calls/voice-ai/phone-number/toggle")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"userId\": \"64f0a1b2c3d4e5f6a7b8c9d4\",\n \"phoneNumber\": \"+14165550100\",\n \"aiEnabled\": true,\n \"aiAgentId\": \"64f0a1b2c3d4e5f6a7b8cc00\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"message": "Configuration saved"
}{
"error": "Agent not synced to ElevenLabs",
"code": "AGENT_NOT_SYNCED"
}{
"success": false,
"error": "Call not found"
}{
"success": false,
"error": "Call not found"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
User whose voicePhoneNumbers entry is being toggled.
Exact phone number string to match against voicePhoneNumbers.phoneNumber.
Prompt._id to link when enabling AI. Required to switch agents on an already-AI-enabled number.