Error Handling
The AgentPhone API uses standard HTTP status codes and returns detailed error information in a consistent JSON format.
Error response format
All errors follow this structure:
HTTP status codes
Error codes
VALIDATION_ERROR
Request validation failed. Check the details field for specific field errors.
VALIDATION_ERROR_NUMBER_LIMIT
Phone number limit reached for your plan. Contact us to add more phone lines.
RATE_LIMIT_EXCEEDED
Rate limit exceeded. Check the Retry-After header for when to retry.
PHONE_NUMBER_NOT_FOUND
The requested phone number doesn’t exist or you don’t have access to it.
TWILIO_ERROR
Error from Twilio service. Usually a temporary issue — retry with exponential backoff.
Handling errors
Check response status
Handle rate limits
Retry transient errors
For 429, 500, 502, 503, and 504 errors, implement exponential backoff:
If you’re using the official SDKs, retry logic is built in. The TypeScript SDK automatically retries on 408, 429, and 5xx errors with exponential backoff (default: 2 retries).
