Error Handling & HTTP Status Codes

HTTP · Status Codes · Error Handling

Error Handling

The API uses standard HTTP status codes and structured JSON error messages for consistent error handling.


HTTP Status Codes

CodeStatusDescription
200OKRequest successful (GET, POST, DELETE)
201CreatedNew resource created (POST)
400Bad RequestInvalid request body or missing parameters
401UnauthorizedNo token or invalid token
403ForbiddenToken does not have the required scopes
404Not FoundResource not found
409ConflictResource cannot be deleted (safety check)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Error Response Format

{
  "success": false,
  "error": {
    "code": "INVALID_TOKEN",
    "message": "The access token is invalid or expired"
  }
}

Starting with v2.119.0, when a request is rejected, the API also specifies the reason in the ` reason ` field and 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`).

Common Error Codes

CodeHTTPDescription
INVALID_GRANT_TYPE400grant_type must be "client_credentials"
INVALID_CLIENT401Invalid client ID or secret
INVALID_TOKEN401Token is invalid or expired
MISSING_TOKEN401No Authorization header
IP_NOT_ALLOWED403Request from an address not listed in XOPORT_REST_IP_LIST (since v2.119.0)
INSUFFICIENT_SCOPE403Token does not have the required scope
NOT_FOUND404Resource not found
HAS_SUBCATEGORIES409Category has subcategories
HAS_PRODUCTS409Category contains products
HAS_ARTICLES409News category contains articles
HAS_ORDERS409Customer has orders
RATE_LIMIT_EXCEEDED429Too many requests

Best Practice

Always check the " success" field in the response and implement retry logic for 429 and 5xx errors.