HTTP 204 No Content

The request succeeded and there is deliberately no body. Most commonly the answer to a successful DELETE.

Defined in RFC 9110 §15.3.5 — 204 No Content · MDN reference

Where you meet HTTP 204 in production

Successful DELETEs, PUTs that do not echo the updated resource back, endpoints whose whole job is a side effect, and preference or settings writes where the client already knows the new state it just sent.

Why you would test it

Clients that call response.json() unconditionally throw here. Testing a 204 path is how you find out that your error handling has a hole in it.

What your client should do about a 204

Do not call .json() unconditionally. Fetch-based clients throw on an empty body, and the throw surfaces as a network-looking error a long way from its cause. Branch on the status, or check content-length, before parsing.

204 versus the codes it gets confused with

Endpoints that return 204

23 endpoints in this playground answer with 204. Every one is free, needs no signup, and can be called from the browser or with curl.

Questions about HTTP 204

Can a 204 have a body?
No. The specification forbids it, and intermediaries may drop it.
Is DELETE supposed to return 204?
204 is the common choice. 200 with a body and 202 for a queued delete are both legitimate too.

Other success codes

All HTTP status codes · All 39 mock REST APIs · Getting started guide

Last updated