PATCH request method - HTTP | MDN

Syntax

http

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

Identifies the target resource of the request when combined with the information provided in the Host header. This is an absolute path (e.g., /path/to/file.html) in requests to an origin server, and an absolute URL in requests to proxies (e.g., http://www.example.com/path/to/file.html).

<query> Optional

An optional query component preceded by a question-mark ?. Often used to carry identifying information in the form of key=value pairs.

Examples

Successfully modifying a resource

Assume there is a resource on the server representing a user with a numeric ID of 123 in the following format:

json

{
  "firstName": "Example",
  "LastName": "User",
  "userId": 123,
  "signupDate": "2024-09-09T21:48:58Z",
  "status": "active",
  "registeredDevice": {
    "id": 1,
    "name": "personal",
    "manufacturer": {
      "name": "Hardware corp"
    }
  }
}

Instead of sending a JSON object to fully overwrite a resource, a PATCH modifies only specific parts of the resource. This request updates the status field:

http

PATCH /users/123 HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 27
Authorization: Bearer ABC123

{
  "status": "suspended"
}

The interpretation and authentication of the PATCH request depend on the implementation. Success can be indicated by any of the successful response status codes. In this example, a 204 No Content is used as there's no need to transmit a body with additional context about the operation. An ETag is provided so the caller can perform a conditional request in future:

http

HTTP/1.1 204 No Content
Content-Location: /users/123
ETag: "e0023aa4f"

Specifications

Specification
RFC 5789

Browser compatibility

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

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.