Error Handling
The Turris Public API uses conventional HTTP response codes and returns detailed error information to help you handle issues gracefully.HTTP Status Codes
| Status Code | Meaning |
|---|---|
200 | Success - Request completed successfully |
201 | Created - Resource was created successfully |
400 | Bad Request - Invalid request parameters |
401 | Unauthorized - Missing or invalid authentication |
403 | Forbidden - Valid auth but insufficient permissions |
404 | Not Found - Resource doesn’t exist |
422 | Unprocessable Entity - Validation failed |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error - Something went wrong on our end |
Error Response Format
All error responses follow a consistent format:Response Fields
| Field | Type | Description |
|---|---|---|
statusCode | number | HTTP status code |
requestId | string | Unique identifier for this request (useful for support) |
errorType | string | Category of the error |
errorMessage | string[] | Array of human-readable error messages |
timestamp | string | ISO 8601 timestamp of when the error occurred |
Error Types
unauthorized
Authentication failed or was not provided.
- Missing
Authorizationheader - Expired JWT token
- Invalid token format
forbidden
Authentication succeeded but the request is not allowed.
- IP not in allowlist (for Restricted Access Tokens)
- Insufficient permissions for the requested resource
invalid_input
Request validation failed.
- Missing required fields
- Invalid field formats
- Mutually exclusive parameters provided together
not_found
The requested resource doesn’t exist.
internal_error
Something went wrong on our servers.
If you receive a 500 error, please contact support with the
requestId for investigation.Handling Errors
Example: JavaScript/TypeScript
Example: Python
Best Practices
Always check the status code
Always check the status code
Don’t assume requests succeed. Check the HTTP status code and handle errors appropriately.
Log the requestId
Log the requestId
The
requestId is essential for debugging. Log it when errors occur so you can reference it when contacting support.Implement retry logic
Implement retry logic
For transient errors (429, 500, 503), implement exponential backoff retry logic.
Handle token expiration gracefully
Handle token expiration gracefully
OAuth tokens expire after 60 minutes. Implement proactive token refresh or handle 401 errors by refreshing and retrying.