Errors

Every error the Cesura API returns has the same shape: an RFC 9457 problem details object, sent with Content-Type: application/problem+json. Your code can handle every endpoint's errors the same way.

The error body

{
  "type": "https://app.cesura.ai/problems/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "This node is outside the part of the budget tree you can use.",
  "instance": "/api/v1/organizations/ORG_ID/budget/nodes/NODE_ID",
  "code": "BUDGET_OUTSIDE_YOUR_NODE",
  "details": {},
  "request_id": "9fc443f5f67bff86f9e60307153420c4"
}
Member Meaning
type The class of failure, as a URI. Compare it as a string; it does not have to resolve.
title A short English summary of the type.
status The HTTP status code.
detail An English sentence about this occurrence. Show it in logs, not to your users, and never branch on it: its wording changes.
instance The request path.
code The machine-readable reason, in capitals. Branch on this.
details Structured context for some codes, for example the scope a key is missing. {} when there is none.
request_id The request's ID, also sent in the X-Request-ID header. Quote it when you contact support.
errors On a 422 only: the fields that failed validation, each with loc, msg, and type. The code of a 422 is VALIDATION_ERROR.

Some bodies also carry an error member. It is deprecated: do not read it.

Handle errors

  • Branch on code. Each API article lists the codes its endpoints return.
  • Expect codes you have not seen. Handle an unknown code by its status.
  • Read details only for the keys a code documents.
  • Log request_id with every failure, so support can find the request.

What to do by status

Status What it means What to do
400, 422 The request is malformed or breaks a rule. A 422 means a field failed validation and lists it in errors. A 400 means the fields are valid but break a rule, for example a parent that cannot hold the node; its type can still be validation-error, with no errors member. Fix the request. Do not retry it unchanged.
401 The key is missing, wrong, revoked, or expired. Check the key. Do not retry until it changes.
403 The key may not do this. Check the key's scopes and node.
404 The organization, node, or object does not exist for this key. Check the IDs in the path.
409 The request conflicts with what is there, for example an external ID already in use. Read the code, change the request, and send it again.
429 Too many requests. Wait for the number of seconds in the Retry-After header, then retry.
500 Something failed on Cesura's side. Retry later. If it persists, contact support with the request_id.
503 A service Cesura depends on is unavailable for a moment. Retry with a growing delay, for example after 1, 2, then 4 seconds.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.