# Test a check

`POST /api/v1/projects/{projectId}/check-tests`

Runs a check once on each of its locations without saving anything, for example before creating it or after a deploy. `check` is validated as for [Create a check](https://docs.monitorly.cloud/api/reference/operations/create-check.md); `checkId` lets the test use the stored secrets of a saved check. The answer comes at once with every location `pending`: poll [Get a check test](https://docs.monitorly.cloud/api/reference/operations/get-check-test.md) for the results. Heartbeat checks cannot be tested.

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

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

## Parameters

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

## Request body

Required: yes.

`application/json`: CheckTestInput

| Field | Type | Required | Description |
|---|---|---|---|
| `check` | CheckInput | yes | The check as the editor shows it, validated like a create; `nodes` are the nodes to run it on. |
| `checkId` | string (uuid) \| null | no | The saved check being edited, whose stored secrets `{"kind": "secret", "secretId": …}` may use. |

Example:

```json
{
  "check": {
    "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"
    ]
  }
}
```

## Responses

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

### 202

The test, with every location pending.

`application/json`: CheckTestView

| Field | Type | Required | Description |
|---|---|---|---|
| `deadline` | string | yes | The check's timeout + 5 s after the start. |
| `done` | boolean | yes | `running` until every node answered or the deadline passed. |
| `id` | string (uuid) | yes |  |
| `projectId` | string (uuid) | yes |  |
| `results` | array of NodeTestResult | yes | In the order of `check.nodes`. |
| `startedAt` | string | yes |  |

Example:

```json
{
  "deadline": "2026-11-27T15:10:15Z",
  "done": false,
  "id": "TEST_ID",
  "projectId": "PROJECT_ID",
  "results": [
    {
      "failures": [],
      "nodeId": "NODE_ID_HEL",
      "status": "pending"
    },
    {
      "failures": [],
      "nodeId": "NODE_ID_FRA",
      "status": "pending"
    },
    {
      "failures": [],
      "nodeId": "NODE_ID_AMS",
      "status": "pending"
    }
  ],
  "startedAt": "2026-11-27T15:10:00Z"
}
```

### 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
- `check_test.not_runnable`: a heartbeat check waits for pings and cannot be checked on nodes
- `check.node_unavailable`: node does not exist, is revoked, or is a private node of another 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
- `check_test.busy`: a test of this check by you is already running, or the project already runs 3 tests; `Retry-After` in seconds
- `check_test.rate_limited`: more than 20 tests in 10 minutes by you or in the workspace; wait `Retry-After` seconds

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