Error Handling
Understand API error responses and how to handle them gracefully.
Error Format
When an API request fails, Nur returns a consistent JSON error response with an appropriate HTTP status code. Every error response includes a code and a human-readable message. Some errors also include a details object with additional context.
HTTP Status Codes
The API uses standard HTTP status codes to indicate the outcome of a request. Codes in the 4xx range indicate client errors, while 5xx codes indicate server-side issues.
| Status | Name | Description | Common Causes |
|---|---|---|---|
| 400 | Bad Request | The request body or parameters are malformed. | Invalid JSON, missing required fields, wrong data types |
| 401 | Unauthorized | Authentication is missing or invalid. | Missing API key, expired key, malformed Authorization header |
| 403 | Forbidden | The API key lacks required permissions. | Insufficient key scopes, accessing another account's resources |
| 404 | Not Found | The requested resource does not exist. | Invalid voice ID, deleted resource, wrong endpoint URL |
| 409 | Conflict | The request conflicts with current state. | Duplicate resource creation, concurrent modification |
| 413 | Payload Too Large | The request body exceeds the size limit. | Audio file too large, text input exceeds character limit |
| 422 | Unprocessable Entity | The request is well-formed but semantically invalid. | Unsupported audio format, invalid language code, incompatible options |
| 429 | Rate Limited | Too many requests in a given time window. | Exceeded per-minute request limit, exceeded monthly quota |
| 500 | Server Error | An unexpected error occurred on the server. | Internal bug, infrastructure failure, temporary outage |
| 503 | Service Unavailable | The service is temporarily unavailable. | Planned maintenance, capacity limits, dependency outage |
Error Codes
In addition to HTTP status codes, each error response includes a specific error.code string that you can use for programmatic error handling.
| Code | HTTP Status | Description |
|---|---|---|
| invalid_api_key | 401 | The provided API key is invalid, expired, or has been revoked. |
| missing_parameter | 400 | A required parameter is missing from the request. |
| invalid_parameter | 400 | A parameter value is invalid or out of the accepted range. |
| file_too_large | 413 | The uploaded file exceeds the maximum allowed size. |
| unsupported_format | 422 | The provided file format is not supported for this operation. |
| voice_not_found | 404 | The specified voice ID does not exist or is not accessible. |
| rate_limit_exceeded | 429 | The request rate limit or monthly quota has been exceeded. |
| insufficient_credits | 403 | Your account does not have enough credits for this operation. |
| service_unavailable | 503 | The service is temporarily unavailable. Retry after a short delay. |
Handling Errors
The Nur SDKs throw typed error classes that you can catch and handle based on the error type. Always wrap API calls in error handling to provide a graceful experience.
Retry Strategy
Not all errors should be retried. Understanding which errors are transient helps you build a robust integration.
Retryable Errors
429Rate Limited - retry after the Retry-After delay500Server Error - retry with exponential backoff503Service Unavailable - retry with exponential backoff
Non-Retryable Errors
400Bad Request - fix the request parameters401Unauthorized - check your API key403Forbidden - check key scopes or credits404Not Found - verify the resource exists
Rate Limit Headers
Every API response includes rate limit headers so you can proactively manage your request rate before hitting the limit.
Tip: Proactive Rate Limiting
Monitor the X-RateLimit-Remaining header and slow down your requests when approaching zero. This is more efficient than waiting for a 429 response and retrying.