Errors
Error format, codes to test, order of checks and retries.
Error format#
An error returns an HTTP status and a JSON body with message (readable text, translated according to the language of the token creator’s profile) and, most of the time, code (a stable identifier):
{
"message": "Invalid, expired or revoked API token.",
"code": "invalid_token"
}Some errors have no code: a 403 caused by the role, a 404, an ordinary validation (422 with errors). In those cases, rely on the status.
Error codes#
| Status | Code | When |
|---|---|---|
| 401 | invalid_token | Token missing, malformed, unknown, expired or revoked, or creator no longer in the workspace. |
| 402 | plan_required, quota_reached, plan_restricted | The plan does not include the API or the requested feature, a quota is reached, or the resource is read-only. |
| 403 | insufficient_scope | Missing scope (the body gives required_scope). |
| 403 | none | Creator’s role is insufficient (a viewer writing, for example). |
| 403 | staff_disabled | Webhook switched off by Hyllo staff. |
| 404 | none | Unknown resource, or one from another workspace. |
| 405 | none | Deleting a QR code or a link page: it does not exist in the API. |
| 409 | idempotency_in_progress | A request with the same Idempotency-Key is still running. |
| 422 | none, with errors | Validation of the body or parameters. |
| 422 | field_not_available | Field that does not exist in the public API (folders). |
| 422 | idempotency_key_mismatch | Idempotency-Key reused with a different request. |
| 422 | too_many_webhooks, webhook_url_not_public | Webhook: limit reached, or non-public address. |
| 422 | logo_too_large, render_refused, export_not_available | QR code export that cannot be drawn. |
| 429 | rate_limited | Rate limit reached (Retry-After gives the wait), including a route’s own limit. |
| 503 | renderer_unavailable | QR code export: rendering engine unavailable, try again. |
Order of checks#
Checks always apply in the same order; the first one that fails gives the response:
- 401: the token is valid.
- 402: the workspace’s plan includes the API.
- 403
insufficient_scope: the token carries the route’s scope. - 404: the resource exists in the token’s workspace.
- 422: the body and parameters are valid.
Consequences: a token without the required scope gets 403, even on an identifier that does not exist (never 404); a resource’s existence is therefore only revealed to a token that has the scope. Validation comes last: fixing a 422 assumes everything else passes. A route’s own limits count after the 402 and the 403; the general budget per token and per workspace counts before, and every response, refusals included, carries X-RateLimit-*.
Validation errors#
A failed validation answers 422 with errors, a list of messages per field:
{
"message": "The url field is required.",
"errors": {
"url": [
"The url field is required."
]
}
}A field that does not exist in the public API (folders) answers 422 with code: field_not_available and one errors entry per refused field. An Idempotency-Key reused with a different request answers 422 idempotency_key_mismatch, with no errors.
Messages are translated: display them if needed, but do not parse them.
Retrying requests#
- 429: wait
Retry-Afterseconds, then replay. See Best practices. - 5xx and network errors: replay with a growing wait and a bounded number of attempts. For a creation, keep the same
Idempotency-Key: see Idempotency. - 409
idempotency_in_progress: wait a moment, then replay. - Other 4xx: do not replay as is, the same request gives the same error. Fix the token, the scope, the plan or the body.
