204 No Content
The request succeeded and the server has deliberately sent no body.
Status
HTTP/1.1 204 No Content
Details
- Category: 2xx
- Status: Standard. Registered with IANA and defined by a current standards-track RFC.
- Specification: RFC 9110 §15.3.5
- Cacheable: Cacheable by default
- Response body: Must not be sent
- Retry: Not applicable
204 means success with nothing to say. It is the natural answer to a DELETE that removed something, a PUT that saved without returning the saved object, and to beacon or telemetry endpoints where the client does not need a payload.
The response must not include a body. A 204 carrying content is a protocol violation and different clients handle it differently, which produces confusing intermittent bugs. A browser receiving 204 for a navigation stays on the current page.
Headers
- ETag: May be sent so the client can track the new state of the resource it just modified.
Common causes
- A DELETE succeeded and there is nothing left to return.
- A PUT or PATCH saved the change and the API does not echo the resource back.
- A CORS preflight or a beacon endpoint acknowledged the request.
How to fix it
As the client
- Do not attempt to parse a body. Calling response.json() on a 204 throws in most HTTP libraries.
- Treat 204 as success. Some client code paths only special-case 200 and mistakenly report a failure.
As the server
- Send no body and no Content-Length larger than zero.
- Return 200 with a body instead if clients need the updated representation, rather than forcing a second GET.
Examples
DELETE /api/v2/order/40213 HTTP/1.1 Host: api.example.com Authorization: Bearer sk_live_example HTTP/1.1 204 No Content