Assign Phone Number to Agent
curl --request POST \
--url https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-workspace-id: <x-workspace-id>' \
--data '
{
"recordCalls": true,
"recordingPublic": true,
"officeHours": {},
"metadataTags": {}
}
'import requests
url = "https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}"
payload = {
"recordCalls": True,
"recordingPublic": True,
"officeHours": {},
"metadataTags": {}
}
headers = {
"x-workspace-id": "<x-workspace-id>",
"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-workspace-id': '<x-workspace-id>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({recordCalls: true, recordingPublic: true, officeHours: {}, metadataTags: {}})
};
fetch('https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}', 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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}",
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([
'recordCalls' => true,
'recordingPublic' => true,
'officeHours' => [
],
'metadataTags' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-workspace-id: <x-workspace-id>"
],
]);
$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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}"
payload := strings.NewReader("{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-workspace-id", "<x-workspace-id>")
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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}")
.header("x-workspace-id", "<x-workspace-id>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-workspace-id"] = '<x-workspace-id>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}"
response = http.request(request)
puts response.read_body{
"agent": {
"_id": "64f9b12a",
"status": "ready",
"phoneNumberIds": ["750cd920"]
},
"phoneNumber": {
"_id": "750cd920",
"agentId": "64f9b12a",
"recordingEnabled": true,
"recordingPublic": false,
"officeHours": {
"monday": ["09:00-17:00"],
"tuesday": []
},
"metadataTags": {
"department": "support",
"priority": "high"
}
},
"pathwayId": "pwy_abc123",
"direction": "bidirectional"
}
Telephony
Assign Phone Number to Agent
Assign a specific phone number to an agent’s call flow, configure recording options, office hours, metadata, and automatically update SIP trunks.
POST
/
v1
/
api
/
agents
/
{agentId}
/
bind
/
{phoneNumberId}
Assign Phone Number to Agent
curl --request POST \
--url https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-workspace-id: <x-workspace-id>' \
--data '
{
"recordCalls": true,
"recordingPublic": true,
"officeHours": {},
"metadataTags": {}
}
'import requests
url = "https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}"
payload = {
"recordCalls": True,
"recordingPublic": True,
"officeHours": {},
"metadataTags": {}
}
headers = {
"x-workspace-id": "<x-workspace-id>",
"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-workspace-id': '<x-workspace-id>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({recordCalls: true, recordingPublic: true, officeHours: {}, metadataTags: {}})
};
fetch('https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}', 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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}",
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([
'recordCalls' => true,
'recordingPublic' => true,
'officeHours' => [
],
'metadataTags' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-workspace-id: <x-workspace-id>"
],
]);
$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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}"
payload := strings.NewReader("{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-workspace-id", "<x-workspace-id>")
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.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}")
.header("x-workspace-id", "<x-workspace-id>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trillet.ai/v1/api/agents/{agentId}/bind/{phoneNumberId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-workspace-id"] = '<x-workspace-id>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"recordCalls\": true,\n \"recordingPublic\": true,\n \"officeHours\": {},\n \"metadataTags\": {}\n}"
response = http.request(request)
puts response.read_body{
"agent": {
"_id": "64f9b12a",
"status": "ready",
"phoneNumberIds": ["750cd920"]
},
"phoneNumber": {
"_id": "750cd920",
"agentId": "64f9b12a",
"recordingEnabled": true,
"recordingPublic": false,
"officeHours": {
"monday": ["09:00-17:00"],
"tuesday": []
},
"metadataTags": {
"department": "support",
"priority": "high"
}
},
"pathwayId": "pwy_abc123",
"direction": "bidirectional"
}
Path Parameters
string
required
The ID of the agent whose call flow will be bound to the phone number.
string
required
The ID of the phone number to bind.
Headers
string
required
Workspace identifier for the API. Required to scope the binding operation.
Request Body
boolean
Whether calls should be recorded. When enabled, updates Twilio trunk recording settings (
Default:
record-from-ringing).Default:
false.boolean
Whether recordings are publicly accessible.
Default:
Default:
false.object
Custom office hours configuration for the phone number (stored with the binding).
Example:
Example:
{ "monday": ["09:00-17:00"], "tuesday": [] }.object
Arbitrary metadata key/value tags to store with the phone number.
Example:
Example:
{ "department": "sales", "priority": "high" }.Response Fields
object
The updated agent object, including its bound phone number IDs.
object
The updated phone number object after binding and SIP trunk configuration.
string
The ID of the call flow associated with this assignment.
string
The direction of the call flow (
inbound, outbound, or bidirectional).{
"agent": {
"_id": "64f9b12a",
"status": "ready",
"phoneNumberIds": ["750cd920"]
},
"phoneNumber": {
"_id": "750cd920",
"agentId": "64f9b12a",
"recordingEnabled": true,
"recordingPublic": false,
"officeHours": {
"monday": ["09:00-17:00"],
"tuesday": []
},
"metadataTags": {
"department": "support",
"priority": "high"
}
},
"pathwayId": "pwy_abc123",
"direction": "bidirectional"
}
⌘I
