HTTP 204 No Content indicates the server has successfully fulfilled the request and there is no additional content to send in the response body. The response MUST NOT include a body. This status is the correct choice for successful DELETE operations, PUT/PATCH updates where the client doesn't need the updated resource back, and actions like 'mark as read' or 'toggle favorite' where the outcome is binary. The key distinction from 200 OK with an empty body is that 204 explicitly tells the client 'there is intentionally no content here.'
Response includes the status code, standard headers (including Content-Type), and a small diagnostic JSON body describing the request and returned status.
Simulator URL (copy in the app after load — not a normal link):
https://httpstatus.com/api/status/204
Example request:
curl -i "https://httpstatus.com/api/status/204"The server successfully processed the request and is not returning any content.
On this code, Inspector focuses on semantics, headers, and correctness warnings that commonly affect clients and caches.
204 No Content (RFC 7231 Section 6.3.5) serves two purposes: confirming success and signaling that the current document view should not change. Browsers receiving 204 from a form submission stay on the current page rather than navigating. The response may include headers (like ETag for the updated resource state) but MUST NOT have a body — not even an empty JSON object. A 204 response is terminated by the first empty line after the headers, with no transfer-encoding or content-length. Important nuance: 204 from a DELETE means the resource was deleted; 204 from a PUT means the update was applied. For CORS preflight (OPTIONS), 204 is preferred over 200 because the browser doesn't need a body.
// DELETE with 204
app.delete('/api/users/:id', async (req, res) => {
const deleted = await db.deleteUser(req.params.id);
if (!deleted) return res.status(404).json({ error: 'Not found' });
res.status(204).end(); // No body
});
// CORS preflight
app.options('/api/*', (req, res) => {
res.set('Access-Control-Allow-Origin', req.headers.origin);
res.set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE');
res.set('Access-Control-Max-Age', '86400');
res.sendStatus(204);
});from fastapi import FastAPI, Response
@app.delete('/api/users/{user_id}', status_code=204)
async def delete_user(user_id: int):
deleted = await db.delete_user(user_id)
if not deleted:
raise HTTPException(404, 'User not found')
return Response(status_code=204) # explicit no body
@app.put('/api/users/{user_id}/read', status_code=204)
async def mark_read(user_id: int):
await db.mark_read(user_id)
# Return None implicitly → 204 No Content@DeleteMapping("/api/users/{id}")
public ResponseEntity<Void> deleteUser(@PathVariable Long id) {
if (!userRepo.existsById(id)) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
}
userRepo.deleteById(id);
return ResponseEntity.noContent().build(); // 204
}func deleteUserHandler(w http.ResponseWriter, r *http.Request) {
id := chi.URLParam(r, "id")
deleted, err := db.DeleteUser(id)
if err != nil {
http.Error(w, "Internal error", 500)
return
}
if !deleted {
http.Error(w, "Not found", 404)
return
}
w.WriteHeader(http.StatusNoContent) // 204, no body
}