DELETE

The HTTP DELETE method is a type of HTTP request that is used to delete a resource from the server.

Table of Contents

Usage

A HTTP request of this type is sent to remove the target resource from the server. Precisely what happens on the server’s side, such as whether the space is reclaimed or the resource is instead just taken offline, is under the control of the server, and how its environment has been configured.

Typically, the HTTP DELETE method is used in cases where clients are creating and modifying resources. It might be used, for example, to remove a file that was previously stored using the HTTP PUT method.

If the HTTP DELETE request is accepted then the server can respond in different ways, for example:

  • A 200 OK status code indicates that the resource has been removed and it will include a message for the client that describes the status.

  • A 204 No Content status code indicates that the resource has been removed but there is no message body to further describe the action or the status.

  • A 202 Accepted status code indicates that the DELETE request has been acknowledged and will likely be successful, although it has not yet been performed. At the client’s choosing, after some time, a subsequent HTTP GET or HEAD request can be made to the resource. A 404 Not Found or 410 Gone may be sent by the server, which will verify that it has been removed.

Example

This example is a HTTP request from the client to remove the specified resource, notes.xml, from the server. The resource is removed and the HTTP request is acknowledged without a more detailed explanation.

Request

DELETE notes.xml HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 204 No Content

Takeaway

The HTTP DELETE request method is used to instruct delete a resource from the server. It is not safe or cacheable but it is idempotent.

Last updated: August 2, 2023