Error Handling
Learn about error responses and how to handle them in your applications.
The 747 SMS API uses standard HTTP status codes and returns detailed error information in the response body. Understanding these errors will help you troubleshoot issues and improve your application's reliability.
Error Response Format
All error responses follow a consistent format:
{
"error": {
"code": "error_code",
"message": "A human-readable error message",
"details": {
// Additional error details when available
}
}
}HTTP Status Codes
The API uses the following HTTP status codes:
| Status Code | Description |
|---|---|
| 200 OK | The request was successful |
| 201 Created | A new resource was successfully created |
| 400 Bad Request | The request was invalid or malformed |
| 401 Unauthorized | Authentication failed or was not provided |
| 403 Forbidden | The authenticated user doesn't have permission |
| 404 Not Found | The requested resource doesn't exist |
| 422 Unprocessable Entity | The request was well-formed but had semantic errors |
| 429 Too Many Requests | Rate limit exceeded |
| 500 Internal Server Error | An error occurred on the server |
Common Error Codes
Here are some common error codes you might encounter:
| Error Code | Description |
|---|---|
| invalid_request | The request is missing required parameters or has invalid parameters |
| authentication_failed | Authentication credentials are invalid |
| insufficient_funds | Account balance is too low to complete the request |
| invalid_phone_number | The provided phone number is invalid or in an unsupported format |
| message_too_long | The message exceeds the maximum allowed length |
| rate_limit_exceeded | You've exceeded the rate limit for API requests |
| resource_not_found | The requested resource (message, account, etc.) doesn't exist |
Error Examples
Invalid Phone Number
// HTTP Status: 400 Bad Request
{
"error": {
"code": "invalid_phone_number",
"message": "The phone number '+1555123' is invalid. Phone numbers must be in E.164 format.",
"details": {
"parameter": "to"
}
}
}Authentication Failed
// HTTP Status: 401 Unauthorized
{
"error": {
"code": "authentication_failed",
"message": "Invalid or expired access token",
"details": {
"hint": "Generate a new access token"
}
}
}Rate Limit Exceeded
// HTTP Status: 429 Too Many Requests
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please try again later.",
"details": {
"rate_limit": {
"limit": 100,
"remaining": 0,
"reset_at": "2023-03-25T12:00:00Z"
}
}
}
}Rate Limit Headers
All responses include rate limit information in the headers:
X-RateLimit-Limit: Maximum requests per minuteX-RateLimit-Remaining: Remaining requests in the current windowX-RateLimit-Reset: Time when the rate limit resets (Unix timestamp)