# Patch

<mark style="color:green;">`PATCH`</mark> `{base}/fhir/{type}`

The patch operation allows you to update specific parts of a resource by sending a declarative description of the changes to be made. This method enables targeted updates without modifying the entire resource.\
\
You can specify a <mark style="color:green;">`PATCH`</mark> method by the `content-type` header with either:

* If the payload is an array - `application/json-patch+json`
* If the payload is an object  `application/merge-patch+json`

Below is an example of how to use a <mark style="color:green;">`PATCH`</mark> request to update specific data in a resource. A complete list of resources can be found by visiting the resource specifications [here](https://www.hl7.org/fhir/resourcelist.html).&#x20;

**Request**\ <mark style="color:green;">`PATCH`</mark> `{base}/fhir/Patient/{id}`

**Headers**

| Name          | Value                         |
| ------------- | ----------------------------- |
| Content-Type  | `application/json-patch+json` |
| Authorization | `Bearer <token>`              |

**Body**

{% tabs %}
{% tab title="JSON: application/json-patch+json" %}

```json
[
  {
    "op": "replace",
    "path": "/name/0/family",
    "value": "Bernard"
  }
]
```

{% endtab %}

{% tab title="JSON: application/merge-patch+json" %}

```json
{
  "active": false
}
```

{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "name": [
    {
      "family": "Bernard"
    }
  ],
  "id": "20304050",
  "resourceType": "Patient",
  "meta": {
    "lastUpdated": "2024-07-16T12:10:47.885463Z",
    "versionId": "540524",
    "extension": [
      {
        "url": "ex:createdAt",
        "valueInstant": "2024-07-16T10:08:33.753699Z"
      }
    ]
  }
  "active": false
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Bad Request"
}
```

{% endtab %}

{% tab title="401" %}

```json
{
  "error": "Unauthorized"
}
```

{% endtab %}

{% tab title="409" %}

```json
{
  "error": "Conflict"
}
```

{% endtab %}

{% tab title="422" %}

```json
{
  "error": "Unprocessable"
}
```

{% endtab %}
{% endtabs %}
