Skip to main content

Error format

Every error has the same shape:
string
A stable, machine-readable code. Rely on this.
string
A human-readable message in English. It can change, so do not parse it.
string
The query parameter that was rejected. Only present on some invalid_request errors.

Error codes

Messages of the fixed errors: The API never answers 403. An ID of another workspace looks the same as an unknown ID.

Order of checks

The API checks a GET request to one of the four endpoints in this order:
  1. The limit per IP address. If it is reached: 429.
  2. The length of the query string. If it is longer than 1024 characters: 400.
  3. The Authorization header. If it is missing or the key has the wrong form: 401. The API does not look up the key yet.
  4. The limit per key. If it is reached: 429.
  5. The query parameters of the endpoint. If one is invalid: 400.
  6. The key itself. If it is unknown, revoked or expired: 401.
  7. The resource. If the ID is unknown: 404.
This has these effects:
  • A 400 for an invalid query parameter says nothing about whether your key is valid.
  • A 401 comes before a 404. A request with an invalid key never learns whether an ID exists.
  • An ID with the wrong form is treated like an unknown ID. With a valid key it returns 404, with an invalid key it returns 401.
  • A path that does not exist returns 404 without any of these checks. It needs no key.
  • A 405 and the answer to OPTIONS are also sent without any of these checks.

Methods

These rules apply to the four endpoints: The API sets no CORS headers, also not on the answer to OPTIONS. A browser blocks calls from another origin, so call the API from a server. A path that does not exist returns 404 with not_found for every one of these methods.

Server errors

A 500 with internal_error means the request failed on the HocDoc side. The response contains no details. Retry the request after a short wait. A 500 carries the RateLimit-* headers of the key.

Handling errors in code

With a key of the right form this prints 400. Read error.code from the body to decide what to do: