Error response format
All error responses follow a consistent structure:| Field | Description |
|---|---|
success | Always false for errors |
error.code | Machine-readable error code |
error.message | Human-readable description |
error.details | Additional context (optional) |
HTTP status codes
| Status | Meaning | When it occurs |
|---|---|---|
| 400 | Bad Request | Invalid input, malformed JSON, missing required fields |
| 401 | Unauthorized | Missing or invalid authentication token |
| 403 | Forbidden | Valid token but insufficient permissions |
| 404 | Not Found | Resource does not exist or is not accessible |
| 409 | Conflict | Resource conflict (e.g., duplicate SKU) |
| 422 | Unprocessable Entity | Validation failed |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side error |
| 503 | Service Unavailable | Temporary unavailability |
Common error codes
Authentication errors
| Code | Status | Description |
|---|---|---|
INVALID_CREDENTIALS | 401 | Email or password incorrect |
TOKEN_EXPIRED | 401 | Access token has expired |
TOKEN_INVALID | 401 | Token is malformed or revoked |
REFRESH_TOKEN_REUSED | 401 | Refresh token has already been used |
INSUFFICIENT_SCOPE | 403 | Token lacks required scope |
Permission errors
| Code | Status | Description |
|---|---|---|
INSUFFICIENT_PERMISSIONS | 403 | User role cannot perform this action |
MISSING_CAPABILITY | 403 | Subscription tier does not include this feature |
LIMIT_EXCEEDED | 403 | Resource or rate limit reached |
TENANT_MISMATCH | 403 | Attempting to access another tenant’s resources |
Validation errors
| Code | Status | Description |
|---|---|---|
VALIDATION_ERROR | 422 | Input failed validation |
DUPLICATE_SKU | 409 | SKU already exists in your portfolio |
INVALID_FORMAT | 400 | Field format is incorrect |
REQUIRED_FIELD_MISSING | 400 | Required field not provided |
Resource errors
| Code | Status | Description |
|---|---|---|
NOT_FOUND | 404 | Resource does not exist |
ALREADY_EXISTS | 409 | Resource already exists |
RESOURCE_LOCKED | 423 | Resource is locked for editing |
Validation error details
Validation errors include field-level details:field value to highlight specific form fields or log the exact problem.
Handling errors in code
Basic error handling
Retry logic for transient errors
Some errors are transient and can be retried:| Status | Retry? | Strategy |
|---|---|---|
| 429 | Yes | Wait for Retry-After duration |
| 500 | Yes | Exponential backoff, max 3 retries |
| 503 | Yes | Exponential backoff, max 3 retries |
| 401 | Maybe | Refresh token, then retry once |
| 400, 403, 404, 409, 422 | No | These indicate a problem with the request |
Security considerations
Do not expose error details to end users. Internal error codes and stack traces should be logged, not displayed. Show generic messages to users. 404 for access denied. When a user requests a resource they cannot access (wrong tenant, insufficient permissions), the API returns 404 rather than 403 to avoid revealing that the resource exists. Rate limit errors do not confirm existence. Rate limiting is applied before resource lookup, so a 429 does not indicate whether the requested resource exists.Logging recommendations
Log the following for debugging:- Request URL and method
- Response status code
- Error code and message
- Request ID (from
X-Request-Idheader) - Timestamp
- Authentication tokens
- Full request bodies containing sensitive data
- User passwords or secrets

