DELETE

Removing a resource at a known URI requires the HTTP DELETE method, which instructs the server to discard the target resource.

Usage

A DELETE request instructs the server to remove the target resource. The server determines what removal means in practice: the resource might be permanently erased, archived, or marked as inactive.

REST APIs rely heavily on DELETE to represent resource destruction. An API endpoint like DELETE /api/users/123 signals a clear intent to remove the user record identified by 123. This maps directly to the POST/PUT/GET/DELETE pattern for create, update, read, and destroy operations.

HTML forms send only GET and POST requests. JavaScript APIs such as fetch and XMLHttpRequest support DELETE natively. Some frameworks use POST with a _method=DELETE parameter as a workaround.

A successful deletion answers 200 OK, 202 Accepted, or 204 No Content, depending on whether the response carries a body and whether the removal has completed. The response status codes section below covers each outcome.

A hard delete permanently removes the resource. Subsequent GET requests return 404 or 410 Gone. A soft delete marks the resource as inactive without removing the underlying data. The resource remains retrievable through an admin API or with a query parameter. 410 communicates permanent removal, while 404 is appropriate when the resource no longer exists at the URI. The choice between the two is covered under 404 vs 410.

A DELETE request is idempotent. Sending the same request multiple times produces the same server state as sending the request once. The first request removes the resource, and subsequent requests have no additional effect. The response codes might differ, though: the first request returns 200 OK or 204 No Content, while later requests return 404 Not Found or 410 Gone.

Conditional DELETE

A DELETE carrying If-Match with the ETag the client last saw removes the resource only when that version is still current. When another client changed the resource in the meantime, the server answers 412 Precondition Failed and leaves the resource in place, which guards against deleting a version the client never saw.

Properties

Property Value
Safe No
Idempotent Yes
Cacheable No

Example

Deleting a resource

A client requests removal of a specific file. The server removes the file and responds with 204 No Content to confirm the action without a message body.

Request

DELETE /uploads/report.pdf HTTP/1.1
Host: api.example.re

Response

HTTP/1.1 204 No Content

REST API deletion with confirmation

A REST API returns 200 OK with a JSON body confirming the deletion and identifying the removed resource.

Request

DELETE /api/users/123 HTTP/1.1
Host: api.example.re
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...

Response

HTTP/1.1 200 OK
Content-Type: application/json

{"deleted": true, "id": 123}

The Authorization header carries a bearer token because most APIs require Authentication before allowing destructive operations.

CORS

Cross-origin DELETE requests require a CORS preflight. The browser sends an OPTIONS request first to confirm the server allows DELETE on the target resource, unless the browser holds a cached preflight result for the method from an earlier Access-Control-Max-Age.

Request body

A DELETE request carries a body only in edge cases: the spec advises against content unless the origin server has signaled support, and the semantics stay undefined. Some intermediaries reject DELETE requests with bodies due to request smuggling risks. Most APIs do not use a request body for DELETE. When a body is needed, such as for bulk deletion, the server defines the expected format.

Caches and DELETE

A successful DELETE passing through a cache invalidates every stored response for the target URI. The "Cacheable: No" property means DELETE responses themselves never get stored, and the method still interacts with caching by clearing what GET left behind.

Response status codes

204 No Content is the most common response for straightforward deletions where no body is needed. 200 OK is appropriate when the server returns the deleted resource or a confirmation message in the response body.

202 Accepted signals that the deletion is queued or asynchronous. The response typically includes a Location header or body pointing to a status endpoint where the client checks progress.

Resources not accepting DELETE answer 405 Method Not Allowed with an Allow header naming the supported methods. An authenticated client lacking permission to delete draws 403 Forbidden instead, and a failed If-Match precondition draws 412 Precondition Failed.

Later requests to a deleted resource return 404 Not Found or 410 Gone, as described under Usage.

See also

Last updated: November 3, 2026