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"
    }
  ]
}
FieldUse it for
codeBranching in your code. It's stable; the X-Error-Code header repeats it.
status, typeThe kind of error, as a number and as a link to its page below.
detailA sentence for whoever is debugging. It can change; don't parse it.
errorsFor a validation error, one item per field, with the field in dot notation.
request_idQuote it when you contact support.

Status codes

StatusPageRetry?
400Validation failedNo. Fix the request.
401Authentication requiredNo. Check the X-API-Key header.
403Access deniedNo. The key's role or scopes don't allow it.
404Not foundNo.
408Request timeoutYes, with the same Idempotency-Key.
409ConflictRead the resource's state first.
413Payload too largeNo. Send smaller batches.
415Unsupported media typeNo. Send Content-Type: application/json.
422Unprocessable contentNo. Change what the body holds.
429Rate limit exceededYes, after Retry-After seconds.
500Internal errorYes, with backoff and the same Idempotency-Key.
502External service errorYes, with backoff.
503Service unavailableNo. 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.

On this page