DELETE request method


目录

The DELETE HTTP method asks the server to delete a specified resource.

Requests using DELETE should only be used to delete data and shouldn't contain a body.

[!NOTE] The semantics of sending a message body in DELETE requests are undefined. Some servers may reject the request with a 4XX client error response.

Request has body No
Successful response has body May
{{Glossary("Safe/HTTP", "Safe")}} No
{{Glossary("Idempotent")}} Yes
{{Glossary("Cacheable")}} No
Allowed in HTML forms No

Syntax

DELETE <request-target>["?"<query>] HTTP/1.1

Examples

Successfully deleting a resource

The following request asks the server to delete the resource file.html:

DELETE /file.html HTTP/1.1
Host: example.com

If the request is successful, there are several possible successful response status codes. A {{HTTPStatus("204", "204 No Content")}} response means the request was successful and no additional information needs to be sent back to the client:

HTTP/1.1 204 No Content
Date: Wed, 04 Sep 2024 10:16:04 GMT

A {{HTTPStatus("200", "200 OK")}} response means the request was successful and the response body includes a representation describing the outcome:

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date: Fri, 21 Jun 2024 14:18:33 GMT
Content-Length: 1234

<html lang="en-US">
  <body>
    <h1>File "file.html" deleted.</h1>
  </body>
</html>

A {{HTTPStatus("202", "202 Accepted")}} response means the request has been accepted and will probably succeed, but the resource has not yet been deleted by the server.

HTTP/1.1 202 Accepted
Date: Wed, 26 Jun 2024 12:00:00 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 1234

<html lang="en-US">
  <body>
    <h1>Deletion of "file.html" accepted.</h1>
    <p>See <a href="http://example.com/tasks/123/status">the status monitor</a> for details.</p>
  </body>
</html>

Specifications

{{Specifications}}

Browser compatibility

The browser doesn't use the DELETE method for user-initiated actions, so "browser compatibility" doesn't apply. Developers can set this request method using fetch().

See also


版本号 #2
由 壳壳虫 创建于 2026-10-31 03:27:53 UTC
由 壳壳虫 更新于 2026-10-31 03:27:53 UTC