Skip to main content
Swytcho uses standard HTTP status codes to indicate whether a request succeeded or failed. Every error response includes a machine-readable JSON body so your code can branch on the specific problem, log the right context, and show a useful message to end users.

Error Response Format

Every failed request returns a JSON object with an error field containing three properties.
Error response body

HTTP Status Code Reference


Common Error Types

Your request did not include a valid API key. Make sure you are passing the key in the Authorization header as Bearer YOUR_API_KEY. Keys are available from the API Keys page in your dashboard.
Something about the structure or values in your request is wrong. The error.message field describes the problem precisely — for example, a missing required field or a parameter value outside the allowed range.
You have sent too many requests in a short window. Check the Retry-After response header for the number of seconds to wait before retrying. Implement exponential backoff to avoid hammering the API after the window resets.
An error occurred on Swytcho’s infrastructure. These are rare and typically transient. Retry the request with exponential backoff. If the problem persists for more than a few minutes, check status.swytcho.com or contact support.

Error Handling Best Practices

Follow these practices to make your integration resilient and easy to debug. Retry transient errors with backoff. Network hiccups and 5xx errors are often temporary. Retry up to three times using exponential backoff (e.g. wait 1 s, then 2 s, then 4 s) before surfacing an error to users. Never retry 4xx errors blindly. A 400, 401, 403, or 422 indicates a problem with your request. Retrying without fixing the underlying issue wastes quota. Log the full error body and fix the root cause. Log error.code and error.message. Store both fields in your application logs so you can debug production issues without reproducing them locally. Show user-friendly messages. Translate API error codes into plain-language messages for end users — they should not see raw JSON or HTTP status codes.
Do not log your API key or include it in bug reports. If you suspect a key has been exposed, rotate it immediately from the dashboard.

Code Examples

The examples below show a robust error-handling pattern for both official SDKs.
Use a library like tenacity (Python) or async-retry (Node.js) to add production-grade retry logic without writing it from scratch.