# Plan a configuration

`POST /api/v1/projects/{projectId}/config/plan`

Compares a `monitorly.yaml` body with the project and stores the plan for 15 minutes: what would be created, changed and deleted. Nothing changes until [Apply a plan](https://docs.monitorly.cloud/api/reference/operations/apply-config.md). A token needs the write scope of every section in the body. Needs the editor role.

Sign-in: a dashboard session, any API token or the `monitorly` CLI's sign-in.

Section: Config plan and apply. Operation id in openapi.json: `plan_config`.

## Parameters

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

## Request body

Required: yes.

`application/json`: ConfigBody

| Field | Type | Required | Description |
|---|---|---|---|
| `$schema` | string \| null | no | The JSON Schema of this document, for editors; ignored. |
| `checks` | array of ConfigCheck \| null | no |  |
| `maintenance` | array of ConfigMaintenance \| null | no |  |
| `prune` | boolean | no | Delete, in the present sections, resources managed by config that the body no longer lists. |
| `statusPages` | array of ConfigPage \| null | no |  |

Example:

```json
{
  "checks": [
    {
      "intervalSecs": 30,
      "kind": {
        "assertions": [
          {
            "op": "eq",
            "target": "status",
            "value": 200
          },
          {
            "op": "equals",
            "path": "$.db",
            "target": "json",
            "value": "ok"
          }
        ],
        "maxRedirects": 0,
        "method": "GET",
        "type": "http",
        "url": "https://api.acme.io/healthz"
      },
      "name": "payments-health",
      "nodes": [
        "NODE_ID_HEL",
        "NODE_ID_FRA",
        "NODE_ID_AMS"
      ],
      "ref": "payments-health"
    }
  ],
  "prune": false
}
```

## Responses

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

### 201

The plan.

`application/json`: ConfigPlanView

| Field | Type | Required | Description |
|---|---|---|---|
| `appliedAt` | string \| null | no | When the plan was applied; null until then. Always sent; optional in the schema because it was added after the first clients. |
| `changes` | array of ConfigChange | yes |  |
| `expiresAt` | string | yes | Apply before this instant. |
| `planId` | string (uuid) | yes |  |
| `projectId` | string (uuid) | yes |  |
| `prune` | boolean | yes |  |
| `summary` | PlanSummary | yes |  |

Example:

```json
{
  "changes": [
    {
      "action": "update",
      "diff": [
        {
          "after": 30,
          "before": 60,
          "path": "/intervalSecs"
        }
      ],
      "id": "CHECK_ID",
      "ref": "payments-health",
      "resourceType": "check",
      "warnings": []
    }
  ],
  "expiresAt": "2026-11-27T16:30:00Z",
  "planId": "PLAN_ID",
  "projectId": "PROJECT_ID",
  "prune": false,
  "summary": {
    "create": 0,
    "delete": 0,
    "unchanged": 0,
    "update": 1
  }
}
```

### 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
- `config.ref_invalid`: `ref` does not match `^[a-z0-9][a-z0-9-]{0,62}$`
- `config.ref_duplicate`: `ref` is repeated in a plan section (for components, on a page)
- `config.ref_unknown`: reference to a check by a `ref` that exists neither in the plan nor in the project
- `config.plan_too_large`: body has more than 300 resources or a page has more than 300 components (`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

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