The shape of every error response and each code the API can answer: its HTTP status, when it appears and what to do.
Every error response has the same shape:
{ "statusCode": 404, "code": "ORGANIZATION_NOT_FOUND", "message": "Organización no encontrada"}
Branch on code. A code keeps its name once published.
message is in Spanish and is for the person. Show it as it comes; do
not parse it in your program.
Some codes add fields that name what failed: scope, feature, roles,
field, maxDays, supported, reason, retryAfterSeconds, details.
The tables say which.
{ "statusCode": 400, "code": "INVALID_REQUEST", "details": [{ "field": "days", "message": "days must not be less than 1" }], "message": "La solicitud no es válida: revisa «days»."}
field is the query parameter or the body field, as a path (page,
items.0.name). It is null when the failure names none. Each row's
message comes as the validation worded it.
Yes: a 429, after Retry-After. A 409 IDEMPOTENCY_IN_PROGRESS, with
the same key.
Yes, with care: a write that ended in a timeout or a 5xx may have run or
not. If you sent it with an Idempotency-Key, retry that same request with
the same key: the API returns the first answer, with
Idempotency-Replayed: true, and does not write twice. That is why it pays
to send a fresh key with every write.
No: any other 4xx. Repeating the same request answers the same.
A write can also answer a refusal of the dashboard's own rules, with a code
of its own that is not in these tables. Handle it by its HTTP status and show
its message.