# Create an escalation policy

`POST /api/v1/workspaces/{workspaceId}/escalation-policies`

Creates a policy: levels of channels to alert, each after a delay from the start of the incident (the first at 0), repeated until someone acknowledges. Workspace owner or admin.

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

Section: Escalation policies. Operation id in openapi.json: `create_escalation_policy`.

## Parameters

| Name | In | Required | Type | Description |
|---|---|---|---|---|
| `workspaceId` | path | yes | string (uuid) | The workspace's id. |
| `Idempotency-Key` | header | no | string | Any 1–255 characters, for example a UUID per intended action. A retry with the same key and the same request answers the stored response and creates nothing again; the same key with another request answers `422 request.idempotency_key_reused`. Keys are kept for 24 hours. |

## Request body

Required: yes.

`application/json`: EscalationPolicyInput

| Field | Type | Required | Description |
|---|---|---|---|
| `levels` | array of LevelInput | yes | 1–10 levels in order. |
| `name` | string | yes | 1–100 characters; names need not be unique. |
| `repeatAfterMins` | integer | no | Minutes from the last level to the repeat, 1–10080. |
| `repeatCount` | integer | no | How many times the whole policy runs again after its last level, 0–9. |

Example:

```json
{
  "levels": [
    {
      "delayMins": 0,
      "targets": [
        {
          "id": "CHANNEL_ID",
          "kind": "channel"
        }
      ]
    },
    {
      "delayMins": 15,
      "targets": [
        {
          "id": "USER_ID",
          "kind": "member"
        }
      ]
    }
  ],
  "name": "payments on-call",
  "repeatAfterMins": 30,
  "repeatCount": 1
}
```

## Responses

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

### 201

The policy.

`application/json`: EscalationPolicyView

| Field | Type | Required | Description |
|---|---|---|---|
| `checkCount` | integer | yes | Checks that use it instead of their project's policy. |
| `createdAt` | string | yes |  |
| `id` | string (uuid) | yes |  |
| `levels` | array of LevelView | yes |  |
| `name` | string | yes |  |
| `projects` | array of PolicyProject | yes | Projects that use the policy by default (those the caller sees). |
| `repeatAfterMins` | integer | yes |  |
| `repeatCount` | integer | yes |  |
| `updatedAt` | string | yes |  |
| `workspaceId` | string (uuid) | yes |  |

Example:

```json
{
  "checkCount": 0,
  "createdAt": "2026-11-27T15:50:00Z",
  "id": "POLICY_ID",
  "levels": [
    {
      "delayMins": 0,
      "targets": [
        {
          "id": "CHANNEL_ID",
          "kind": "channel",
          "name": "#payments-oncall"
        }
      ]
    },
    {
      "delayMins": 15,
      "targets": [
        {
          "id": "USER_ID",
          "kind": "member",
          "name": "Dana Ortiz"
        }
      ]
    }
  ],
  "name": "payments on-call",
  "projects": [],
  "repeatAfterMins": 30,
  "repeatCount": 1,
  "updatedAt": "2026-11-27T15:50:00Z",
  "workspaceId": "WORKSPACE_ID"
}
```

### 400

Bad Request.

- `request.malformed`: the body or a parameter is not of the expected shape
- `request.idempotency_key_invalid`: the key is empty or longer than 255 characters
- `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.no_levels`: a policy has at least one level
- `escalation_policy.too_many_levels`: more than 10 levels; `params.max`
- `escalation_policy.first_delay_not_zero`: level 1 goes out when the incident opens: its `delayMins` is 0
- `escalation_policy.delay_out_of_range`: a later level waits 1 to 1440 minutes after the one before; `params.min`, `params.max`
- `escalation_policy.too_many_targets`: more than 20 targets on a level; `params.max`
- `escalation_policy.duplicate_target`: the same target twice on one level
- `escalation_policy.target_unknown`: the target is not an alert channel, a linked Telegram chat or a member of this workspace
- `escalation_policy.repeat_count_out_of_range`: `repeatCount` is more than 9
- `escalation_policy.repeat_after_out_of_range`: `repeatAfterMins` is not 1 to 10080; `params.min`, `params.max`

### 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
- `token.create_limited`: more than 30 resources created within an hour from one token; `Retry-After` in seconds

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