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
| Code | Meaning | Description |
|---|---|---|
200 | OK | Successful GET, PATCH |
201 | Created | Successful POST |
204 | No Content | Successful DELETE |
400 | Bad Request | Malformed JSON or invalid query parameters |
401 | Unauthorized | Missing or invalid API key |
404 | Not Found | Resource does not exist |
422 | Unprocessable Entity | Validation failed |
429 | Too Many Requests | Rate limit exceeded |
500 | Server Error | Something went wrong on our end |
Error Format
All errors return a top-level errors array. Each object contains:
| Field | Description |
|---|---|
status | HTTP status code as a string |
title | Short summary |
detail | Specific explanation |
source.pointer | JSON 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
errorsarray. Multiple validation errors can arrive in one response. - Retry
429and5xxonly. Use theRetry-Afterheader for rate limits. For server errors, use exponential backoff. - Do not retry
400,401,404, or422. Fix the request first -- retrying will produce the same result. - Log error bodies. The
detailfield typically contains the exact information needed to diagnose the issue.