LOCALHOST
All pages
Start

Errors

Status codes, the error shape and what to do about each.

Every refusal is JSON with one field, detail, written for a person to read. Show it to your user as it is.

HTTP/1.1 403 Forbidden
{"detail": "This API key does not have the “sites:write” permission."}

A request body that doesn't fit the schema answers 422, and detail is a list naming each field:

{"detail": [{"type": "missing", "loc": ["body", "data", "image"], "msg": "Field required"}]}

Status codes

StatusMeansWhat to do
200 · 201Done. 201 when something new was made.Read the body.
202Accepted, and finishing in the background (a registration, a move, a renewal).Read the thing's status later, or listen to a webhook.
204Done, nothing to return (a deletion).Nothing.
400The request made sense but can't be done as asked: a bad image reference, a size we don't have, a value that won't do.Fix the input; detail says what.
401No key, a revoked or expired one, or a token the server doesn't know.Make a new key in the panel. The CLI says run lh login.
402The wallet is short for a paid call.Top up, then send the call again with the same Idempotency-Key.
403The key lacks the permission, a partner key can't act for that client, or the thing is managed by us and can't be changed.Use a key with the permission, or stop.
404Nothing by that name on this account. Also what you get for someone else's.Check the name and the account you act for.
409A conflict: the name is taken, a site by that slug exists, nothing is owed yet, a checklist item blocks publishing.Read detail; often the state has moved on.
413The body is too big.Send less.
422The body doesn't match the schema, or a DNS record isn't valid.Fix the fields detail lists.
429Too many requests, or a limit per number or per hour (one-time codes).Wait and try again.
5xxOur problem.Try again in a moment; paid calls stay safe with an Idempotency-Key.

In the command line

lh turns these into one line on stderr, prefixed lh:, and an exit code your scripts can branch on. The exit codes are on the command-line page.