Error Handling & HTTP Status Codes
Error Handling
The API uses standard HTTP status codes and structured JSON error messages for consistent error handling.
HTTP Status Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request successful (GET, POST, DELETE) |
| 201 | Created | New resource created (POST) |
| 400 | Bad Request | Invalid request body, missing parameters, or an unusable query parameter (on every JSON endpoint since v2.122.10, see below) |
| 401 | Unauthorized | No token or invalid token |
| 403 | Forbidden | Token does not have the required scopes |
| 404 | Not Found | Resource not found |
| 409 | Conflict | Resource cannot be deleted (safety check) |
| 429 | Too Many Requests | Rate limit exceeded; Retry-After states the wait time in seconds |
| 500 | Internal Server Error | Server error |
Error Response Format
HTTP/1.1 401 Unauthorized
X-XoPort-Deny-Reason: deny_token_required
Content-Type: application/json; charset=utf-8
{
"success": false,
"api_version": "2.122.13",
"error": {
"code": "UNAUTHORIZED",
"reason": "deny_token_required",
"message": "Authentication required. JSON/REST routes always require an OAuth2 token and check its scopes; the XML_PORT_IP_FILTER whitelist does not authorize them (changed in API 2.119.0). Obtain a token via POST /oauth/token (client_credentials grant)."
}
}Errors involving query parameters also include details[] with param and message for each error (example on the Export API page). Evaluate error.code, not the message text.
Starting with v2.119.0, when a request is rejected, the API specifies the reason in the reason field; for a 401 error, it also includes the reason in the X-XoPort-Deny-Reason header: for example, deny_token_required (401, request without a token) or deny_ip_not_listed (403, address not in XOPORT_REST_IP_LIST; only in the body).
Common Error Codes
| Code | HTTP | Description |
|---|---|---|
INVALID_FILTER_VALUE | 400 | A query parameter carries an unusable value or a list value (?status[]=1); details[] names param and message for each error. Since v2.122.10 on every JSON endpoint, including Import and Delete; nothing is then read, written or deleted |
INVALID_PAGINATION | 400 | limit, offset, page, sort, or order are unusable (details[] as above) |
INVALID_RANGE | 400 | Unusable path form or path segment: new:{datum} on an endpoint other than customers and orders (since v2.122.10), and since v2.122.12 in the JSON export also a segment that is neither an integer nor a range nor a subroute (/product/42x, /order/42.0, /contracts/10/20). The message names the segment |
FILTER_NOT_APPLICABLE | 400 | Filter on a single-record request or ID range where it has no effect; since v2.122.13 also ?categories_id= together with an ID or range in the path of the category product list (/categories/5/productlist?categories_id=7, /categories/5:10/productlist?categories_id=5). Only the same value as the single path ID remains allowed |
INVALID_STATUS | 400 | status_id on the status endpoint PUT /Import/JSON/contracts/{id}/status is not a contract status of the shop or not an integer. Since v2.122.13, error.valid_status_ids lists the valid IDs; up to v2.122.12, the endpoint checked against the order statuses |
UNKNOWN_FILTER | 200 or 400 | Unknown parameter name on the export: warning in warnings[], HTTP 400 with ?_strict=true |
MISSING_ID | 400 | Delete without an ID in the path; the ID must be included in the path, for example DELETE /…/categories/99 |
UNAUTHORIZED | 401 | Missing, invalid or expired access token, or the client is disabled; error.reason and the header X-XoPort-Deny-Reason specify the reason |
IP_NOT_ALLOWED | 403 | Request from an address not listed in XOPORT_REST_IP_LIST (since v2.119.0) |
INSUFFICIENT_PERMISSIONS | 403 | The token lacks the endpoint’s scope (message: “Required scope: …”) |
NOT_FOUND | 404 | Resource not found: single-record request without a match at /product/{id} and /products/{id} as well as /order_status/{id} (since v2.122.10), plus media, ticket attachments, documents and DELETE on an unknown ID. The other single-record requests respond with HTTP 200 and an empty data. An incorrect base URL also results in 404 NOT_FOUND |
HAS_SUBCATEGORIES | 409 | Category has subcategories |
HAS_PRODUCTS | 409 | Category contains products |
HAS_NEWS | 409 | News category contains articles |
HAS_ORDERS | 409 | Customer has orders |
RATE_LIMIT_EXCEEDED | 429 | Client’s rate limit exceeded; since v2.122.11 with error.retry_after |
The token endpoint POST /oauth/token responds in the OAuth2 format (error, error_description), not with these codes: see “Errors at the token endpoint” below.
A scope change on the client takes effect only with the next token: A token that has already been issued retains the scopes it had at the time of issuance until it expires, i.e., for up to one hour. You can withdraw access immediately in the backend with “Revoke Tokens” in the client’s action menu (as of shop 4.9.168); in older shops, deactivate and reactivate the client; the secret remains the same. A changed rate limit, by contrast, takes effect immediately.
The client’s usage log does not include export aborts with HTTP 400 before a query runs (filter, pagination and path errors), nor the 429 response. If you look for an error there, you will therefore not find these cases; the 400 responses still count toward the rate limit.
- Unusable values and list values of query parameters result in HTTP 400
INVALID_FILTER_VALUEon every JSON endpoint (on Import and Delete “… Nothing was written” or “… Nothing was deleted”). Up to v2.122.9, such a filter was usually dropped silently, and the response came unfiltered with HTTP 200. Rules and examples: Export API. GET /product/{id}and/products/{id}for a deleted or never assigned product result in HTTP 404NOT_FOUND(message “Product with id=… not found”) instead of HTTP 200 with an emptydata. If you abort on responses outside 2xx, you now get this case as an error.new:{datum}on an endpoint other than customers and orders results in HTTP 400INVALID_RANGE.
- An unusable path segment in the JSON export results in HTTP 400
INVALID_RANGE. Up to v2.122.11, the paginated list came back under HTTP 200, and forms such as1e3,4.2, or+5counted as an ID. Rules and examples: Export API, section “Path segment”. - Leading or trailing whitespace in a query value or an ID in the path no longer counts. Some requests that previously got past the value validation and silently behaved differently therefore now return an error or a different result, e.g.
?_strict=true%0Awith an unknown filter now returns HTTP 400.
- Contract status: The status endpoint
PUT /Import/JSON/contracts/{id}/statuschecksstatus_idagainst the shop’s contract statuses instead of the order statuses. An ID that exists only as an order status now results in HTTP 400INVALID_STATUS; a contract status that does not also exist as an order status is written. Read the IDs fromcontracts_statuses[]ofGET /Export/JSON/contractsor fromerror.valid_status_ids, never from/order_statuses. The contract import reports an invalid ID (for example an ID that exists only as an order status) with the warningCONTRACT_STATUS_UNKNOWN: the record is written, the status is not. - Category product list:
?categories_id=together with an ID or range in the path results in HTTP 400FILTER_NOT_APPLICABLE, except with the same value as the single path ID. Up to v2.122.12, the category of the parameter came back under HTTP 200. Send the category either in the path or as a parameter.
Rate limit exceeded (429)
Since v2.122.11 Retry-After states the seconds until a request is accepted again (1 to 3600), and the body carries the same number as error.retry_after. In addition, there are the headers X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset, which every response to a client with a rate limit carries (see OAuth2 Clients).
HTTP/1.1 429 Too Many Requests
Retry-After: 1260
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1792327500
Content-Type: application/json; charset=utf-8
{
"success": false,
"api_version": "2.122.13",
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit of 5000 requests per 3600 s (sliding window) exceeded.",
"retry_after": 1260
}
}Retry-Afteris what counts for the next attempt. In most cases, “now +Retry-After” is exactlyX-RateLimit-Reset; if a client’s limit has just been lowered,Retry-Afterpoints to a later time.- Up to v2.122.10 (shop up to 4.9.170),
Retry-Afterwas always 3600; there was noretry_afterfield, and the message read “Rate limit of 5000 requests/hour exceeded.” Evaluateerror.code, never the message text. - A rejected request (429) does not count. Distribute many requests evenly over the hour and slow down as soon as
X-RateLimit-Remainingreaches 0, rather than waiting for the 429.
Errors at the token endpoint
POST /oauth/token responds in the OAuth2 format with error and error_description. Since v2.122.11 a requested scope that cannot be read (invalid UTF-8 or a list such as scope[]=…) results in HTTP 400 invalid_scope; no token is issued. client_id or client_secret as a list results in HTTP 400 invalid_request. At the token endpoint’s own limit, Retry-After states the wait time (1 to 300 seconds). All errors of the token endpoint are listed under OAuth2 Clients.
Best Practice
Always check the success field in the response and implement retry logic for 429 and 5xx errors.