# Set or remove custom headers

PATCH /v1/webhooks/{webhook_id}/headers

Source: https://cherami.to/docs/api/webhooks/update-webhook-headers



{/* Generated from apps/web/openapi. Edit the contract, not this file. */}

`PATCH /v1/webhooks/{webhook_id}/headers`

Requires an [API key](https://cherami.to/docs/api#authentication): `Authorization: Bearer YOUR_CREDENTIAL`.

Sets and removes custom headers sent with every delivery, in one request; headers you don't name stay as they are. Values are sent as written and never shown again. Use a header for a shared token your receiver checks alongside the signature, or for routing. Repeating the same change is safe.

## Parameters [#parameters]

| Parameter    | Location | Required | Type   | Meaning                                  |
| ------------ | -------- | -------- | ------ | ---------------------------------------- |
| `webhook_id` | path     | Yes      | string | Cherami resource ID returned by the API. |

## Request body [#request-body]

JSON object, at most 4 KiB in total.

### Schema: UpdateWebhookHeaders [#schema-updatewebhookheaders]

Set and remove in one request; a name can't be in both. Other headers stay as they are.

| Field    | Required | Type            | Meaning and constraints                                                                                                                                           |
| -------- | -------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `set`    | No       | object          | Header name to value. Names are HTTP tokens, stored in lowercase; reserved names (svix-*, webhook-*, host, content-type, content-length, user-agent) are refused. |
| `remove` | No       | array of string | `maxItems`: `20`                                                                                                                                                  |

Unknown fields are rejected.

At least 1 field must be supplied.

## curl example [#curl-example]

Supply `CHERAMI_API_KEY` privately.

Save the payload as `request.json`, replacing the example values.

```json
{
  "set": {
    "x-integration-token": "REPLACE_WITH_YOUR_VALUE"
  },
  "remove": [
    "x-old-header"
  ]
}
```

```sh
curl --silent --show-error --include --request PATCH \
  "https://cherami.to/v1/webhooks/WEBHOOK_ID/headers" \
  --header "Authorization: Bearer $CHERAMI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data-binary @request.json
```

## Responses [#responses]

### HTTP 200 [#http-200]

Success.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[WebhookHeaders](#schema-webhookheaders)

```json
{
  "id": "11111111-1111-4111-8111-111111111111",
  "header_names": []
}
```

### HTTP 400 [#http-400]

`invalid_json`: Send a valid UTF-8 JSON object, not an array or scalar.

`invalid_webhook_headers`: Correct the header change the message names. Names are HTTP tokens of at most 128 characters, other than `Host`, `Content-Type`, `Content-Length`, `User-Agent` and names starting `svix-` or `webhook-`; values are printable and at most 1024 characters; `set` and `remove` take at most 20 entries each.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 401 [#http-401]

`unauthorized`: Send a valid API key as `Authorization: Bearer <key>`. If the key stopped working, get a new one through [recovery](https://cherami.to/docs/guides/recovery).

* `X-Request-ID`: Identifies this request; include it when reporting a problem.
* `WWW-Authenticate`: `"Bearer"`

Content type: `application/json`.

[Error](#schema-error)

### HTTP 404 [#http-404]

`not_found`: The resource does not exist or does not belong to this account. A reply or forward source must also be in the sending inbox.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 409 [#http-409]

`webhook_operation_in_progress`: Another change to this webhook is in progress. Retry in a minute.

`webhook_endpoint_missing`: This webhook no longer receives events and cannot be changed. Delete it and add it again; the new webhook has a new ID and signing secret.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 413 [#http-413]

`body_too_large`: Reduce the JSON request to the operation's body limit.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 415 [#http-415]

`unsupported_media_type`: Send `Content-Type: application/json`.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

### HTTP 503 [#http-503]

`webhook_provider_unavailable`: The request could not be completed, and nothing changed. Retry later.

`webhook_headers_uncertain`: The header change was not confirmed. Apply the same change again; repeating it is safe.

`webhook_headers_unavailable`: Header names could not be read. When `error.details.applied` is true the change was made; list the headers again.

`webhooks_unavailable`: Webhook management failed. If it was a change, it may have been applied: list or read the webhooks before repeating it.

* `X-Request-ID`: Identifies this request; include it when reporting a problem.

Content type: `application/json`.

[Error](#schema-error)

## Schema: WebhookHeaders [#schema-webhookheaders]

| Field          | Required | Type            | Meaning and constraints |
| -------------- | -------- | --------------- | ----------------------- |
| `id`           | Yes      | string          | Cherami resource ID.    |
| `header_names` | Yes      | array of string |                         |

## Schema: Error [#schema-error]

| Field   | Required | Type   | Meaning and constraints |
| ------- | -------- | ------ | ----------------------- |
| `error` | Yes      | object |                         |

### `error` fields [#error-fields]

| Field     | Required | Type   | Meaning and constraints                                               |
| --------- | -------- | ------ | --------------------------------------------------------------------- |
| `code`    | Yes      | string | Code to handle. Handle a code you don't recognize by its HTTP status. |
| `message` | Yes      | string | Explanation of this case; its wording can change.                     |

[Errors, limits and pagination](https://cherami.to/docs/api/errors) · [Download OpenAPI 3.1](https://cherami.to/openapi.json)
