Description
Updates the agent assignments for a phone number. You can configure separate agents for handling inbound calls (calls received) and outbound calls (calls made from this number).
This is essential for:
- Inbound AI receptionist: Link an agent to answer incoming calls
- Outbound campaigns: Link an agent for making automated outbound calls
- Dual-purpose numbers: Use different agents for inbound vs outbound
Authentication
Path Parameters
Phone number in E.164 format (e.g., +14155551234)
Request Body
Agent ID for handling incoming calls to this number.
- Use the
agent_id returned when creating a voice agent
- Set to empty string
"" or null to clear the assignment
Example: "agent_abc123"
Agent ID for making outbound calls from this number.
- Used in voice campaigns when this number is the caller ID
- Set to empty string
"" or null to clear the assignment
Example: "agent_xyz789"
Optional friendly name for the phone number.Example: "Main Reception Line"
At least one of inbound_agent_id, outbound_agent_id, or nickname is required.
Response Fields
Whether the update was successful
The phone number that was updated
The inbound agent ID (if updated)
The outbound agent ID (if updated)
The nickname (if updated)
Example Requests
Link Inbound Agent (AI Receptionist)
curl -X POST "https://api.teli.ai/v1/voice/phone-numbers/+14155551234/update-agent" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbound_agent_id": "agent_abc123"
}'
const response = await fetch(
'https://api.teli.ai/v1/voice/phone-numbers/+14155551234/update-agent',
{
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
inbound_agent_id: 'agent_abc123'
})
}
);
const data = await response.json();
console.log(data);
import requests
response = requests.post(
'https://api.teli.ai/v1/voice/phone-numbers/+14155551234/update-agent',
headers={'X-API-Key': 'YOUR_API_KEY'},
json={
'inbound_agent_id': 'agent_abc123'
}
)
data = response.json()
print(data)
Link Both Inbound and Outbound Agents
curl -X POST "https://api.teli.ai/v1/voice/phone-numbers/+14155551234/update-agent" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbound_agent_id": "agent_abc123",
"outbound_agent_id": "agent_xyz789",
"nickname": "Main Sales Line"
}'
Clear an Agent Assignment
curl -X POST "https://api.teli.ai/v1/voice/phone-numbers/+14155551234/update-agent" \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inbound_agent_id": ""
}'
Example Responses
{
"success": true,
"phone_number": "+14155551234",
"message": "Phone number updated successfully",
"inbound_agent_id": "agent_abc123",
"outbound_agent_id": "agent_xyz789",
"nickname": "Main Sales Line",
"powered_by": "Teli"
}
{
"error": "At least one of inbound_agent_id, outbound_agent_id, or nickname required",
"success": false,
"powered_by": "Teli"
}
{
"error": "Agent not found or invalid agent ID",
"success": false,
"powered_by": "Teli"
}
{
"error": "Phone number not found or invalid",
"success": false,
"powered_by": "Teli"
}
Use Cases
1. AI Receptionist (Inbound Only)
Link a voice agent to answer incoming calls automatically:
{
"inbound_agent_id": "agent_receptionist_001"
}
When calls come in to this number, the linked agent will answer and handle the conversation.
2. Outbound Campaign Number
Link an agent for making outbound calls:
{
"outbound_agent_id": "agent_sales_dialer_001"
}
When starting a voice campaign with this phone number as the caller ID, this agent will be used.
3. Dual-Purpose Number
Use different agents for inbound vs outbound:
{
"inbound_agent_id": "agent_support_001",
"outbound_agent_id": "agent_sales_001",
"nickname": "Customer Success Line"
}
- Incoming calls: Handled by support agent
- Outgoing campaigns: Uses sales agent
Notes
- Agent IDs: Use the
agent_id returned from POST /v1/agents (voice agent creation)
- Phone format: Always use E.164 format (
+1XXXXXXXXXX)
- Clearing agents: Set to empty string
"" or null to remove an agent assignment
- Both methods supported:
POST and PATCH are both accepted
POST /v1/voice/phone-numbers/create - Create a new phone number
GET /v1/voice/phone-numbers - List phone numbers
POST /v1/agents - Create a voice agent
GET /v1/agents - List agents
POST /v1/voice/campaigns - Start a voice campaign