204 No Content
This is an educational reference page about HTTP 204 No Content. The page itself is served as 200 OK so it can be indexed as HTTP documentation.
The request succeeded and the response intentionally has no body.
Specification
Registered in the IANA HTTP Status Code Registry as No Content. Defined in RFC 9110, Section 15.3.5.
What it means
HTTP 204 No Content means the server completed the request and has no content to send back. The response ends after the headers, with no body and no trailers. Any headers in the response, such as ETag, describe the target resource after the change.
When to use it
- Return 204 for a successful DELETE when there is nothing useful to return.
- Return 204 for a PUT or PATCH when the client already has the new state. RFC 9110 lets a PUT that updates an existing resource return either 200 or 204.
- Return 204 when the client sent Prefer: return=minimal (RFC 7240) and the server honors it.
- Return 204 for save actions in editors, where the user should stay on the same page.
Headers involved
- ETag in a 204 is the entity tag of the resource after the change. After a PUT, RFC 9110 allows it only if the server stored the body exactly as sent.
- Content-Length must not be sent. RFC 9110 forbids it in 204 responses because there is no body.
- Content-Type is not needed because there is no content.
Examples
DELETE with no body
DELETE /api/sessions/current HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOi...
HTTP/1.1 204 No Content
PATCH update that returns the new ETag
PATCH /api/profile HTTP/1.1
Host: api.example.com
Content-Type: application/merge-patch+json
If-Match: "v7"
{
"timezone": "Europe/London"
}
HTTP/1.1 204 No Content
ETag: "v8"
Common mistakes
- Sending a JSON body with 204. Clients and proxies ignore it or fail to parse the next response on the connection.
- Calling response.json() on a 204 in client code. Check the status first or read the body as text.
- Using 204 for a GET that found nothing. A missing resource is 404; an empty list is 200 with [].
Developer notes
204 is heuristically cacheable, like 200. That rarely matters for DELETE or PUT, because caches do not store responses to those methods, but it can matter if you return 204 to a GET.
Questions
What does HTTP 204 No Content mean?
HTTP 204 means the request succeeded and the server intentionally sent no response body.
Should DELETE return 200 or 204?
Return 204 when there is nothing to send back. Return 200 when the response body includes something useful, such as the deleted resource or a summary.
Can a 204 response have a body?
No. A 204 response ends after the header section and cannot contain content.
See also
Header and content rules
What RFC 9110 says about a 204 response, quoted from the RFC.
- No keyword (sender; content): A 204 response ends at its header section. It has no content and no trailers. Table row
A 204 response is terminated by the end of the header section; it cannot contain content or trailers. RFC 9110 §15.3.5
The same rule is in the response obligations table and its JSON.