# Rotate a heartbeat URL

`POST /api/v1/checks/{checkId}/heartbeat-token`

Gives a heartbeat check a new ping URL. The old one stops working at once, so update the job that pings it. The new URL is in this answer only.

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

## Parameters

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

## Responses

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

### 200

The check and its new `pingUrl`.

`application/json`: CheckSaved

| Field | Type | Required | Description |
|---|---|---|---|
| `check` | CheckView | yes |  |
| `pingUrl` | string \| null | no |  |

### 400

Bad Request.

- `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_heartbeat`: only a heartbeat check has a ping token

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