code and a human-readable message.
Error Response Format
All errors return a JSON object with a singleerror key:
details field with per-field error messages:
Schema
| Field | Type | Description |
|---|---|---|
error.code | string | Machine-readable error code (see table below) |
error.message | string | Human-readable description of the error |
error.details | object | Field-specific validation errors. Each key is a field name, each value is an array of error strings. Only present for validation errors. |
HTTP Status Codes
| Status | Meaning | When |
|---|---|---|
400 | Bad Request | Missing required parameters, malformed JSON, invalid arguments |
401 | Unauthorized | Missing or invalid API key, expired JWT token |
403 | Forbidden | Authenticated but not authorized for this resource |
404 | Not Found | Resource doesn’t exist or isn’t accessible |
422 | Unprocessable Content | Validation failed, invalid state transition, payment error |
429 | Too Many Requests | Rate limit exceeded (see Rate Limiting) |
Error Codes
Authentication & Authorization
| Code | Status | Description |
|---|---|---|
authentication_required | 401 | Request requires a valid JWT token |
authentication_failed | 401 | Email or password is incorrect |
invalid_token | 401 | API key or JWT token is invalid or expired |
invalid_provider | 400 | OAuth provider not recognized |
access_denied | 403 | User doesn’t have permission for this action |
Resource Errors
| Code | Status | Description |
|---|---|---|
record_not_found | 404 | Resource doesn’t exist or isn’t accessible in the current store |
resource_invalid | 422 | Resource couldn’t be saved |
Validation Errors
| Code | Status | Description |
|---|---|---|
validation_error | 422 | Model validation failed. Check details for field-specific messages. |
parameter_missing | 400 | A required parameter is missing |
parameter_invalid | 400 | A parameter has an invalid value |
Order Errors
| Code | Status | Description |
|---|---|---|
order_not_found | 404 | Order doesn’t exist or doesn’t belong to the current user/guest |
order_already_completed | 422 | Cannot modify an order that has already been completed |
order_cannot_transition | 422 | Order can’t move to the requested state (e.g., advancing without an address) |
order_empty | 422 | Order has no line items |
order_invalid_state | 422 | Order is in an invalid state for this operation |
Line Item & Stock Errors
| Code | Status | Description |
|---|---|---|
line_item_not_found | 404 | Line item doesn’t exist in this order |
variant_not_found | 404 | Variant doesn’t exist or isn’t available |
insufficient_stock | 422 | Not enough stock to fulfill the requested quantity |
invalid_quantity | 422 | Quantity must be a positive integer |
Payment Errors
| Code | Status | Description |
|---|---|---|
payment_failed | 422 | Payment was declined or couldn’t be processed |
payment_processing_error | 422 | Error communicating with the payment gateway |
gateway_error | 422 | Payment gateway returned an error |
Digital Download Errors
| Code | Status | Description |
|---|---|---|
attachment_missing | 403 | File attachment not found for this digital product |
download_unauthorized | 403 | User is not authorized to download this file |
digital_link_expired | 403 | Download link has expired |
download_limit_exceeded | 403 | Maximum number of downloads reached |
Other Errors
| Code | Status | Description |
|---|---|---|
rate_limit_exceeded | 429 | Too many requests. Retry after the Retry-After header value. |
request_too_large | 413 | Request body exceeds the size limit |
processing_error | 422 | Generic server-side processing error |
invalid_request | 400 | Request is malformed (e.g., invalid JSON body) |
Examples
Not Found
404
Validation Error
422
Insufficient Stock
422
Invalid State Transition
422
Handling Errors in the SDK
The@spree/sdk package throws a SpreeError for all non-2xx responses:

