Status Codes
Families of codes
- 2xx — success
- 3xx — redirect
- 4xx — client error
- 5xx — server error
Everyday successes
200 OK for reads/updates, 201 Created for new resources, 204 No Content when there is no body (often after DELETE).
HTTP/1.1 201 Created
Location: /api/books/42
Everyday client errors
400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable Entity for validation failures.
Be honest
Do not return 200 with an error flag in the JSON when a standard status code fits. Clients and monitoring tools rely on the status line.
HTTP/1.1 404 Not Found
Content-Type: application/json
{"error":"book_not_found"}
Comments
One comment per signed-in account. Comments are saved with this page’s URL.