Products

Solutions

Resources

Search for API Security Tests

/

/

204 Status Code - No Content

204 Status Code - No Content

In this section you will learn about 204 Status Code, what is it, its components and examples.

In this section you will learn about 204 Status Code, what is it, its components and examples.

204 Status Code - No Content
204 Status Code - No Content
204 Status Code - No Content

Luke Stephens

Luke Stephens

Luke Stephens

What is HTTP Status Code 204 - No Content?

The HTTP Status Code 204 is indicative of a successful request, but unlike the 200 OK status, it signifies that there is no additional information to send back in the response body. This status code is part of the 2xx series of HTTP status codes, which confirm that a client's request was successfully received, understood, and accepted. The 204 No Content status is typically returned when the server has successfully processed the request but there is no content to send in the response body.

Understanding 204 No Content

  • Successful Request: The 204 No Content status code indicates that the server has successfully fulfilled the request and there is no additional information to send back.

HTTP/1.1 204 No Content
  • No Response Body: A distinctive characteristic of the 204 No Content status code is that the response must not include a message body, meaning it's empty.

HTTP/1.1 204 No Content

Why 204 No Content?

The 204 No Content status code serves as a refined success indicator when actions are processed successfully, but there is no relevant data to be returned to the client. It's a precise way to inform the client about the success of the operation, keeping the communication lightweight.

Benefits of 204 No Content

  • Efficient Communication: The 204 No Content status code is a mechanism for efficient communication between client and server, especially when no additional information needs to be conveyed.

  • Bandwidth Conservation: By not including any additional data in the response body, the 204 No Content status code helps in conserving bandwidth, which is beneficial in network-constrained environments.

How does 204 No Content Work?

  1. Client Sends a Request:

    The client might send a request to delete a resource or to update a resource where the server does not need to send back any data.

DELETE /api/users/123 HTTP/1.1
Host: www.example.com
  1. Server Processes the Request:

    The server processes the request, performing the necessary operations to fulfill the request.

  2. Server Sends a Response:

    The server sends a 204 No Content response to the client, indicating the successful processing of the request without any additional data.

HTTP/1.1 204 No Content

Components of 204 No Content Response

A 204 No Content response primarily consists of:

  • Status Line: The first line of the response, indicating the 204 No Content status code.

HTTP/1.1 204 No Content
  • Headers: Even though there's no message body, headers can still be included in the response to provide metadata about the request.

Example of 204 No Content

Deleting a Resource:

DELETE /api/users/123 HTTP/1.1
Host: www.example.com

Response:

HTTP/1.1 204 No Content

In this example, the client sends a request to delete a user resource. The server processes the request, deletes the user, and returns a 204 No Content status code to indicate the successful deletion of the resource.

Conclusion

The 204 No Content status code is a meaningful part of the HTTP status code spectrum, signifying the successful processing of a request without returning any content. Understanding the 204 No Content status code is important for developers and anyone working with APIs or web services, as it provides a nuanced way of confirming the success of an operation without the need for additional data transmission.

On this page

Protect your APIs from attacks now

Protect your APIs from attacks now

Protect your APIs from attacks now

Explore more from Akto

Blog

Be updated about everything related to API Security, new API vulnerabilities, industry news and product updates.

Events

Browse and register for upcoming sessions or catch up on what you missed with exclusive recordings

CVE Database

Find out everything about latest API CVE in popular products

Test Library

Discover and find tests from Akto's 100+ API Security test library. Choose your template or add a new template to start your API Security testing.

Documentation

Check out Akto's product documentation for all information related to features and how to use them.