Skip to main content
POST
Attach phone numbers to an agent
Attach or assign phone numbers to voice agents to enable inbound and outbound calling capabilities. This endpoint allows you to connect phone numbers from various telephony providers to your voice agents.

API Endpoint

Endpoint: POST /api/agent/attach-phone-number Content-Type: application/json Authentication: Required (Token header: token or api_access_token)

Request Body

Request Parameters

Supported Providers

Request Examples

cURL

PHP

Response

Success Response

Status Code: 200 OK

Response Fields

Error Responses

400 - Bad Request

Status Code: 400 Bad Request
Common error messages:
  • "Agent ID is required"
  • "Provider is required"
  • "Phone number(s) are required"
  • "Invalid phone number format. Use E.164 format"
  • "Phone number is already attached to another agent"
  • "Provider not configured for your account"

401 - Authentication Error

Status Code: 401 Unauthorized

404 - Agent Not Found

Status Code: 404 Not Found

409 - Conflict

Status Code: 409 Conflict

422 - Validation Error

Status Code: 422 Unprocessable Entity

500 - Server Error

Status Code: 500 Internal Server Error

Phone Number Format

Phone numbers must be in E.164 format:

E.164 Format Examples by Country

Usage Examples

Examples are provided above for cURL and PHP. Client library code examples (JavaScript/Python) have been removed — use the cURL examples as the canonical requests (send numbers as an array of E.164 strings).

Important Notes

  1. Phone Number Format: Always use E.164 format with the + prefix, country code, and number without spaces or special characters.
  2. Provider Configuration: Ensure the telephony provider is properly configured in your account before attaching numbers.
  3. Number Availability: Use the List Phone Numbers API to check available numbers before attaching.
  4. One Number, One Agent: A phone number can only be attached to one agent at a time. Attempting to attach an already-used number will result in a 409 Conflict error.
  5. Multiple Numbers: You can attach multiple phone numbers to a single agent for load balancing or regional coverage.
  6. Number Purpose: Numbers with specific purposes (TEST, PRODUCTION) should be used accordingly to avoid mixing test and production traffic.
  7. Detaching Numbers: To detach a number and attach it to a different agent, first detach it from the current agent or use the update agent endpoint.
  8. Inbound Calls: Once attached, the phone number will route inbound calls to the specified agent automatically.
  9. Webhooks: Ensure your agent has proper webhook configurations to handle call events.
  10. Provider Limits: Some providers may have limits on the number of concurrent calls per number. Check your provider’s documentation.

Workflow Integration

Complete Agent Setup with Phone Number

Headers

token
string
required

API token for authentication

Body

application/json
agent_id
integer
required

ID of the agent to attach phone numbers to

numbers
string[]
required

Phone numbers to attach to the agent. Must include country code with + prefix (e.g., '+1234567890'). Provide one or more numbers.

Minimum array length: 1

Response

Numbers attached successfully

success
boolean
message
string
data
object