Error Handling
SwiftPay uses conventional HTTP response codes to indicate the success or failure of an API request.HTTP Status Codes
| Code | Description |
|---|---|
200 | Success - The request completed successfully |
201 | Created - A new resource was created |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Invalid or missing API key |
403 | Forbidden - Valid key but insufficient permissions |
404 | Not Found - The requested resource doesn’t exist |
409 | Conflict - The request conflicts with current state |
422 | Validation Error - The request body failed validation |
429 | Rate Limited - Too many requests |
500 | Server Error - Something went wrong on our end |
Error Response Format
All error responses follow a consistent format:Error Object Properties
The type of error. One of: -
unauthenticated - Invalid or missing API key -
unauthorized - Insufficient permissions - validation_error - Invalid
request parameters - not_found - Resource not found - conflict - Resource
state conflict - rate_limit_exceeded - Too many requests -
internal_server_error - Internal server error - external_service_error -
External service error - database_error - Database errorA human-readable description of the error.
A unique identifier for this request. Include this when contacting support.
For validation errors, an object containing field-specific error messages.
Error Types
Authentication Error
Returned when the API key is missing or invalid.Validation Error
Returned when request parameters fail validation.Not Found Error
Returned when the requested resource doesn’t exist.Conflict Error
Returned when the request conflicts with the current state.Handling Errors
Best Practices
Log Request IDs
Always log the
requestId from error responses. This helps our support
team debug issues quickly.Retry on 5xx
Server errors (5xx) are usually temporary. Implement exponential backoff
and retry logic.
Validate Locally
Validate request data before sending to reduce validation errors.
Handle Edge Cases
Always handle error responses gracefully to provide a good user
experience.