# Services

Monitored services: HTTP, TCP and API checks, their results, their scans and the parameters a check takes.

Its operations need the scopes `services.edit`, `services.view`, `services.delete` or `alarms.edit`.

**Endpoints**

- `POST/v1/services`
- `PUT/v1/services/{service_uuid}`
- `GET/v1/services/{service_uuid}`
- `GET/v1/services`
- `DELETE/v1/services/{service_uuid}`
- `POST/v1/services/collector-preview`
- `GET/v1/services/{service_uuid}/collectors`
- `POST/v1/services/{service_uuid}/duplicate`
- `DELETE/v1/services/{service_uuid}/alarm-snooze`
- `POST/v1/services/import`
- `GET/v1/services/{service_uuid}/parameters/test`
- `POST/v1/services/{service_uuid}/pause`
- `POST/v1/services/{service_uuid}/reassign`
- `POST/v1/services/{service_uuid}/resume`
- `POST/v1/services/{service_uuid}/run-now`
- `GET/v1/services/{service_uuid}/runs`
- `GET/v1/services/{service_uuid}/runs/{run_uuid}`
- `GET/v1/services/{service_uuid}/scans`
- `PUT/v1/services/{service_uuid}/alarm-snooze`
- `POST/v1/services/{service_uuid}/parameters/test`
- `POST/v1/services/test-runs`
- `POST/v1/services/{service_uuid}/test-runs`
- `GET/v1/service-test-runs/{test_uuid}`
- `POST/v1/services/{service_uuid}/verify`
- `GET/v1/services/{service_uuid}/versions`
- `GET/v1/services/{service_uuid}/versions/{version_uuid}`

## The Service object

### Attributes

- `uuid` (string): The service’s uuid.
- `name` (string): The service’s name.
- `steps` (array of objects): The service’s steps, in order. A step has `uuid` (assigned when it is first saved, kept across edits), `name`, `type` (`http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`), `method`, `scheme`, `host`, `port`, `path` (no query string), `auth` (only its `type`), `options` (the ones its type uses, filled in), `assertions` (at most 20), `extract` (at most 10), `on_success`, `on_failure`, `repeat` and `keep_evidence` (whether the step keeps what its server answered as evidence). Header names and values, bodies, cookies, query strings, payloads, messages, metadata and authentication fields are never returned.
- `variables` (array of objects): The values generated for each run (`{{var.name}}`): each `{name, generator, …}`, never a value.
- `run` (object): The whole run: its budget in seconds and its fast retry.
  - `budget_seconds` (integer): The whole run’s budget in seconds, 5 to 300; the check interval is at least this rounded up to a minute.
  - `fast_retry` (object): The whole-run fast retry: how often a failed run is retried at once, and how long it waits between tries.
    - `count` (integer): How many times a failed run is retried at once, 0 to 3.
    - `interval_ms` (integer): The pause between fast retries, in milliseconds, 0 to 60,000.
- `live_version` (integer): The number of the version that is live: every save writes a new one, kept for ever.
- `check_interval_seconds` (integer): Seconds between two checks.
- `active` (boolean): Whether monitoring is switched on.
- `status` (string): One of `up`, `down`, `pending` (no reachability result yet) and `suspended` (switched off). Values:`suspended``pending``up``down`(an open set: new values may be added)
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`: the effective health (no collectors reads `unknown`).
- `collector_status` (string): The collector pool’s state: active and standby, or why it is not (`needs_collectors`, `failing`, …).
- `collector_status_reason` (string or null): Why the collector pool is awaiting a collector or failing, such as `dns`, `blocked_destination` or `parameter_unavailable`; null otherwise.
- `pool_mode` (string): `active_standby` or `all_members`.
- `member_limit` (integer or null): How many collectors report, in `all_members` mode; null otherwise.
- `quorum_n` (integer or null): How many members must agree, in `all_members` mode; null otherwise.
- `collector_last_result_at` (integer or null): Epoch milliseconds. When a collector last reported a result; null when none has. An instant: epoch milliseconds, UTC.
- `latest_reachability` (object or null): The latest scored reachability result; null until one completes.
  - `is_reachable` (boolean or null): Whether the host and port answered within the timeout; null until completed.
  - `response_time_ms` (integer or null): The connect time in milliseconds; null when none was measured.
  - `error_message` (string or null): The error text of a failed check, without any parameter value; null when it passed.
  - `checked_at` (integer or null): Epoch milliseconds. When the reachability result completed; null while it has not. An instant: epoch milliseconds, UTC.
- `latest_response` (object or null): The latest scored response check; null until one completes.
  - `is_up` (boolean or null): Whether every configured response check passed; null until completed.
  - `http_status_code` (integer or null): The HTTP status code received; null when the request failed.
  - `status_match` (boolean or null): Whether the status was one of the expected statuses; null when not judged.
  - `body_match` (boolean or null): Whether the body contained the expected text; null when not judged.
  - `response_time_ms` (integer or null): The request time in milliseconds; null when none was measured.
  - `content_type` (string or null): The `Content-Type` header of the response; null when none was received.
  - `error_message` (string or null): The error text of a failed check, without any parameter value; null when it passed.
  - `checked_at` (integer or null): Epoch milliseconds. When the response check completed; null while it has not. An instant: epoch milliseconds, UTC.
- `alarm_snooze` (object or null): The service’s own alarm snooze, which holds the alarm notifications of every alarm on the service; null when none is live. See `PUT /v1/services/{service_uuid}/alarm-snooze`.
  - `until` (integer or null): Epoch milliseconds. When the service’s snooze ends. An instant: epoch milliseconds, UTC.
  - `reason` (string or null): The reason given when it was set; null when none was.
  - `set_at` (integer or null): Epoch milliseconds. When it was last set. An instant: epoch milliseconds, UTC.
- `tags` (array of objects): The tags attached to the service.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
- `console_url` (string): The service’s page in the console.

**The Service object**

```json
{
  "uuid": "75666699-b77d-4631-b576-041e8102a55b",
  "name": "example",
  "steps": [
    {}
  ],
  "variables": [
    {}
  ],
  "run": {
    "budget_seconds": 1,
    "fast_retry": {
      "count": 1,
      "interval_ms": 1
    }
  },
  "live_version": 1,
  "check_interval_seconds": 1,
  "active": true,
  "status": "suspended",
  "health_status": "example",
  "collector_status": "example",
  "collector_status_reason": "example",
  "pool_mode": "example",
  "member_limit": 1,
  "quorum_n": 1,
  "collector_last_result_at": 1794214800000,
  "latest_reachability": {
    "is_reachable": true,
    "response_time_ms": 1,
    "error_message": "example",
    "checked_at": 1794214800000
  },
  "latest_response": {
    "is_up": true,
    "http_status_code": 1,
    "status_match": true,
    "body_match": true,
    "response_time_ms": 1,
    "content_type": "example",
    "error_message": "example",
    "checked_at": 1794214800000
  },
  "alarm_snooze": {
    "until": 1794214800000,
    "reason": "example",
    "set_at": 1794214800000
  },
  "tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    }
  ],
  "console_url": "example"
}
```

## Create a service

POST/v1/services

Adds a service to monitor, with the servers that check it chosen by hand or by tags. Parameters and authentication need the `services.parameters` scope on the key and the permission on the owner’s role (a service account’s key: the scope alone), and are refused with 403 otherwise. Refuses an organisation over its service limit and one that needs a payment method.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Body parameters

- `name` (string, required): The service’s name, up to 255 characters.
- `check_interval_seconds` (integer or null): Seconds between two checks, from 60 to 86400 and at least the run budget rounded up to a whole minute; 60 when omitted on create.
- `notes` (string or null): Free-form notes about the service; null or omitted stores none.
- `active` (boolean or null): Whether monitoring is switched on; on when omitted.
- `tag_uuids` (array of strings or null): The uuids of the tags the service carries.
- `parameters` (array of strings or null): The parameter definitions the check reads (name, source, format and selector, never a value). Needs the `services.parameters` permission.
- `steps` (array of arrays, required): The service’s steps, 1 to 10, in order. Each step makes a request of any protocol (`http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`), verifies the answer with assertions, extracts values for later steps and decides what happens next. A single check is a one-step service. A step may carry `keep_evidence` (boolean): whether it keeps what its server answered as evidence, on for a new step; on an update, a step sent with its `uuid` and no `keep_evidence` keeps the stored value. The write-only parts of a step (header names and values, bodies, cookies, query strings, payloads, messages, metadata and every authentication field) are never returned.
- `variables` (array of strings or null): The values generated for each run (up to 10): `numeric`, `alphabetic`, `alphanumeric`, `uuid`, `timestamp`, `date`, `run_uuid` and `service_uuid`.
- `run` (array of strings or null): The whole run: `budget_seconds` (5 to 300; the sum of the steps’ own times when omitted) and `fast_retry` (`count` 0 to 3, `interval_ms` 0 to 60,000).
- `collectors` (object, required): The servers that run the check, chosen by hand or by tags. Required on create.
  - `selection` (string): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
  - `servers` (array of strings or null): The uuids of the servers to use, in order, with selection `servers`; at most 50.
  - `all` (array of strings or null): Servers must carry all of these tags, as tag UUIDs, with selection `tags`; at most 20.
  - `any` (array of strings or null): Servers must carry at least one of these tags, as tag UUIDs, with selection `tags`; at most 20.
- `pool_mode` (string or null): `active_standby` (one collector with a standby) or `all_members` (every collector in the pool reports). Values:`active_standby``all_members`(an open set: new values may be added)
- `member_limit` (integer or null): With `all_members`, the most collectors that report, from 1 to the pool limit; only valid in that mode.
- `quorum_n` (integer or null): With `all_members`, how many collectors must agree, from 1 and at most the member limit; only valid in that mode.

### Returns

`201 Created`:

The service that was created.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "example",
    "steps": [
      [
        "example"
      ]
    ],
    "collectors": {}
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$service = $wt15->services->create(['name' => 'example', 'steps' => [['example']], 'collectors' => []]);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.create({ name: 'example', steps: [['example']], collectors: {  } });
```

Python:

```python
client = Client.from_environment()

result = client.services.create(name='example', steps=[['example']], collectors={})
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (402 Payment Required)**

The organisation's payment gate blocks the action: `payment_required` (no payment method) or `invoice_overdue`. Nothing is billed and nothing is started.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/payment_required/",
  "title": "Payment required",
  "status": 402,
  "code": "payment_required",
  "detail": "A payment method must be set before adding resources for monitoring.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Update a service

PUT/v1/services/{service\_uuid}

Replaces a service’s definition; the fields the answer of `GET /v1/services/{service_uuid}` leaves out are kept from the stored service when omitted. Omitted request headers keep their stored names, an omitted body is kept while the destination is unchanged, and an omitted password or token is kept. Changing the destination without re-sending a stored body or header value is refused.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Body parameters

- `name` (string, required): The service’s name, up to 255 characters.
- `check_interval_seconds` (integer or null): Seconds between two checks, from 60 to 86400 and at least the timeout rounded up to a whole minute.
- `notes` (string or null): Free-form notes about the service; omit to keep the current notes, null clears them.
- `active` (boolean, required): Whether monitoring is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags the service carries.
- `parameters` (array of strings or null): The parameter definitions the check reads (name, source, format and selector, never a value). Needs the `services.parameters` permission.
- `steps` (array of arrays, required): The service’s steps, 1 to 10, in order. Each step makes a request of any protocol (`http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`), verifies the answer with assertions, extracts values for later steps and decides what happens next. A single check is a one-step service. A step may carry `keep_evidence` (boolean): whether it keeps what its server answered as evidence, on for a new step; on an update, a step sent with its `uuid` and no `keep_evidence` keeps the stored value. The write-only parts of a step (header names and values, bodies, cookies, query strings, payloads, messages, metadata and every authentication field) are never returned.
- `variables` (array of strings or null): The values generated for each run (up to 10): `numeric`, `alphabetic`, `alphanumeric`, `uuid`, `timestamp`, `date`, `run_uuid` and `service_uuid`.
- `run` (array of strings or null): The whole run: `budget_seconds` (5 to 300; the sum of the steps’ own times when omitted) and `fast_retry` (`count` 0 to 3, `interval_ms` 0 to 60,000).
- `collectors` (object or null): The servers that run the check, chosen by hand or by tags; omit to leave the pool unchanged.
  - `selection` (string): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
  - `servers` (array of strings or null): The uuids of the servers to use, in order, with selection `servers`; at most 50.
  - `all` (array of strings or null): Servers must carry all of these tags, as tag UUIDs, with selection `tags`; at most 20.
  - `any` (array of strings or null): Servers must carry at least one of these tags, as tag UUIDs, with selection `tags`; at most 20.
- `pool_mode` (string or null): `active_standby` (one collector with a standby) or `all_members` (every collector in the pool reports). Values:`active_standby``all_members`(an open set: new values may be added)
- `member_limit` (integer or null): With `all_members`, the most collectors that report, from 1 to the pool limit; only valid in that mode.
- `quorum_n` (integer or null): With `all_members`, how many collectors must agree, from 1 and at most the member limit; only valid in that mode.

### Returns

`200 OK`:

The service after the update.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**PUT /v1/services/{service_uuid}**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "example",
    "active": true,
    "steps": [
      [
        "example"
      ]
    ]
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$service = $wt15->services->update('6b8ec5a3-9417-480d-bff3-7f8faddb1083', ['name' => 'example', 'active' => true, 'steps' => [['example']]]);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.update('6b8ec5a3-9417-480d-bff3-7f8faddb1083', { name: 'example', active: true, steps: [['example']] });
```

Python:

```python
client = Client.from_environment()

result = client.services.update('6b8ec5a3-9417-480d-bff3-7f8faddb1083', name='example', active=True, steps=[['example']])
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (402 Payment Required)**

The organisation's payment gate blocks the action: `payment_required` (no payment method) or `invoice_overdue`. Nothing is billed and nothing is started.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/payment_required/",
  "title": "Payment required",
  "status": 402,
  "code": "payment_required",
  "detail": "A payment method must be set before adding resources for monitoring.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a service

GET/v1/services/{service\_uuid}

Returns one service with its definition, its latest scored reachability and response results, the state of its collector pool and its tags. Request headers, the body and authentication secrets are never returned. Opening a service may also add any default alarms the catalogue gained since it was created, as the console’s page does.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The service.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$service = $wt15->services->view('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.view('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.view('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## List services

GET/v1/services

Returns the organisation’s services, filtered by search text or tags and sorted by name, health, last scan or response time. Each row summarises the service’s definition, status, health, latest response time and collector pool. Pages by `page` and `per_page` (`limit` is the same as `per_page`); every page carries `current_page`, `per_page`, `last_page` and `total`.

Needs the scope `services.view`.

### Query parameters

- `search` (string or null): Only services whose name or host contains this text.
- `tag_uuids` (array of strings or null): Only services carrying at least one of these tags, as tag UUIDs. A list: repeat the parameter (`tag_uuids=<uuid>&tag_uuids=<uuid>`) or send one value (`tag_uuids=<uuid>`); `tag_uuids[]=<uuid>` is accepted too.
- `sort` (string or null): The column to sort by: `name`, `health`, `last_scan` or `response_time`. Values:`name``health``last_scan``response_time`(an open set: new values may be added)
- `direction` (string or null): The sort direction, `asc` (the default) or `desc`. Values:`asc``desc`(an open set: new values may be added)
- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): How many items one page holds, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the organisation’s services.

Each item of the page:

- `uuid` (string): The service’s uuid.
- `name` (string): The service’s name.
- `step_count` (integer): How many steps the service has, 1 to 10.
- `step_types` (array of strings): The types of its steps, each once, in order of first use: `http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`: the effective health (no collectors reads `unknown`).
- `status` (string): One of `up`, `down`, `pending` (no reachability result yet) and `suspended` (switched off). Values:`suspended``pending``up``down`(an open set: new values may be added)
- `active` (boolean): Whether monitoring is switched on.
- `check_interval_seconds` (integer): Seconds between two checks.
- `run_budget_seconds` (integer): Seconds one whole run may take.
- `latest_response_time_ms` (integer or null): The latest scored reachability result’s response time.
- `latest_checked_at` (integer or null): Epoch milliseconds. When the latest scored reachability result completed; null with none. An instant: epoch milliseconds, UTC.
- `collector_status` (string): The collector pool’s state: active and standby, or why it is not (`needs_collectors`, `failing`, …).
- `collector_status_reason` (string or null): Why the collector pool is awaiting a collector or failing, such as `dns`, `blocked_destination` or `parameter_unavailable`; null otherwise.
- `pool_mode` (string): `active_standby` (one collector with a standby) or `all_members` (every collector in the pool reports).
- `member_count` (integer): How many collectors are in the pool.
- `alarm_snooze` (object or null): The service’s own alarm snooze, which holds the alarm notifications of every alarm on the service; null when none is live. See `PUT /v1/services/{service_uuid}/alarm-snooze`.
  - `until` (integer or null): Epoch milliseconds. When the service’s snooze ends. An instant: epoch milliseconds, UTC.
  - `reason` (string or null): The reason given when it was set; null when none was.
  - `set_at` (integer or null): Epoch milliseconds. When it was last set. An instant: epoch milliseconds, UTC.
- `console_url` (string): The service’s page in the console.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services**

curl:

```bash
curl https://rest.watchtower15.com/v1/services \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

foreach ($wt15->services->list()->autoPaging() as $service) { echo $service->uuid, "\n"; }
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

for await (const item of wt15.services.list()) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.services.list():
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "step_count": 0,
      "step_types": [
        "example"
      ],
      "health_status": "example",
      "status": "suspended",
      "active": true,
      "check_interval_seconds": 1,
      "run_budget_seconds": 1,
      "latest_response_time_ms": 1,
      "latest_checked_at": 1794214800000,
      "collector_status": "example",
      "collector_status_reason": "example",
      "pool_mode": "example",
      "member_count": 1,
      "alarm_snooze": {
        "until": 1794214800000,
        "reason": "example",
        "set_at": 1794214800000
      },
      "console_url": "example"
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Delete a service

DELETE/v1/services/{service\_uuid}

Deletes the service and stops monitoring it.

Needs the scope `services.delete`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`204 No Content`:

The service was deleted; there is no body.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**DELETE /v1/services/{service_uuid}**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$wt15->services->delete('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

await wt15.services.delete('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

client.services.delete('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (204 No Content)**

```http
HTTP/1.1 204 No Content
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.delete scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Preview service collectors

POST/v1/services/collector-preview

Lists the servers a collector selection, by hand or by tags, would pick, with the role each would get, why each excluded server is left out and any warning about the pool. It reads only: nothing is saved and no server is contacted.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Body parameters

- `selection` (string, required): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
- `servers` (array of strings or null): The uuids of the servers to preview, with `selection` `servers`.
- `all` (array of strings or null): Servers must carry ALL of these tags.
- `any` (array of strings or null): Servers must carry ANY of these tags.
- `with_parameters` (boolean or null): Whether the preview asks for the collectors that can read a parameter.

### Returns

`200 OK`:

The matching servers and the pool’s warnings.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/collector-preview**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/collector-preview \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "selection": "servers"
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->collectorPreview(['selection' => 'servers']);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.collectorPreview({ selection: 'servers' });
```

Python:

```python
client = Client.from_environment()

result = client.services.collector_preview(selection='servers')
```

**Response (200 OK)**

```json
{
  "data": {
    "servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "agent_version": "example",
        "agent_last_seen_at": 1794214800000,
        "service_capability": true,
        "carries": 1,
        "role": "example",
        "excluded_because": "example"
      }
    ],
    "warnings": [
      {
        "code": "example",
        "message": "example"
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## List a service's collectors

GET/v1/services/{service\_uuid}/collectors

Returns the servers of the service’s collector pool: each one’s role (`active` and `standby` in active-standby mode, `member` in every-collector mode, `cold` for a candidate), whether it is eligible, why it is excluded, and the time and result of its last check. A server’s address is never returned.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service in the path.

### Returns

`200 OK`:

The service’s collector pool.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/collectors**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/collectors \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->collectors('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.collectors('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.collectors('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "pool_mode": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collectors": [
      {
        "server": {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        },
        "role": "example",
        "eligible": true,
        "excluded_because": "example",
        "last_check_at": 1794214800000,
        "last_check_ok": true,
        "last_check_reason": "example"
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Duplicate a service

POST/v1/services/{service\_uuid}/duplicate

Creates a copy of a service with the same steps, variables, run, parameters and collector rule. The copy is paused, holds new step uuids and no lease, so it never doubles checks until you resume it. Refuses an organisation over its service limit and one that needs a payment method.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service to copy.

### Body parameters

- `name` (string or null): The copy’s name, up to 255 characters; `Copy of <name>` when omitted.

### Returns

`201 Created`:

The new copy of the service.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/duplicate**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/duplicate \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->duplicate('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.duplicate('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.duplicate('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## End a service's alarm snooze

DELETE/v1/services/{service\_uuid}/alarm-snooze

Ends the service’s alarm snooze early, so held notifications are released by the next sweep (up to a minute), as described for `PUT`. The call is safe to repeat: it answers 204 also when the service had no live snooze, since the end state is what you asked for. Needs the `alarms.edit` scope.

Needs the scope `alarms.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The UUID of the service.

### Returns

`204 No Content`:

The snooze was ended, or there was none; the answer has no body.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**DELETE /v1/services/{service_uuid}/alarm-snooze**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/alarm-snooze \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$wt15->services->endAlarmSnooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

await wt15.services.endAlarmSnooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

client.services.end_alarm_snooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (204 No Content)**

```http
HTTP/1.1 204 No Content
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the alarms.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Import a step

POST/v1/services/import

Reads a pasted cURL command, or one operation of a pasted OpenAPI document (JSON or YAML, up to 1 MB, named by its operationId or as “METHOD path”), and answers the step it makes. Nothing is saved: send the step in a create or an update. Every credential in the source becomes a `{{param.name}}` reference listed in `parameters_needed`, which you add to the service as Parameters; its value is in no answer. A flag or part the reader does not know is named in `unread_flags`. A document is pasted, never fetched: a `url` is refused.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Body parameters

- `source` (string, required): What the text is: `curl` for a cURL command, `openapi` for an OpenAPI document. Values:`curl``openapi`(an open set: new values may be added)
- `source_text` (string, required): The pasted cURL command or OpenAPI document (JSON or YAML), up to 1 MB. It is never logged.
- `operation` (string or null): With `openapi`, the operation to read: its `operationId`, or `METHOD path` such as `GET /pets/{petId}`.
- `url` (string): Refused: a document is pasted, never fetched.

### Returns

`200 OK`:

The step, the parameters it needs and what was not read.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/import**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/import \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "source": "curl",
    "source_text": "example"
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->import(['source' => 'curl', 'source_text' => 'example']);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.import({ source: 'curl', source_text: 'example' });
```

Python:

```python
client = Client.from_environment()

result = client.services.import(source='curl', source_text='example')
```

**Response (200 OK)**

```json
{
  "data": {
    "step": {},
    "parameters_needed": [
      {
        "name": "example",
        "for": "example"
      }
    ],
    "unread_flags": [
      "example"
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a service parameters test

GET/v1/services/{service\_uuid}/parameters/test

Returns the state of the last parameters test: `none` when none is pending or recent, `pending`, or `done` with the results by parameter name. A result says whether the parameter was found, its length and where it came from, never its value.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The state of the last parameters test and its results.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/parameters/test**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/parameters/test \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->parameterTestResult('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.parameterTestResult('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.parameter_test_result('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "status": "example",
    "requested_at": 1794214800000,
    "completed_at": 1794214800000,
    "results": [
      {
        "name": "example",
        "found": true,
        "length": 1,
        "source": "example",
        "error": "example",
        "at": "example"
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Pause a service

POST/v1/services/{service\_uuid}/pause

Pauses monitoring: the service is switched off, open incidents on it are resolved and its collectors stop checking. Answers the service as the single-service read does.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The service after it was paused.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/pause**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/pause \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->pause('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.pause('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.pause('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Reassign a service

POST/v1/services/{service\_uuid}/reassign

Moves checking to the standby collector at once; the previous active collector becomes the standby and its late results are ignored. Refused in `all_members` mode, where every member checks. Answers the service as the single-service read does.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The service after the reassignment.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/reassign**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/reassign \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->reassign('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.reassign('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.reassign('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Resume a service

POST/v1/services/{service\_uuid}/resume

Resumes a paused service: checking and billing start again, so the payment method is checked first. The service is verified again, and its alarms stay quiet until the first result after the resume. Answers the service as the single-service read does.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The service after it was resumed.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/resume**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/resume \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->resume('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.resume('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.resume('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (402 Payment Required)**

The organisation's payment gate blocks the action: `payment_required` (no payment method) or `invoice_overdue`. Nothing is billed and nothing is started.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/payment_required/",
  "title": "Payment required",
  "status": 402,
  "code": "payment_required",
  "detail": "A payment method must be set before adding resources for monitoring.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Run a service check now

POST/v1/services/{service\_uuid}/run-now

Asks the active collector, or every member in `all_members` mode, to make one extra check now, scored like a scheduled one. Nothing is checked from WatchTower15 itself. Answers the service as the single-service read does.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`202 Accepted`:

The service, with the check requested.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/run-now**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/run-now \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->runNow('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.runNow('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.run_now('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (202 Accepted)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## List a service's runs

GET/v1/services/{service\_uuid}/runs

Returns the runs of a workflow service in a time window, newest first, one cursor page at a time, from every collector: each run has its status, its reason, its duration against its budget, the collector that ran it and the step that failed. A window inside the last 30 days is read from every run; the part of a window older than that holds only the runs that mattered (the first failed run of a streak, one a hour while it lasts, and the recovery), and `meta.history_only_before` says where that begins. A service that is not a workflow answers an empty page with `meta.path` `check`: its results are `GET /v1/services/{service_uuid}/scans`.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Query parameters

- `period` (string or null): A relative window ending now: 1 to 9999 minutes, hours, days or weeks (`3h`, `2w`). Not with `from` and `to`. The operation names its longest window and its default.
- `from` (string or null): The start of a pinned window, epoch milliseconds or RFC 3339 with an offset. Needs `to`. A start before the oldest data kept is served from it.
- `to` (string or null): The end of a pinned window, epoch milliseconds or RFC 3339 with an offset, after `from`. A window that ends before the oldest data kept, or in the future, is refused.
- `status` (array of strings or null): Only runs with one of these statuses: `passed`, `failed`, `budget_exceeded` or `refused`. Repeat the parameter (`status[]=failed&status[]=budget_exceeded`) for several. A list: repeat the parameter (`status=passed&status=failed`) or send one value (`status=passed`); `status[]=passed` is accepted too. Values:`passed``failed``budget_exceeded``refused`(an open set: new values may be added)
- `collector_uuid` (string or null): Only runs of this collector, by the server’s uuid.
- `failed_step_uuid` (string or null): Only runs whose failed step is this one, by the step’s uuid.
- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `cursor` (string or null): The `next_cursor` of the previous page; omit it for the first page.
- `per_page` (integer or null): How many runs one page holds, from 1 to 100; 25 when omitted.

### Returns

`200 OK`:

One page of the service’s runs.

Each item of the page:

- `run_uuid` (string): The run’s uuid.
- `collector` (object): The server that ran the run.
  - `uuid` (string): The uuid of the server that ran it.
  - `name` (string or null): The server’s name; null when the server is gone.
- `version_uuid` (string): The uuid of the service’s saved version that this run ran.
- `version` (integer): The number of that version, 1 for the first.
- `trigger` (string): `scheduled` for a run on the service’s own schedule, `probe` for a run asked for by a probe or a standby collector.
- `status` (string): One of `passed`, `failed`, `budget_exceeded` (the run used its whole time budget) and `refused` (the collector would not run the definition).
- `reason` (string or null): A short name for why a `budget_exceeded` or `refused` run ended so, for example `budget_exceeded`, `definition_unsupported`; null otherwise.
- `started_at` (integer): Epoch milliseconds: when the run started. An instant: epoch milliseconds, UTC.
- `completed_at` (integer): Epoch milliseconds: when the run completed. An instant: epoch milliseconds, UTC.
- `duration_ms` (integer): How long the whole run took, in milliseconds.
- `budget_ms` (integer): The time budget of the run, in milliseconds.
- `attempts` (integer): How many times the run was tried: 1 plus its fast retries.
- `failed_step_uuid` (string or null): The uuid of the first step that failed and stopped the run; null when no step did.
- `failed_reason` (string or null): Why that step failed, a short name such as `timeout` or `assertion_failed`; null when none did.
- `steps_run` (integer): How many steps ran: every step but the ones skipped.
- `eventful` (boolean): Whether this run is one the service keeps for ten years: the first failed run of a streak, one an hour while it lasts and the recovery.
- `retention` (string): `recent` for a run kept for 30 days, `history` for one kept for 10 years.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/runs**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/runs \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

foreach ($wt15->services->runsList('6b8ec5a3-9417-480d-bff3-7f8faddb1083')->autoPaging() as $item) { echo $item->runUuid, "\n"; }
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

for await (const item of wt15.services.runsList('6b8ec5a3-9417-480d-bff3-7f8faddb1083')) {
  console.log(item.run_uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.services.runs_list('6b8ec5a3-9417-480d-bff3-7f8faddb1083'):
    print(item.run_uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "run_uuid": "9a8bd773-d0bf-40d8-a638-a5f17cbf21cf",
      "collector": {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      },
      "version_uuid": "dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d",
      "version": 1,
      "trigger": "example",
      "status": "example",
      "reason": "example",
      "started_at": 1794214800000,
      "completed_at": 1794214800000,
      "duration_ms": 1,
      "budget_ms": 1,
      "attempts": 1,
      "failed_step_uuid": "41f16550-65fb-4883-ab44-3df95fa4a1f1",
      "failed_reason": "example",
      "steps_run": 1,
      "eventful": true,
      "retention": "example"
    }
  ],
  "next_cursor": "example",
  "total": 1,
  "meta": {
    "history_only_before": 1794214800000,
    "path": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a service run

GET/v1/services/{service\_uuid}/runs/{run\_uuid}

Returns one run of a workflow service with every step’s outcome: its status, reason, attempts, timings and the numbers it observed (a status code, a response time), the assertions’ outcomes and the extractions’ outcomes, never a value. A run is kept for 30 days; the runs that mattered (the first failed run of a streak, one a hour while it lasts and the recovery) are kept for 10 years, and `retention` says which. A run that is no longer kept answers not found.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.
- `run_uuid` (string, required): The uuid of the run, from the runs list.

### Returns

`200 OK`:

The run and its steps.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/runs/{run_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/runs/9a8bd773-d0bf-40d8-a638-a5f17cbf21cf \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->runsView('6b8ec5a3-9417-480d-bff3-7f8faddb1083', '9a8bd773-d0bf-40d8-a638-a5f17cbf21cf');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.runsView('6b8ec5a3-9417-480d-bff3-7f8faddb1083', '9a8bd773-d0bf-40d8-a638-a5f17cbf21cf');
```

Python:

```python
client = Client.from_environment()

result = client.services.runs_view('6b8ec5a3-9417-480d-bff3-7f8faddb1083', '9a8bd773-d0bf-40d8-a638-a5f17cbf21cf')
```

**Response (200 OK)**

```json
{
  "data": {
    "run_uuid": "9a8bd773-d0bf-40d8-a638-a5f17cbf21cf",
    "collector": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "version_uuid": "dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d",
    "version": 1,
    "trigger": "example",
    "status": "example",
    "reason": "example",
    "started_at": 1794214800000,
    "completed_at": 1794214800000,
    "duration_ms": 1,
    "budget_ms": 1,
    "attempts": 1,
    "failed_step_uuid": "41f16550-65fb-4883-ab44-3df95fa4a1f1",
    "failed_reason": "example",
    "steps_run": 1,
    "eventful": true,
    "retention": "example",
    "steps": [
      {
        "step_uuid": "370aa2dc-ab89-4c13-8494-981b72b7597d",
        "position": 1,
        "name": "example",
        "type": "example",
        "status": "example",
        "critical": true,
        "reason": "example",
        "attempts": 1,
        "started_at": 1794214800000,
        "duration_ms": 1,
        "observed": {},
        "assertions": [
          {
            "passed": true,
            "reason": "example",
            "observed": 0,
            "observed_type": "example",
            "observed_length": 1
          }
        ],
        "extractions": [
          {
            "name": "example",
            "extracted": true,
            "reason": "example"
          }
        ],
        "evidence": {
          "attempt": 1,
          "of": 1,
          "answered": true,
          "withheld_reason": "example",
          "request": "example",
          "version": "example",
          "status": 1,
          "headers": [
            {}
          ],
          "headers_omitted": 1,
          "body": "example",
          "body_bytes": 1,
          "body_kept": "example",
          "body_decompressed": true,
          "code": 1,
          "message": "example",
          "reply": "example",
          "reply_kept": "example",
          "reply_bytes": 1,
          "trailers": [
            "example"
          ],
          "trailers_omitted": 1,
          "message_kept": "example",
          "message_bytes": 1,
          "reply_encoding": "example",
          "records": [
            {}
          ],
          "records_omitted": 1,
          "subject": "example",
          "issuer": "example",
          "names": [
            "example"
          ],
          "names_omitted": 1,
          "not_before": 1794214800000,
          "not_after": 1794214800000,
          "protocol": "example",
          "cipher": "example",
          "lines": [
            "example"
          ],
          "lines_omitted": 1
        },
        "evidence_dropped": "example",
        "evidence_hidden": true
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## List a service's results

GET/v1/services/{service\_uuid}/scans

Returns the service’s completed results of one type (`reachability` or `response`), newest first, one cursor page at a time, from every collector. The list holds every result of the last 168 hours and then, before `meta.history_only_before`, only the results that mattered: the first failure of a streak, one an hour while it lasts and the recovery, kept for ten years. Each row has the common fields and those of its type; a result kept for ten years has no `error_message` and no `content_type`.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Query parameters

- `type` (string, required): The result type to list: `reachability` or `response`. Values:`reachability``response`(an open set: new values may be added)
- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `cursor` (string or null): The `next_cursor` of the previous page; omit it for the first page.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): How many items one page holds, from 1 to 100; 25 when omitted.

### Returns

`200 OK`:

One page of the service’s completed results of the requested type.

Each item of the page:

- `uuid` (string): The result’s uuid.
- `outcome` (string or null): The scanner’s verdict on a result from a former scanner; null on every result a collector reported and on a result kept past 168 hours.
- `completed_at` (integer or null): Epoch milliseconds: when the result completed; null while it has not. An instant: epoch milliseconds, UTC.
- `execution_time_ms` (integer or null): How long the check took, in milliseconds; null when unknown.
- `error_message` (string or null): The error text of a failed check, without any parameter value; null when the check passed and on a result kept past 168 hours.
- `confirmation` (string or null): Whether a failure was confirmed by the standby collector: `pending`, `confirmed` or `unconfirmed`; null for a result that passed.
- `reason` (string or null): The failure’s reason class (for example `dns`, `refused`, `timeout`); null when the check passed or failed only on an assertion.
- `is_reachable` (boolean or null): Whether the host and port answered within the timeout; null until completed. Present on `reachability` results only.
- `response_time_ms` (integer or null): The connect or request time, in milliseconds; null when none was measured. Present on both result types.
- `ip_resolved` (string or null): The address the host resolved to on the collector; null when it did not resolve. Present on `reachability` results only.
- `is_up` (boolean or null): Whether every configured response check passed; null until completed. Present on `response` results only.
- `http_status_code` (integer or null): The HTTP status code received; null when the request failed. Present on `response` results only.
- `status_match` (boolean or null): Whether the status was one of the expected statuses; null when not judged. Present on `response` results only.
- `body_match` (boolean or null): Whether the body contained the expected text; null when not judged. Present on `response` results only.
- `content_type` (string or null): The `Content-Type` header of the response; null when none was received and on a result kept past 168 hours. Present on `response` results only.
- `response_size_bytes` (integer or null): The size of the response body, in bytes; null when unknown. Present on `response` results only.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/scans**

curl:

```bash
curl -G https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/scans \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -d type=reachability
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

foreach ($wt15->services->scans('6b8ec5a3-9417-480d-bff3-7f8faddb1083', ['type' => 'reachability'])->autoPaging() as $item) { echo $item->uuid, "\n"; }
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

for await (const item of wt15.services.scans('6b8ec5a3-9417-480d-bff3-7f8faddb1083', { type: 'reachability' })) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.services.scans('6b8ec5a3-9417-480d-bff3-7f8faddb1083', type='reachability'):
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "outcome": "example",
      "completed_at": 1794214800000,
      "execution_time_ms": 1,
      "error_message": "example",
      "confirmation": "example",
      "reason": "example",
      "is_reachable": true,
      "response_time_ms": 1,
      "ip_resolved": "example",
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "content_type": "example",
      "response_size_bytes": 1
    }
  ],
  "next_cursor": "example",
  "total": 1,
  "meta": {
    "history_only_before": 1794214800000
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Snooze a service's alarms

PUT/v1/services/{service\_uuid}/alarm-snooze

Holds the alarm notifications of one service for a set time, as the console’s Snooze does. The alarms keep evaluating the whole time: incidents still open, escalate, step down and resolve, and health and the alarm states keep their real values; only the automatic notifications are held. It covers every alarm whose resource is the service: its reachability, response, collector and workflow run and step alarms, and any custom alarm on it. The servers that collect for the service are their own resources and are not covered, and snoozing a server does not snooze the services it checks. While a snooze is live, a new or escalated incident whose alarm has a notification policy is held, not sent, and reads `notification_held_at` on the incident. An incident that resolves while the service is snoozed is resolved without a notification, even one that was notified before the snooze started, and an incident whose trigger was held is resolved without one too: the team is not told that an earlier page cleared. A person’s acknowledge or resolve still notifies and clears the hold, snoozed or not. When the snooze ends, by its time or by `DELETE`, each incident still open whose notification was held is notified once at its current severity (the stored message, so it may read as lowered from a higher severity); one already acknowledged or resolved is cleared without a notification. That release is made by a sweep that runs every minute, so it can lag the end by up to a minute. A paused service may also be snoozed: the two are independent, and a snooze still live when the service is resumed holds whatever opens after it. Send `duration` (a whole number, at least 1) and `unit` (`minutes`, `hours` or `days`), counted from now: the total is 1 minute to 30 days, and more is refused with 422. Setting a snooze on a service that already has one replaces its end, so a second call extends or shortens it, and there is one snooze for each. `reason` is optional, plain text, at most 500 characters. A snooze takes effect from the next evaluation pass (up to a minute), so a notification can still go out in the pass that is running when you call, and likewise an end takes effect from the next pass. Needs the `alarms.edit` scope.

Needs the scope `alarms.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The UUID of the service.

### Body parameters

- `duration` (integer, required): How long the snooze lasts, a whole number of `unit`s, at least 1. The total is 1 minute to 30 days: at most 43200 `minutes`, 720 `hours` or 30 `days`.
- `unit` (string, required): The unit of `duration`: `minutes`, `hours` or `days`. Values:`minutes``hours``days`(an open set: new values may be added)
- `reason` (string or null): Why the alarms are snoozed, plain text, at most 500 characters; null or left out for none. It is shown to the team with the snooze.

### Returns

`200 OK`:

The service’s own snooze after the call: when it ends, its reason and when it was set.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**PUT /v1/services/{service_uuid}/alarm-snooze**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/alarm-snooze \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "duration": 1,
    "unit": "minutes"
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->setAlarmSnooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083', ['duration' => 1, 'unit' => 'minutes']);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.setAlarmSnooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083', { duration: 1, unit: 'minutes' });
```

Python:

```python
client = Client.from_environment()

result = client.services.set_alarm_snooze('6b8ec5a3-9417-480d-bff3-7f8faddb1083', duration=1, unit='minutes')
```

**Response (200 OK)**

```json
{
  "data": {
    "until": 1794214800000,
    "reason": "example",
    "set_at": 1794214800000
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the alarms.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Test service parameters

POST/v1/services/{service\_uuid}/parameters/test

Asks the service’s collector to test the saved parameters and returns the test as pending. Poll `GET /v1/services/{service_uuid}/parameters/test` for the results, which name each parameter and never carry a value.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`202 Accepted`:

The test, pending and without results.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/parameters/test**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/parameters/test \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->testParameters('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.testParameters('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.test_parameters('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (202 Accepted)**

```json
{
  "data": {
    "status": "example",
    "requested_at": 1794214800000,
    "completed_at": 1794214800000,
    "results": [
      {
        "name": "example",
        "found": true,
        "length": 1,
        "source": "example",
        "error": "example",
        "at": "example"
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Test a service definition

POST/v1/services/test-runs

Runs one check of a service definition that is not saved, from one live collector of its pool, and answers `202` with the test’s uuid. Poll `GET /v1/service-test-runs/{test_uuid}` for the result, which carries each check’s reason and observed numbers and never a value or a response snippet. The body is the create body; the same refusals apply, and one test is allowed every 30 seconds, 20 an hour per organisation.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Body parameters

- `name` (string, required): The service’s name, up to 255 characters.
- `check_interval_seconds` (integer or null): Seconds between two checks, from 60 to 86400 and at least the run budget rounded up to a whole minute; 60 when omitted on create.
- `notes` (string or null): Free-form notes about the service; null or omitted stores none.
- `active` (boolean or null): Whether monitoring is switched on; on when omitted.
- `tag_uuids` (array of strings or null): The uuids of the tags the service carries.
- `parameters` (array of strings or null): The parameter definitions the check reads (name, source, format and selector, never a value). Needs the `services.parameters` permission.
- `steps` (array of arrays, required): The service’s steps, 1 to 10, in order. Each step makes a request of any protocol (`http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`), verifies the answer with assertions, extracts values for later steps and decides what happens next. A single check is a one-step service. A step may carry `keep_evidence` (boolean): whether it keeps what its server answered as evidence, on for a new step; on an update, a step sent with its `uuid` and no `keep_evidence` keeps the stored value. The write-only parts of a step (header names and values, bodies, cookies, query strings, payloads, messages, metadata and every authentication field) are never returned.
- `variables` (array of strings or null): The values generated for each run (up to 10): `numeric`, `alphabetic`, `alphanumeric`, `uuid`, `timestamp`, `date`, `run_uuid` and `service_uuid`.
- `run` (array of strings or null): The whole run: `budget_seconds` (5 to 300; the sum of the steps’ own times when omitted) and `fast_retry` (`count` 0 to 3, `interval_ms` 0 to 60,000).
- `collectors` (object, required): The servers that run the check, chosen by hand or by tags. Required on create.
  - `selection` (string): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
  - `servers` (array of strings or null): The uuids of the servers to use, in order, with selection `servers`; at most 50.
  - `all` (array of strings or null): Servers must carry all of these tags, as tag UUIDs, with selection `tags`; at most 20.
  - `any` (array of strings or null): Servers must carry at least one of these tags, as tag UUIDs, with selection `tags`; at most 20.
- `pool_mode` (string or null): `active_standby` (one collector with a standby) or `all_members` (every collector in the pool reports). Values:`active_standby``all_members`(an open set: new values may be added)
- `member_limit` (integer or null): With `all_members`, the most collectors that report, from 1 to the pool limit; only valid in that mode.
- `quorum_n` (integer or null): With `all_members`, how many collectors must agree, from 1 and at most the member limit; only valid in that mode.

### Returns

`202 Accepted`:

The test, waiting for its collector.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/test-runs**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/test-runs \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "example",
    "steps": [
      [
        "example"
      ]
    ],
    "collectors": {}
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->testRunsStartNew(['name' => 'example', 'steps' => [['example']], 'collectors' => []]);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.testRunsStartNew({ name: 'example', steps: [['example']], collectors: {  } });
```

Python:

```python
client = Client.from_environment()

result = client.services.test_runs_start_new(name='example', steps=[['example']], collectors={})
```

**Response (202 Accepted)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "status": "example",
    "collector": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "requested_at": 1794214800000,
    "picked_up_at": 1794214800000,
    "completed_at": 1794214800000,
    "run": {
      "status": "example",
      "reason": "example",
      "refused_at": "example",
      "attempts": 1,
      "duration_ms": 1,
      "steps": [
        {
          "step_uuid": "370aa2dc-ab89-4c13-8494-981b72b7597d",
          "position": 1,
          "type": "example",
          "status": "example",
          "critical": true,
          "reason": "example",
          "attempts": 1,
          "duration_ms": 1,
          "observed": {},
          "assertions": [
            {}
          ],
          "extractions": [
            {}
          ],
          "response_shape": {},
          "evidence": {
            "attempt": 1,
            "of": 1,
            "answered": true,
            "withheld_reason": "example",
            "request": "example",
            "version": "example",
            "status": 1,
            "headers": [],
            "headers_omitted": 1,
            "body": "example",
            "body_bytes": 1,
            "body_kept": "example",
            "body_decompressed": true,
            "code": 1,
            "message": "example",
            "reply": "example",
            "reply_kept": "example",
            "reply_bytes": 1,
            "trailers": [],
            "trailers_omitted": 1,
            "message_kept": "example",
            "message_bytes": 1,
            "reply_encoding": "example",
            "records": [],
            "records_omitted": 1,
            "subject": "example",
            "issuer": "example",
            "names": [],
            "names_omitted": 1,
            "not_before": 1794214800000,
            "not_after": 1794214800000,
            "protocol": "example",
            "cipher": "example",
            "lines": [],
            "lines_omitted": 1
          },
          "evidence_dropped": "example",
          "evidence_hidden": true
        }
      ]
    },
    "result": {
      "reachability": {
        "is_reachable": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1
      },
      "response": {
        "is_up": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1,
        "http_status_code": 1,
        "status_match": true,
        "body_match": true,
        "content_type_match": true,
        "body_format_valid": true,
        "content_type": "example",
        "response_size_bytes": 1,
        "expected_http_statuses": [
          1
        ],
        "assertion_results": [
          {
            "select": "example",
            "comparison": "example",
            "value": "example",
            "passed": true,
            "reason": "example",
            "observed": "example",
            "observed_type": "example",
            "observed_length": 1
          }
        ],
        "smtp_step": "example",
        "smtp_reply_code": 1,
        "smtp_enhanced_status": "example"
      }
    }
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Test a saved service

POST/v1/services/{service\_uuid}/test-runs

Runs one check of the service with the definition sent, as `PUT /v1/services/{service_uuid}` would save it, from one live collector of its pool, and answers `202` with the test’s uuid. Nothing is saved. A stored secret that is not sent is used as saved. Poll `GET /v1/service-test-runs/{test_uuid}` for the result.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Body parameters

- `name` (string, required): The service’s name, up to 255 characters.
- `check_interval_seconds` (integer or null): Seconds between two checks, from 60 to 86400 and at least the timeout rounded up to a whole minute.
- `notes` (string or null): Free-form notes about the service; omit to keep the current notes, null clears them.
- `active` (boolean, required): Whether monitoring is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags the service carries.
- `parameters` (array of strings or null): The parameter definitions the check reads (name, source, format and selector, never a value). Needs the `services.parameters` permission.
- `steps` (array of arrays, required): The service’s steps, 1 to 10, in order. Each step makes a request of any protocol (`http`, `grpc`, `websocket`, `tcp`, `udp`, `icmp`, `dns`, `tls`, `smtp` or `wait`), verifies the answer with assertions, extracts values for later steps and decides what happens next. A single check is a one-step service. A step may carry `keep_evidence` (boolean): whether it keeps what its server answered as evidence, on for a new step; on an update, a step sent with its `uuid` and no `keep_evidence` keeps the stored value. The write-only parts of a step (header names and values, bodies, cookies, query strings, payloads, messages, metadata and every authentication field) are never returned.
- `variables` (array of strings or null): The values generated for each run (up to 10): `numeric`, `alphabetic`, `alphanumeric`, `uuid`, `timestamp`, `date`, `run_uuid` and `service_uuid`.
- `run` (array of strings or null): The whole run: `budget_seconds` (5 to 300; the sum of the steps’ own times when omitted) and `fast_retry` (`count` 0 to 3, `interval_ms` 0 to 60,000).
- `collectors` (object or null): The servers that run the check, chosen by hand or by tags; omit to leave the pool unchanged.
  - `selection` (string): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
  - `servers` (array of strings or null): The uuids of the servers to use, in order, with selection `servers`; at most 50.
  - `all` (array of strings or null): Servers must carry all of these tags, as tag UUIDs, with selection `tags`; at most 20.
  - `any` (array of strings or null): Servers must carry at least one of these tags, as tag UUIDs, with selection `tags`; at most 20.
- `pool_mode` (string or null): `active_standby` (one collector with a standby) or `all_members` (every collector in the pool reports). Values:`active_standby``all_members`(an open set: new values may be added)
- `member_limit` (integer or null): With `all_members`, the most collectors that report, from 1 to the pool limit; only valid in that mode.
- `quorum_n` (integer or null): With `all_members`, how many collectors must agree, from 1 and at most the member limit; only valid in that mode.

### Returns

`202 Accepted`:

The test, waiting for its collector.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/test-runs**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/test-runs \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "example",
    "active": true,
    "steps": [
      [
        "example"
      ]
    ]
  }'
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->testRunsStartSaved('6b8ec5a3-9417-480d-bff3-7f8faddb1083', ['name' => 'example', 'active' => true, 'steps' => [['example']]]);
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.testRunsStartSaved('6b8ec5a3-9417-480d-bff3-7f8faddb1083', { name: 'example', active: true, steps: [['example']] });
```

Python:

```python
client = Client.from_environment()

result = client.services.test_runs_start_saved('6b8ec5a3-9417-480d-bff3-7f8faddb1083', name='example', active=True, steps=[['example']])
```

**Response (202 Accepted)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "status": "example",
    "collector": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "requested_at": 1794214800000,
    "picked_up_at": 1794214800000,
    "completed_at": 1794214800000,
    "run": {
      "status": "example",
      "reason": "example",
      "refused_at": "example",
      "attempts": 1,
      "duration_ms": 1,
      "steps": [
        {
          "step_uuid": "370aa2dc-ab89-4c13-8494-981b72b7597d",
          "position": 1,
          "type": "example",
          "status": "example",
          "critical": true,
          "reason": "example",
          "attempts": 1,
          "duration_ms": 1,
          "observed": {},
          "assertions": [
            {}
          ],
          "extractions": [
            {}
          ],
          "response_shape": {},
          "evidence": {
            "attempt": 1,
            "of": 1,
            "answered": true,
            "withheld_reason": "example",
            "request": "example",
            "version": "example",
            "status": 1,
            "headers": [],
            "headers_omitted": 1,
            "body": "example",
            "body_bytes": 1,
            "body_kept": "example",
            "body_decompressed": true,
            "code": 1,
            "message": "example",
            "reply": "example",
            "reply_kept": "example",
            "reply_bytes": 1,
            "trailers": [],
            "trailers_omitted": 1,
            "message_kept": "example",
            "message_bytes": 1,
            "reply_encoding": "example",
            "records": [],
            "records_omitted": 1,
            "subject": "example",
            "issuer": "example",
            "names": [],
            "names_omitted": 1,
            "not_before": 1794214800000,
            "not_after": 1794214800000,
            "protocol": "example",
            "cipher": "example",
            "lines": [],
            "lines_omitted": 1
          },
          "evidence_dropped": "example",
          "evidence_hidden": true
        }
      ]
    },
    "result": {
      "reachability": {
        "is_reachable": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1
      },
      "response": {
        "is_up": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1,
        "http_status_code": 1,
        "status_match": true,
        "body_match": true,
        "content_type_match": true,
        "body_format_valid": true,
        "content_type": "example",
        "response_size_bytes": 1,
        "expected_http_statuses": [
          1
        ],
        "assertion_results": [
          {
            "select": "example",
            "comparison": "example",
            "value": "example",
            "passed": true,
            "reason": "example",
            "observed": "example",
            "observed_type": "example",
            "observed_length": 1
          }
        ],
        "smtp_step": "example",
        "smtp_reply_code": 1,
        "smtp_enhanced_status": "example"
      }
    }
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a service test

GET/v1/service-test-runs/{test\_uuid}

Returns one service test started by the same key’s user within the last hour: `waiting`, `picked_up`, `passed`, `failed` or `no_answer`, the collector that ran it and, once it ended, each check’s result. A result carries reasons and observed numbers, never a value, a resolved address or a response snippet.

Needs the scope `services.view`.

### Path parameters

- `test_uuid` (string (uuid), required): The uuid of the test run in the path, as answered when the test was started.

### Returns

`200 OK`:

The service test.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/service-test-runs/{test_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/service-test-runs/8f833e21-7a1a-4708-9c44-60ae80cc9fe0 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->testRunsView('8f833e21-7a1a-4708-9c44-60ae80cc9fe0');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.testRunsView('8f833e21-7a1a-4708-9c44-60ae80cc9fe0');
```

Python:

```python
client = Client.from_environment()

result = client.services.test_runs_view('8f833e21-7a1a-4708-9c44-60ae80cc9fe0')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "status": "example",
    "collector": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "requested_at": 1794214800000,
    "picked_up_at": 1794214800000,
    "completed_at": 1794214800000,
    "run": {
      "status": "example",
      "reason": "example",
      "refused_at": "example",
      "attempts": 1,
      "duration_ms": 1,
      "steps": [
        {
          "step_uuid": "370aa2dc-ab89-4c13-8494-981b72b7597d",
          "position": 1,
          "type": "example",
          "status": "example",
          "critical": true,
          "reason": "example",
          "attempts": 1,
          "duration_ms": 1,
          "observed": {},
          "assertions": [
            {}
          ],
          "extractions": [
            {}
          ],
          "response_shape": {},
          "evidence": {
            "attempt": 1,
            "of": 1,
            "answered": true,
            "withheld_reason": "example",
            "request": "example",
            "version": "example",
            "status": 1,
            "headers": [],
            "headers_omitted": 1,
            "body": "example",
            "body_bytes": 1,
            "body_kept": "example",
            "body_decompressed": true,
            "code": 1,
            "message": "example",
            "reply": "example",
            "reply_kept": "example",
            "reply_bytes": 1,
            "trailers": [],
            "trailers_omitted": 1,
            "message_kept": "example",
            "message_bytes": 1,
            "reply_encoding": "example",
            "records": [],
            "records_omitted": 1,
            "subject": "example",
            "issuer": "example",
            "names": [],
            "names_omitted": 1,
            "not_before": 1794214800000,
            "not_after": 1794214800000,
            "protocol": "example",
            "cipher": "example",
            "lines": [],
            "lines_omitted": 1
          },
          "evidence_dropped": "example",
          "evidence_hidden": true
        }
      ]
    },
    "result": {
      "reachability": {
        "is_reachable": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1
      },
      "response": {
        "is_up": true,
        "reason": "example",
        "error_message": "example",
        "response_time_ms": 1,
        "http_status_code": 1,
        "status_match": true,
        "body_match": true,
        "content_type_match": true,
        "body_format_valid": true,
        "content_type": "example",
        "response_size_bytes": 1,
        "expected_http_statuses": [
          1
        ],
        "assertion_results": [
          {
            "select": "example",
            "comparison": "example",
            "value": "example",
            "passed": true,
            "reason": "example",
            "observed": "example",
            "observed_type": "example",
            "observed_length": 1
          }
        ],
        "smtp_step": "example",
        "smtp_reply_code": 1,
        "smtp_enhanced_status": "example"
      }
    }
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Test a service's collectors

POST/v1/services/{service\_uuid}/verify

Asks every current candidate collector to probe the service now. A paused service, or one with no collectors chosen, has nobody to ask. Answers the service as the single-service read does.

Needs the scope `services.edit`.

### Headers

- `Idempotency-Key` (string): Any text of 1 to 255 visible ASCII characters. A repeat of the same request within 24 hours returns the first answer without running again (the response carries `Idempotent-Replayed: true`); the same key on a different request is refused 422 `invalid_request`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Returns

`200 OK`:

The service, with the probes requested.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**POST /v1/services/{service_uuid}/verify**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/verify \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->verify('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.verify('6b8ec5a3-9417-480d-bff3-7f8faddb1083');
```

Python:

```python
client = Client.from_environment()

result = client.services.verify('6b8ec5a3-9417-480d-bff3-7f8faddb1083')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {
      "budget_seconds": 1,
      "fast_retry": {
        "count": 1,
        "interval_ms": 1
      }
    },
    "live_version": 1,
    "check_interval_seconds": 1,
    "active": true,
    "status": "suspended",
    "health_status": "example",
    "collector_status": "example",
    "collector_status_reason": "example",
    "pool_mode": "example",
    "member_limit": 1,
    "quorum_n": 1,
    "collector_last_result_at": 1794214800000,
    "latest_reachability": {
      "is_reachable": true,
      "response_time_ms": 1,
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "latest_response": {
      "is_up": true,
      "http_status_code": 1,
      "status_match": true,
      "body_match": true,
      "response_time_ms": 1,
      "content_type": "example",
      "error_message": "example",
      "checked_at": 1794214800000
    },
    "alarm_snooze": {
      "until": 1794214800000,
      "reason": "example",
      "set_at": 1794214800000
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid; `errors` names the parameters.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## List a service's versions

GET/v1/services/{service\_uuid}/versions

Lists every saved version of a service, newest first. Every save of a service writes a version that is live at once; versions are kept for ever. A row says which version it is, when and by whom it was saved and how many steps it held; `services.versionsView` returns the definition. Pages by `page` and `per_page` (`limit` is the same as `per_page`); every page carries `current_page`, `per_page`, `last_page` and `total`.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.

### Query parameters

- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): How many items one page holds, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the service’s versions.

Each item of the page:

- `uuid` (string): The version’s uuid.
- `version` (integer): The version’s number: 1 for the first save, one more for each save after.
- `created_at` (integer or null): Epoch milliseconds. When the version was saved. An instant: epoch milliseconds, UTC.
- `created_by` (object or null): Who saved it; null when the system did (a conversion).
  - `name` (string or null): The display name of the person who saved the version.
- `step_count` (integer): How many steps the version held.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/versions**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/versions \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

foreach ($wt15->services->versions('6b8ec5a3-9417-480d-bff3-7f8faddb1083')->autoPaging() as $item) { echo $item->uuid, "\n"; }
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

for await (const item of wt15.services.versions('6b8ec5a3-9417-480d-bff3-7f8faddb1083')) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.services.versions('6b8ec5a3-9417-480d-bff3-7f8faddb1083'):
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "version": 1,
      "created_at": 1794214800000,
      "created_by": {
        "name": "example"
      },
      "step_count": 1
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a service version

GET/v1/services/{service\_uuid}/versions/{version\_uuid}

Returns one saved version of a service: its steps, variables and run as they were when that version was saved. Header names and values, bodies, cookies, query strings, payloads, messages, metadata and authentication fields are never returned.

Needs the scope `services.view`.

### Path parameters

- `service_uuid` (string (uuid), required): The uuid of the service.
- `version_uuid` (string (uuid), required): The uuid of the version, from `services.versions`; it must belong to the service.

### Returns

`200 OK`:

The version.

Each failure is a problem document with a stable `code`; the response panel's status selector shows each one this operation can answer, and [errors](https://developer.watchtower15.com/api/errors/) lists them all.

**GET /v1/services/{service_uuid}/versions/{version_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/services/6b8ec5a3-9417-480d-bff3-7f8faddb1083/versions/dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

```php
$wt15 = WatchTower15\Client::fromEnvironment();

$result = $wt15->services->versionsView('6b8ec5a3-9417-480d-bff3-7f8faddb1083', 'dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d');
```

Node.js:

```ts
const wt15 = WatchTower15.fromEnvironment();

const result = await wt15.services.versionsView('6b8ec5a3-9417-480d-bff3-7f8faddb1083', 'dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d');
```

Python:

```python
client = Client.from_environment()

result = client.services.versions_view('6b8ec5a3-9417-480d-bff3-7f8faddb1083', 'dfd2b1dc-ea76-4fbe-b1ce-14e96f81e69d')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "version": 1,
    "created_at": 1794214800000,
    "created_by": {
      "name": "example"
    },
    "name": "example",
    "steps": [
      {}
    ],
    "variables": [
      {}
    ],
    "run": {}
  }
}
```

**Response (401 Unauthorized)**

The API key is missing, malformed, expired or revoked.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/unauthorized/",
  "title": "Unauthorized",
  "status": 401,
  "code": "unauthorized",
  "detail": "The API key is missing, malformed, expired or revoked",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (403 Forbidden)**

The key or its owner does not hold what the operation needs.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the services.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

No such record in this organisation (an absent id and another organisation's answer alike).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/not_found/",
  "title": "Not found",
  "status": 404,
  "code": "not_found",
  "detail": "No record with that id exists in this organisation.",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (422 Unprocessable Content)**

The request is invalid (`invalid_request`; `errors` names the parameters).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/invalid_request/",
  "title": "Invalid request",
  "status": 422,
  "code": "invalid_request",
  "detail": "The request is invalid",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "errors": {
    "name": [
      "The name field is required."
    ]
  }
}
```

**Response (429 Too Many Requests)**

A rate limit or the organisation's daily limit is reached; `Retry-After` says when to retry.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/rate_limited/",
  "title": "Rate limited",
  "status": 429,
  "code": "rate_limited",
  "detail": "Too many requests: the limit is 240 a minute",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d",
  "limit": 60
}
```

**Response (500 Internal Server Error)**

An unexpected error.

```json
{
  "type": "https://docs.watchtower15.com/api/errors/internal_error/",
  "title": "Internal error",
  "status": 500,
  "code": "internal_error",
  "detail": "An unexpected error has happened",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

Source: https://developer.watchtower15.com/api/reference/services/
