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
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | Unique identifier of the voice agent |
provider | string | Yes | Telephony provider name (see supported providers below) |
numbers | array | Yes | Phone numbers in E.164 format (e.g., ["+918062810341"]). Provide one or more numbers. |
Supported Providers
| Provider | Value | Description |
|---|---|---|
| San Software | san | San Software telephony platform |
| Ozonetell | ozonetell | Ozonetell cloud communication platform |
| Twilio | twilio | Global cloud communications platform |
| Exotel | exotel | Leading cloud telephony provider in India |
| Telnyx | telnyx | Global carrier network provider |
| Vonage | vonage | Cloud communications platform |
| Plivo | plivo | Cloud communications platform |
| Bandwidth | bandwidth | Enterprise communications platform |
Request Examples
cURL
PHP
Response
Success Response
Status Code:200 OK
Response Fields
| Field | Type | Description |
|---|---|---|
error | boolean | Indicates if there was an error (false for success) |
code | integer | HTTP status code |
message | string | Success or error message |
timestamp | integer | Unix timestamp in milliseconds |
data | object | Response data object |
data.agent_id | string | ID of the agent |
data.phone_numbers | array | Attached phone numbers in E.164 format |
data.provider | string | Telephony provider |
data.attached_at | string | ISO 8601 timestamp of attachment |
data.status | string | Status of the phone number (active, pending, inactive) |
Error Responses
400 - Bad Request
Status Code:400 Bad Request
"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:| Format | Example | Description |
|---|---|---|
| E.164 | +918062810341 | International format with + prefix, country code, and number |
| ❌ Invalid | 918062810341 | Missing + prefix |
| ❌ Invalid | (918) 062-810341 | Contains special characters |
| ❌ Invalid | +91 8062 810341 | Contains spaces |
E.164 Format Examples by Country
| Country | Country Code | Example |
|---|---|---|
| India | +91 | +918062810341 |
| United States | +1 | +12025551234 |
| United Kingdom | +44 | +442012345678 |
| Australia | +61 | +61212345678 |
| Canada | +1 | +14165551234 |
| Singapore | +65 | +6512345678 |
| UAE | +971 | +971501234567 |
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 (sendnumbers as an array of E.164 strings).
Important Notes
-
Phone Number Format: Always use E.164 format with the
+prefix, country code, and number without spaces or special characters. - Provider Configuration: Ensure the telephony provider is properly configured in your account before attaching numbers.
- Number Availability: Use the List Phone Numbers API to check available numbers before attaching.
- 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.
- Multiple Numbers: You can attach multiple phone numbers to a single agent for load balancing or regional coverage.
- Number Purpose: Numbers with specific purposes (TEST, PRODUCTION) should be used accordingly to avoid mixing test and production traffic.
- 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.
- Inbound Calls: Once attached, the phone number will route inbound calls to the specified agent automatically.
- Webhooks: Ensure your agent has proper webhook configurations to handle call events.
- 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
Related Endpoints
- List Phone Numbers - Get available phone numbers
- Create Voice Agent - Create a new voice agent
- Update Voice Agent - Update agent configuration
- List Voice Agents - View all agents
- Make Call - Make outbound calls with your agent

