Errors & status codes
Errors & status codes
How the API signals success and failure
Every response from the Lemmy API uses the same envelope, whether the request succeeds or fails. Each response contains:
Checking for success
IsSuccess and the HTTP status code always agree, so you can rely on either:
IsSuccess: true→ HTTP200 OK, andErrorMessagesis empty.IsSuccess: false→ HTTP400 Bad Request, andErrorMessagesexplains why.
Always check IsSuccess (or the status code) before using the payload.
A successful response:
A failed response:
Status codes
Common causes of a 400
- Missing
x-page-offsetorx-page-limitheaders on aGETrequest — see Pagination. - Missing or invalid required fields in a
POSTrequest body. - Any other validation error — read
ErrorMessagesfor the specifics.
Handling errors
Check IsSuccess before trusting the payload, and surface ErrorMessages when something
goes wrong: