Dev
Overview

Error Handling

Understand error responses and HTTP status codes from the CloudCart REST JSON:API.

The API uses standard HTTP status codes and returns errors in JSON:API format.

Status Codes

CodeMeaningDescription
200OKSuccessful GET, PATCH
201CreatedSuccessful POST
204No ContentSuccessful DELETE
400Bad RequestMalformed JSON or invalid query parameters
401UnauthorizedMissing or invalid API key
404Not FoundResource does not exist
422Unprocessable EntityValidation failed
429Too Many RequestsRate limit exceeded
500Server ErrorSomething went wrong on our end

Error Format

All errors return a top-level errors array. Each object contains:

FieldDescription
statusHTTP status code as a string
titleShort summary
detailSpecific explanation
source.pointerJSON pointer to the offending field
{
  "errors": [{
    "status": "422",
    "detail": "The name must be at least 2 characters.",
    "source": { "pointer": "/data/attributes/name" }
  }]
}

Common Examples

401 -- Invalid API Key

{
  "errors": [{
    "status": "401",
    "title": "Unauthenticated",
    "detail": "Invalid or missing API key. Provide a valid key in the X-CloudCart-ApiKey header."
  }]
}

404 -- Resource Not Found

{
  "errors": [{
    "status": "404",
    "title": "Not Found",
    "detail": "No product found with id '999999'."
  }]
}

422 -- Validation Errors

Multiple errors can be returned at once:

{
  "errors": [
    {
      "status": "422",
      "detail": "The name must be at least 2 characters.",
      "source": { "pointer": "/data/attributes/name" }
    },
    {
      "status": "422",
      "detail": "The category field is required.",
      "source": { "pointer": "/data/relationships/category" }
    }
  ]
}

429 -- Rate Limited

{
  "error": "Too Many Requests",
  "message": "API rate limit exceeded. Please wait and retry later.",
  "retry_after": 60
}

See Rate Limits for full details on rate limit headers, per-plan limits, and best practices.


Handling Errors

Use source.pointer to map errors back to specific fields in your UI or logging.

  • Parse the full errors array. Multiple validation errors can arrive in one response.
  • Retry 429 and 5xx only. Use the Retry-After header for rate limits. For server errors, use exponential backoff.
  • Do not retry 400, 401, 404, or 422. Fix the request first -- retrying will produce the same result.
  • Log error bodies. The detail field typically contains the exact information needed to diagnose the issue.

On this page