204

No Content

2xx Success

ELI5

Success. The server did what you asked, but there’s nothing useful to send back in the body.

Server perspective

Use 204 when the request succeeded and the client does not need a response body.

When to use

  • Return 204 for successful deletes or updates when the representation is unnecessary
  • Use headers for metadata such as validators or caching information
  • DELETE requests that succeed without needing to return a representation
  • PUT or PATCH requests that succeed but do not need to echo updated data
  • Settings changes or control actions where headers are enough

How to respond

  • Do not send a message body
  • Include metadata headers like ETag when they help the client understand the new state

Headers to consider

  • ETag

Response body

  • Do not include a response body in a 204 response

Server-side pitfalls

  • Do not send body content with 204
  • Do not use 204 when the API contract expects a representation or action result
  • When the client needs a representation or action result in the body
  • When creating a new resource and 201 Created communicates the contract better
  • When a browser or client should reset its document view and 205 is the better signal

Examples

Deleting a user account

Request:DELETE https://api.example.test/api/users/123
Response:204 No Content

The delete succeeded and the server does not need to send anything else back.

Updating user preferences

Request:PUT https://api.example.test/api/users/123/preferences
Response:204 No Content # Headers ETag: "prefs-v2"

The update succeeded, and any useful metadata can travel in headers without a response body.

References

Related Status Codes