Handle inbound call
API Endpoints
Handle Inbound Call
Process an incoming call from Twilio. This endpoint is typically called by Twilio webhooks when a call is received.
POST
Handle inbound call
Overview
Process an incoming call from Twilio. This endpoint is typically called by Twilio webhooks when a call is received on a configured phone number. The endpoint returns TwiML XML to instruct Twilio how to handle the call.Query Parameters
ID of the AI agent to handle the inbound call. Can also be provided in the request body or determined from the ForwardedFrom phone number.
Request Body
This endpoint acceptsapplication/x-www-form-urlencoded data from Twilio webhooks.
Twilio call SID (automatically provided by Twilio)
Caller’s phone number (automatically provided by Twilio)
Called phone number (automatically provided by Twilio)
Forwarded from phone number if the call was forwarded (automatically provided by Twilio)
ID of the AI agent to handle the call. Can be provided in query string, request body, or determined from ForwardedFrom phone number.
Optional external call ID for tracking purposes.
Example Request
Response
On success, this endpoint returns TwiML XML that instructs Twilio to stream the call audio to the Call24x7.AI WebSocket server.Success Response (TwiML XML)
Error Response (JSON)
Always
false for errorsHuman-readable error message
Error code. Possible values:
MISSING_PARAMS, AGENT_NOT_FOUND, INSUFFICIENT_BALANCE, INTERNAL_ERRORExample Error Response
Agent ID Resolution
Theagent_id can be provided in three ways (checked in order):
- Query parameter:
?agent_id=agent-123 - Request body:
agent_id=agent-123in the form data - ForwardedFrom lookup: If
ForwardedFromis provided, the system attempts to find the user by phone number and use their active inbound agent
Twilio Configuration
To use this endpoint, configure your Twilio phone number’s webhook URL to point to:Notes
- This endpoint is designed to be called by Twilio webhooks, not directly by your application
- The endpoint returns TwiML XML on success, not JSON
- Ensure your account has sufficient balance before receiving calls
- Calls are billed at $0.15 per minute with precise second-by-second billing
Authorizations
API key authentication. Include your API key in the Authorization header as: Bearer YOUR_API_KEY
Query Parameters
ID of the AI agent to handle the inbound call
Body
application/x-www-form-urlencoded
Twilio webhook parameters
Twilio webhook parameters for inbound calls
Response
TwiML response for Twilio
TwiML XML response

