Errors
Understanding and handling Prisme.ai API errors
The Prisme.ai API uses conventional HTTP response codes to indicate the success or failure of an API request. This page provides a comprehensive guide to understanding and handling errors from the API.
Error Response Format
All API errors follow a consistent format:
As for any request, you will also receive a x-correlation-id
response header that will help you find relevent activity events or application logs.
code
A machine-readable string identifier for the error type. Use this for programmatic error handling.
message
A human-readable description of the error. The message may change over time, so don’t rely on exact message matching.
details
An optional object containing additional information about the error, which varies based on the error type.
requestId
A unique identifier for the request that can be provided to support for troubleshooting.
HTTP Status Codes
Code | Description |
---|---|
200 | OK - The request succeeded |
201 | Created - A new resource was successfully created |
202 | Accepted - The request has been accepted for processing |
204 | No Content - The request succeeded but returns no content |
Code | Description |
---|---|
200 | OK - The request succeeded |
201 | Created - A new resource was successfully created |
202 | Accepted - The request has been accepted for processing |
204 | No Content - The request succeeded but returns no content |
Code | Description |
---|---|
400 | Bad Request - The request contains invalid parameters or syntax |
401 | Unauthorized - Authentication is required or has failed |
403 | Forbidden - The authenticated user doesn’t have sufficient permissions |
404 | Not Found - The requested resource does not exist |
409 | Conflict - The request conflicts with the current state of the resource |
422 | Unprocessable Entity - The request was well-formed but contains semantic errors |
429 | Too Many Requests - You’ve exceeded the rate limits |
Code | Description |
---|---|
500 | Internal Server Error - Something went wrong on our servers |
502 | Bad Gateway - A service required to fulfill the request is unavailable |
503 | Service Unavailable - The server is temporarily unavailable |
504 | Gateway Timeout - A service required to fulfill the request timed out |
Common Error Codes
Authentication Errors
Authentication Errors
Code | HTTP Status | Description |
---|---|---|
invalid_token | 401 | The provided token is invalid, expired, or has been revoked |
missing_token | 401 | No authentication token was provided |
invalid_credentials | 401 | The provided username/password or API key is incorrect |
token_expired | 401 | The provided token has expired |
Authorization Errors
Authorization Errors
Resource Errors
Resource Errors
Code | HTTP Status | Description |
---|---|---|
resource_not_found | 404 | The requested resource does not exist |
resource_already_exists | 409 | A resource with the specified identifier already exists |
resource_conflict | 409 | The request conflicts with the current state of the resource |
resource_locked | 423 | The resource is currently locked and cannot be modified |
Validation Errors
Validation Errors
Code | HTTP Status | Description |
---|---|---|
invalid_request | 400 | The request body or parameters are invalid |
invalid_parameter | 400 | A specific parameter has an invalid value |
missing_parameter | 400 | A required parameter is missing |
validation_failed | 422 | The input failed validation checks |
Rate Limiting Errors
Rate Limiting Errors
Code | HTTP Status | Description |
---|---|---|
rate_limit_exceeded | 429 | You’ve exceeded the rate limit for this endpoint |
quota_exceeded | 429 | You’ve exceeded your usage quota |
concurrent_request_limit | 429 | Too many concurrent requests |
Server Errors
Server Errors
Code | HTTP Status | Description |
---|---|---|
internal_error | 500 | An unexpected error occurred on the server |
service_unavailable | 503 | The service is temporarily unavailable |
gateway_timeout | 504 | A dependent service timed out |
database_error | 500 | A database operation failed |
Error Examples
Handling Errors
Check HTTP Status Code
First, check the HTTP status code to understand the general category of the error:
Parse Error Code
For more specific error handling, check the error code:
Implement Retry Logic
For certain errors, especially 429 (rate limiting) and some 5xx errors, implement retry logic with exponential backoff:
Log Errors
Log errors with their requestId for troubleshooting:
The requestId is particularly important when contacting support, as it allows for quick identification of the specific request in server logs.
Best Practices
Graceful Degradation
Design your application to function (perhaps with limited capabilities) even when API requests fail.
User-Friendly Messages
Translate error codes into user-friendly messages rather than displaying raw API errors to users.
Centralized Error Handling
Implement a centralized error handling mechanism to ensure consistent handling of errors across your application.
Contextual Recovery
Provide context-specific recovery options based on the error type (e.g., refresh button, edit form, etc.).
Validation Precheck
Validate inputs on the client side before sending requests to reduce validation errors.
Error Tracking
Implement error tracking to monitor error patterns and improve user experience over time.
Troubleshooting Common Errors
Authentication Failed
Authentication Failed
If you receive a 401 error:
- Check that your token is correctly formatted in the Authorization header
- Verify that your token hasn’t expired
- Ensure you’re using the correct authentication method for the endpoint
- Try generating a new token
Permission Denied
Permission Denied
If you receive a 403 error:
- Verify that the authenticated user has the necessary permissions
- Check if you’re using an API key with limited scopes
- Ensure you’re accessing resources within the correct workspace
- Check if the resource has additional access controls
Common permission errors include attempting to access:
- Resources in workspaces you’re not a member of
- Admin-only functionality without admin privileges
- Resources owned by other users
Rate Limit Exceeded
Rate Limit Exceeded
If you receive a 429 error:
- Implement proper rate limit handling with backoff
- Check the
Retry-After
header for guidance on when to retry - Optimize your code to batch requests where possible
- Consider upgrading your plan if you consistently hit limits
See the Rate Limits page for more details on rate limiting.
Invalid Parameters
Invalid Parameters
If you receive a 400 or 422 error:
- Check the
details
field in the error response for specific validation failures - Verify that you’re sending the correct data types
- Check for required fields that might be missing
- Ensure values are within acceptable ranges or formats