Error Handling
HTTP status codes, error response format, and common error codes
Error Handling
This guide covers the error response format and error codes used by the PRIME API.
Error Response Format
All errors return a JSON object with the following structure:
Fields
HTTP Status Codes
Client Errors (4xx)
Server Errors (5xx)
Error Reasons
The API uses specific reason codes to indicate the type of error.
Authentication & Authorization
Validation Errors
Resource Errors
Trading Errors
Deposit/Withdrawal Errors
System Errors
Resource Names
Errors may include a resource name indicating which entity caused the error.
Error Examples
Invalid Request
Authentication Failed
MFA Required
When MFA is enabled for a user but the TOTP code (challenge field) was not provided in the login request:
To resolve, re-submit the login request with the challenge field containing the TOTP code.
Permission Denied
Resource Not Found
Insufficient Funds
Rate Limited
Handling Errors
Best Practices
- Check HTTP status code first - Categorize by 4xx vs 5xx
- Parse the error response - Extract
messageanddetails - Handle specific reasons - Implement logic for expected errors
- Log unexpected errors - Include correlation ID for support
- Implement retries for 5xx - Use exponential backoff
Example Error Handler (JavaScript)
Retry Strategy
For transient errors (5xx, rate limits):
Correlation ID
Every request is assigned a correlation ID for tracing. Include this ID when contacting support.
Finding the Correlation ID
- Check response headers:
X-Correlation-ID - Check error details: may include
correlation_idfield
Providing Your Own
You can provide a correlation ID in the request: