HTTP 2xx success status codes
The 2xx class signals that the client’s request was received, understood, and accepted. Choosing the most specific success code makes your API self-documenting: a 201 tells a client a resource was created, a 204 tells it there is nothing to render, and a 206 tells it the body is only a slice of the whole. Returning a flat 200 everywhere throws this information away. Search the reference above for any code or keyword to see its meaning, expected body, and idempotency notes.
How it works
A status code is the first machine-readable token of an HTTP response (HTTP/1.1 201 Created). The 2xx range is defined mainly by RFC 9110 with WebDAV additions in RFC 4918 and RFC 5842. The most important distinctions are: whether a body is allowed (204 and 205 forbid one), whether a Location header is expected (201), and whether the response is conditional or partial (206 answers a Range request). Idempotency is a property of the method, not the status code: GET and HEAD are always safe, PUT and DELETE are idempotent, while POST generally is not.
Tips and examples
- Return
201 CreatedwithLocation: /orders/42after creating a resource so clients can fetch it without guessing the URL. - Use
204 No ContentforDELETEand forPUTupdates where echoing the body adds no value — but never put bytes in the body. - For large downloads, support
Rangerequests and answer with206 Partial Contentplus aContent-Rangeheader so interrupted transfers can resume. 202 Acceptedis your friend for queue-backed work; return a job URL and let clients poll rather than holding the connection open.