Errors
Every error has the same shape. Branch on its code, retry what is safe to retry.
When a request fails, Sparkle answers with a 4xx or 5xx status and an
RFC 9457 problem details body. Every error has the same
fields:
{
"type": "https://api.sparkle.ai/errors/validation",
"title": "Validation Failed",
"status": 400,
"detail": "unknown moment type",
"instance": "/public/v1/conversations",
"code": "validation.conversation.moment_type_invalid",
"request_id": "req_abc123",
"timestamp": "2026-12-03T15:00:00Z",
"documentation_url": "https://docs.sparkle.ai/docs/api/errors/validation",
"errors": [
{
"field": "moment_types",
"message": "unknown moment type",
"code": "validation.conversation.moment_type_invalid",
"resource": "Conversation"
}
]
}| Field | Use it for |
|---|---|
code | Branching in your code. It's stable; the X-Error-Code header repeats it. |
status, type | The kind of error, as a number and as a link to its page below. |
detail | A sentence for whoever is debugging. It can change; don't parse it. |
errors | For a validation error, one item per field, with the field in dot notation. |
request_id | Quote it when you contact support. |
Status codes
| Status | Page | Retry? |
|---|---|---|
400 | Validation failed | No. Fix the request. |
401 | Authentication required | No. Check the X-API-Key header. |
403 | Access denied | No. The key's role or scopes don't allow it. |
404 | Not found | No. |
408 | Request timeout | Yes, with the same Idempotency-Key. |
409 | Conflict | Read the resource's state first. |
413 | Payload too large | No. Send smaller batches. |
415 | Unsupported media type | No. Send Content-Type: application/json. |
422 | Unprocessable content | No. Change what the body holds. |
429 | Rate limit exceeded | Yes, after Retry-After seconds. |
500 | Internal error | Yes, with backoff and the same Idempotency-Key. |
502 | External service error | Yes, with backoff. |
503 | Service unavailable | No. The feature isn't configured. |
Retrying safely
Every POST and PUT takes an Idempotency-Key header. When you retry a request after a timeout or
a 5xx, send the same key: if the first attempt went through, you get its response, and nothing
happens twice. A request that never reached Sparkle is processed as new.