# @patch

Sends the value of a publisher as the body of a `PATCH` request, to update part of a resource, and stores the response in an `ApiResult<T>` property. It takes the same arguments, options and `send(component)` handle as [@post](/docs/decorators/post); only the HTTP method differs.

## Import

<sonic-code language="typescript">
  <template>
import { patch, type ApiResult } from "@supersoniks/concorde/decorators";
import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
  </template>
</sonic-code>

## Basic usage

The body holds only the fields to change, here a gate change for flight CN 001.

<sonic-code language="typescript">
  <template>
type Flight = { flight: string; route: string; gate: string };

const gateChangeKey = new DataProviderKey&lt;Partial&lt;Flight&gt;&gt;("gateChange");

@patch(new Endpoint&lt;Flight&gt;("flights/CN001"), gateChangeKey)
@state()
payload?: ApiResult&lt;Flight&gt;;

moveToB12() {
  set(gateChangeKey, { gate: "B12" }); // sends the PATCH
}
  </template>
</sonic-code>

Triggers, the `send` method decorator and every option are described on [@post](/docs/decorators/post).

## API reference

| Argument | Type | Description |
|----------|------|-------------|
| `endpoint` | `Endpoint<T>` | Resource path and response type |
| `bodyKey` | `DataProviderKey<B>` | Publisher read as the partial body |
| `configurationKey` | `DataProviderKey<APIConfiguration>` (optional) | API configuration publisher. Default: HTML scope |
| `options` | `PatchOptions` | Same as [@post options](/docs/decorators/post) |
