Skip to content

204 No Content

Description

The 204 No Content status code indicates that the server has successfully processed the request and is not returning any content in the response payload body. The server may return updated metadata in the response headers.

This status code is particularly useful in scenarios where the client only needs confirmation that the request was processed successfully, but doesn't need any content returned. Common use cases include:

  • After a successful DELETE operation
  • After a successful PUT or PATCH operation where the client already has the updated representation
  • For OPTIONS requests to provide communication options
  • For form submissions where the user should remain on the same page

The key characteristic of a 204 No Content response is that it MUST NOT include a message body, and thus no Content-Length or Content-Type header fields should be included.

Syntax

The server responds with a 204 No Content status without a response body:

HTTP/1.1 204 No Content
[Optional updated headers]

Note the absence of Content-Type and Content-Length headers, and the empty line at the end indicating no response body.

Examples

DELETE Operation Example

A client deletes a resource:

Client Request:

DELETE /users/123 HTTP/1.1
Host: api.example.com
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Server Response:

HTTP/1.1 204 No Content

Form Submission Example

A client submits a form that updates user preferences:

Client Request:

POST /preferences HTTP/1.1
Host: app.example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 56

theme=dark&notifications=weekly&language=en-US

Server Response:

HTTP/1.1 204 No Content
Set-Cookie: preferences=updated; Path=/; HttpOnly

Toggle Operation Example

A client toggles a feature on or off:

Client Request:

PUT /features/dark-mode HTTP/1.1
Host: api.example.com
Content-Type: application/json
Content-Length: 16
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

{"enabled": true}

Server Response:

HTTP/1.1 204 No Content
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"

OPTIONS Request Example

A client checks what methods are allowed on a resource:

Client Request:

OPTIONS /api/resources/123 HTTP/1.1
Host: api.example.com

Server Response:

HTTP/1.1 204 No Content
Allow: GET, PUT, DELETE, OPTIONS
Access-Control-Allow-Methods: GET, PUT, DELETE, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization

Summary

The 204 No Content status code is an efficient way to acknowledge successful request processing without transferring any response body. It reduces bandwidth usage and is particularly valuable in scenarios where the client doesn't need updated content, such as after DELETE operations, certain form submissions, or when toggling settings. By omitting the response body entirely, it provides a clear signal that no content is intended to be returned, rather than indicating an error or empty result.