# Copy a server check's rules

`POST /api/v1/checks/{checkId}/copy-rules`

Gives other server checks the rules of this one: every rule, threshold and duration, the rules of              each disk and the ignore lists. Each target keeps its server, name, project and alerts. Every              target changes, or none does. Needs the viewer role on this check and the editor role on every              target.

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: `copy_server_rules`.

## Parameters

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

## Request body

Required: yes.

`application/json`: CopyRulesInput

| Field | Type | Required | Description |
|---|---|---|---|
| `targets` | array of string (uuid) | yes | Server checks to take the rules, 1–100, each once and not the source. |

## Responses

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

### 200

The target checks as they are stored now.

`application/json`: CopyRulesResult

| Field | Type | Required | Description |
|---|---|---|---|
| `checks` | array of CheckView | yes | The targets as stored now. |

### 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

### 409

Conflict.

- `check.not_server`: rules are copied only from a server check to server checks

### 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

### 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).
