# Set a check's escalation policy

`PATCH /api/v1/checks/{checkId}`

Changes only which escalation policy the check's incidents follow: its own, or the project's with `null`. An incident that is already open keeps the policy it started with. Needs the editor role; a token needs `alerts:write`.

Sign-in: a dashboard session, an API token with `alerts:write` or the `monitorly` CLI's sign-in with `alerts:write`.

Section: Checks. Operation id in openapi.json: `set_check_escalation_policy`.

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `checkId` | path | yes | string (uuid) | The check's id. |

## Request body

Required: yes.

`application/json`: CheckPatch

| Field | Type | Required | Description |
|---|---|---|---|
| `escalationPolicyId` | string (uuid) \| null | yes | A policy of the workspace, or null for the project's. |

## Responses

Errors are `application/problem+json` (`Problem`); branch on `type`.

### 200

The check.

`application/json`: CheckView

| Field | Type | Required | Description |
|---|---|---|---|
| `createdAt` | string | yes |  |
| `downAfter` | integer | yes |  |
| `epoch` | integer | yes | Bumped whenever a change alters the check's meaning; results of other epochs never vote. |
| `escalationPolicyId` | string (uuid) \| null | no | The check's own escalation policy; null: the project's (`ProjectView.escalationPolicyId`). |
| `id` | string (uuid) | yes |  |
| `intervalSecs` | integer | yes |  |
| `kind` | KindDto | yes |  |
| `managedBy` | ManagedBy | no | `config` when a config apply manages the check (only those are pruned), `ui` otherwise. Always sent; optional in the schema because it was added after the first clients. |
| `muted` | boolean | yes |  |
| `name` | string | yes |  |
| `nodes` | array of string (uuid) | yes |  |
| `paused` | boolean | yes |  |
| `projectId` | string (uuid) | yes |  |
| `quorum` | QuorumDto | yes |  |
| `ref` | string \| null | no | The check's key in a config file (`monitorly.yaml`); null until a config apply creates or adopts it. Always sent; optional in the schema because it was added after the first clients. |
| `timeoutMs` | integer | yes |  |
| `upAfter` | integer | yes |  |
| `updatedAt` | string | yes |  |

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `auth.credentials_conflict`: the request carries both a session cookie and a token

### 401

Unauthorized.

- `auth.unauthenticated`, `auth.session_expired`: no session, or it ended
- `token.invalid`: the token is malformed, unknown, revoked or expired, or its creator left the workspace

### 403

Forbidden.

- `auth.forbidden`: your role is too low for this
- `token.scope_missing`: the token lacks the scope this needs; `detail` names it
- `request.origin_mismatch`, `request.header_required`: a changing request with a session comes from another site or lacks `X-Monitorly-Request: 1`

### 404

Not Found.

- `request.not_found`: it does not exist, or you cannot see it

### 413

Payload Too Large.

- `request.too_large`: the body is larger than 256 KiB

### 422

Unprocessable Entity.

- `field.required`, `field.too_long`, `field.invalid`: a field breaks a rule; `errors` points at it
- `escalation_policy.unknown`: `escalationPolicyId` is not a policy of this workspace

### 429

Too Many Requests.

- `token.rate_limited`: more than 10 requests a second with this token
- `session.rate_limited`: more than 5 changes a second from your sessions

Schemas named above are listed with their fields in [the schema list](https://docs.monitorly.cloud/api/reference/schemas.md).
