HTTP

Status Code

204 No Content

The request succeeded with no response body. Learn when to use 204 No Content for successful operations that don't return data.

3 min read beginner Try in Playground

TL;DR: 204 No Content means success with nothing to return. Common for DELETE requests and updates that need no response body.

What is 204 No Content?

A 204 No Content status code means your request was successful, but the server has nothing to send back. Think of it like successfully turning off a light switch—the action worked perfectly, but there’s no need for the switch to tell you anything more. The silence itself is the confirmation.

This status code is perfect for operations where success is all you need to know, without any additional data.

When Does This Happen?

You’ll see a 204 No Content response in these common situations:

1. Deleting Resources

DELETE /posts/123
Resource deleted successfully, nothing to return

2. Updating Without Response Data

PUT /users/456/settings
Settings saved, no need to return the data

3. Clearing Data

DELETE /cart/items
Shopping cart emptied successfully

4. Toggling States

POST /posts/123/like
Like added/removed, action confirmed

5. Saving Preferences

PATCH /users/789/preferences
Preferences updated, no response needed

Example Responses

Deleting a Blog Post:

HTTP/1.1 204 No Content
Date: Sat, 18 Jan 2026 12:00:00 GMT
Server: nginx/1.18.0

(no response body)
```text

**Updating User Settings:**

```http
HTTP/1.1 204 No Content
Cache-Control: no-cache
Last-Modified: Sat, 18 Jan 2026 12:00:00 GMT

(no response body)

Clearing Shopping Cart:

HTTP/1.1 204 No Content
Content-Length: 0

(no response body)
```text

## Real-World Example

Imagine you're building a task management app and someone marks a task as complete:

**Request:**

```http
PATCH /tasks/456 HTTP/1.1
Host: taskapp.com
Content-Type: application/json

{
  "completed": true
}

Response:

HTTP/1.1 204 No Content
Date: Sat, 18 Jan 2026 12:00:00 GMT
Cache-Control: no-cache

(no response body - the task was successfully updated)
```text

The client knows the update worked because they got 204, and they don't need the server to send back the task data since they already have it.

## 204 vs Other Success Codes

| Code    | Meaning              | When to Use                               |
| ------- | -------------------- | ----------------------------------------- |
| **204** | Success, no content  | DELETE, updates that don't return data    |
| **200** | Success with content | GET requests, operations that return data |
| **201** | Created              | POST requests that create new resources   |
| **202** | Accepted             | Long-running operations                   |

## Important Characteristics

**No Response Body:**

```http
HTTP/1.1 204 No Content
Content-Length: 0  ← Must be 0 or omitted

← Absolutely no body content allowed

Headers Still Allowed:

HTTP/1.1 204 No Content
Cache-Control: no-cache
ETag: "abc123"
Last-Modified: Sat, 18 Jan 2026 12:00:00 GMT

← Headers provide metadata about the operation
```text

## Common Mistakes

**❌ Including response body**

```http
HTTP/1.1 204 No Content
Content-Type: application/json

{"message": "Deleted"}  ← Wrong! 204 must have no body

❌ Using 204 when data is expected

GET /users/123  ← Client expects user data
HTTP/1.1 204 No Content  ← Should be 200 with user data
```text

**❌ Wrong Content-Length**

```http
HTTP/1.1 204 No Content
Content-Length: 25  ← Wrong! Should be 0 or omitted

{"status": "success"}  ← Body contradicts 204

✅ Correct usage

DELETE /posts/123
HTTP/1.1 204 No Content

← Perfect! No body, successful deletion confirmed
```text

## Best Practices

**For DELETE Operations:**

```http
DELETE /users/123/avatar
HTTP/1.1 204 No Content
Cache-Control: no-cache

For State Changes:

POST /posts/456/publish
HTTP/1.1 204 No Content
Last-Modified: Sat, 18 Jan 2026 12:00:00 GMT
```text

**For Bulk Operations:**

```http
DELETE /notifications/read
HTTP/1.1 204 No Content
X-Deleted-Count: 15  ← Metadata in headers is fine

When NOT to Use 204

Don’t use for creation:

POST /users  ← Creating new user
HTTP/1.1 201 Created  ← Return the created user data
Location: /users/123

{"id": 123, "username": "newuser"}
```text

**Don't use for data retrieval:**

```http
GET /posts/123  ← Getting post data
HTTP/1.1 200 OK  ← Return the post content

{"id": 123, "title": "My Post"}

Try It Yourself

Visit our request builder and try a DELETE operation:

  1. Set method to DELETE
  2. Set path to /posts/demo
  3. Click Send request
  4. Watch the 204 No Content response (no body!)

Frequently Asked Questions

What does 204 No Content mean?

A 204 response means the request succeeded but there is no content to return. The server processed the request successfully and intentionally returns an empty body.

When should I use 204 vs 200?

Use 204 when the operation succeeds but there is nothing meaningful to return. Use 200 when you have data to send back. 204 is common for DELETE and some PUT operations.

Can 204 have a response body?

No, 204 must not include a response body. If you need to return data, use 200 OK instead. The 204 status explicitly means no content.

What is the difference between 204 and 404?

204 means success with no content to return. 404 means the resource was not found. 204 is a success code; 404 is an error code.

Keep Learning