Request & Response Handling
Understanding common request and response patterns will help you build robust integrations across all Telnyx services. This guide covers the universal HTTP concepts that apply to Voice, Messaging, Cloud Storage, IoT, and all other Telnyx APIs.HTTP Methods
Telnyx APIs follow RESTful conventions using standard HTTP methods:GET - Retrieve Resources
Used to fetch information without making changes:POST - Create Resources
Used to create new resources or trigger actions:PATCH - Update Resources
Used to modify existing resources:DELETE - Remove Resources
Used to delete resources:Request Format
Content-Type Headers
Most Telnyx APIs expect JSON payloads:Request Structure
Response Format
Standard Response Structure
Most Telnyx APIs return JSON responses with consistent structure:Success Responses
- 200 OK: Request successful, data returned
- 201 Created: Resource successfully created
- 202 Accepted: Request accepted, processing asynchronously
- 204 No Content: Request successful, no data to return
Error Responses
Error responses include details to help troubleshoot issues:Telnyx API Error Codes
For a comprehensive list of all Telnyx-specific error codes and their meanings, see the API Error Codes reference. This resource provides detailed explanations for each error code to help you troubleshoot and handle API errors effectively. Common error patterns include:- 10xxx codes: Parameter validation errors
- 20xxx codes: Authentication and authorization errors
- 30xxx codes: Resource not found or unavailable errors
- 40xxx codes: Rate limiting and quota errors
- 50xxx codes: Server-side errors
HTTP Status Codes
Client Errors (4xx)
- 400 Bad Request: Invalid request format or parameters
- 401 Unauthorized: Authentication failed
- 403 Forbidden: Authentication succeeded but access denied
- 404 Not Found: Resource doesn’t exist
- 422 Unprocessable Entity: Valid request format but logical errors
- 429 Too Many Requests: Rate limit exceeded
Server Errors (5xx)
- 500 Internal Server Error: Unexpected server error
- 502 Bad Gateway: Upstream service error
- 503 Service Unavailable: Service temporarily unavailable
- 504 Gateway Timeout: Request timeout
Common Headers
Request Headers
Response Headers
Pagination
For endpoints that return lists, Telnyx uses consistent pagination:Request Parameters
Response Metadata
Filtering and Sorting
Common Filter Patterns
Best Practices
Request Optimization
- Use appropriate HTTP methods: Don’t use POST for retrieving data
- Include relevant headers: Specify Content-Type and Accept headers
- Validate input: Check parameters before sending requests
- Handle timeouts: Set appropriate timeout values
Response Handling
- Check status codes: Don’t assume all responses are successful
- Parse error messages: Use error details for troubleshooting
- Handle edge cases: Account for empty results and partial failures
- Log appropriately: Log errors but avoid logging sensitive data
Next Steps
- API Reliability & Retries - Handle failed requests
- Webhook Fundamentals - Receive asynchronous notifications
- API Glossary - Reference for API terminology