# Alarms

Alarm rules and the alarms they raised.

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

**Endpoints**

- `POST/v1/alarms`
- `PUT/v1/alarms/{alarm_uuid}`
- `GET/v1/alarms/{alarm_uuid}`
- `GET/v1/alarms`
- `DELETE/v1/alarms/{alarm_uuid}`

## Create an alarm

POST/v1/alarms

Creates an alarm on a resource, named by `entity_type` and `entity_uuid`, from a catalogue rule named by `rule_slug` (read the catalogue with `GET /v1/alarm-rules`, narrowed by the resource’s sub-type, since the catalogue holds rules a resource of another sub-type does not support). Every other field is optional and falls back to the rule’s default. A second alarm on the same rule and resource is allowed, for two sensitivities of one metric. A resource holds at most 40 alarms, and an alarm that a profile left deleted still counts: it is refused with 422 when the resource is full. `active` and `alarm_policy_uuids` cannot be null; an empty `alarm_policy_uuids` means no policies.

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

### Body parameters

- `entity_type` (string, required): The type of resource the alarm is on; required. The same values `GET /v1/alarms` takes. Values:`domain``service``server``log_source``custom_metric``database_instance``server_port``server_system_service``server_volume`(an open set: new values may be added)
- `entity_uuid` (string (uuid), required): The uuid of the resource the alarm is on; required. A resource of another organisation answers 404.
- `rule_slug` (string, required): The slug of the catalogue rule the alarm is based on, from `GET /v1/alarm-rules`; required. A slug that does not exist for the entity type is refused.
- `name` (string or null): The alarm’s own name, up to 255 characters; it tells apart two alarms on one metric. Left out, the alarm takes its rule’s name.
- `aggregation` (string or null): How the readings in a window are combined before the comparison: `sum`, `count`, `avg`, `min`, `max` or `last`. Left out, the rule’s default applies. Values:`sum``count``avg``min``max``last`(an open set: new values may be added)
- `comparison_operator` (string or null): How a reading is compared with the thresholds: `lt`, `lte`, `gt`, `gte` or `eq`. Left out, the rule’s default applies. Values:`lt``lte``gt``gte``eq`(an open set: new values may be added)
- `warning_threshold` (number or null): The warning threshold, a number; negatives and fractions are allowed. Left out, the rule’s default applies.
- `critical_threshold` (number or null): The critical threshold, a number; negatives and fractions are allowed. A warning threshold past the critical one, in the direction the comparison goes, is refused. Left out, the rule’s default applies.
- `warning_window_minutes` (integer or null): The window, in minutes, the warning threshold is judged over, from 1 to 43200 (30 days). Left out, the rule’s default applies.
- `critical_window_minutes` (integer or null): The window, in minutes, the critical threshold is judged over, from 1 to 43200 (30 days). Left out, the rule’s default applies.
- `warning_consecutive_failures_count` (integer or null): Consecutive evaluations before a warning, from 1 to 100. Left out, the rule’s default applies.
- `critical_consecutive_failures_count` (integer or null): Consecutive evaluations before a critical, from 1 to 100; a warning count above it is refused. Left out, the rule’s default applies.
- `active` (boolean): Whether the alarm starts switched on; `true` when left out. `null` is refused.
- `notify_on_acknowledge` (boolean or null): Whether acknowledging an incident of the alarm notifies. Left out, the catalogue rule’s flag applies.
- `notify_on_resolve` (boolean or null): Whether resolving an incident of the alarm notifies. Left out, the catalogue rule’s flag applies.
- `alarm_policy_uuids` (array of strings): The alarm policies the alarm notifies; an empty list or none means no policies, and `null` is refused. Each uuid is a policy of this organisation.

### Returns

`201 Created`:

The created alarm.

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/alarms**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/alarms \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "entity_type": "domain",
    "entity_uuid": "902fa808-814e-4157-af4a-f81e03dd5d21",
    "rule_slug": "example"
  }'
```

PHP:

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

$result = $wt15->alarms->create([
    'entity_type' => 'domain',
    'entity_uuid' => '902fa808-814e-4157-af4a-f81e03dd5d21',
    'rule_slug' => 'example',
]);
```

Node.js:

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

const result = await wt15.alarms.create({
  entity_type: 'domain',
  entity_uuid: '902fa808-814e-4157-af4a-f81e03dd5d21',
  rule_slug: 'example',
});
```

Python:

```python
client = Client.from_environment()

result = client.alarms.create(entity_type='domain', entity_uuid='902fa808-814e-4157-af4a-f81e03dd5d21', rule_slug='example')
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "rule_slug": "example",
    "classification": "example",
    "metric_name": "example",
    "description": "example",
    "alarm_type": "example",
    "unit": "example",
    "comparison_operator": "example",
    "aggregation": "example",
    "warning_threshold": 0,
    "critical_threshold": 0,
    "warning_window_minutes": 1,
    "critical_window_minutes": 1,
    "warning_consecutive_failures_count": 1,
    "critical_consecutive_failures_count": 1,
    "self_resolving": true,
    "active": true,
    "notify_on_acknowledge": true,
    "notify_on_resolve": true,
    "entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "parent_entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b"
    },
    "alarm_policies": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "state": "critical",
    "inactive_reason": "example",
    "state_since": 1794214800000,
    "acknowledged": 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 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"
}
```

## Update an alarm

PUT/v1/alarms/{alarm\_uuid}

Changes the fields sent; what is not sent keeps its value. `active: false` switches the alarm off and resolves its open incidents at once; `active: true` switches it back on. A `null` returns a threshold, window, consecutive count, `aggregation` or `comparison_operator` to the catalogue rule’s default, `name` to the rule’s name and a notify flag to the catalogue’s; `active` and `alarm_policy_uuids` cannot be null, and `alarm_policy_uuids: []` clears the policies. `alarm_policy_uuids`, when sent, replaces the list. Thresholds out of order are refused with 422. Editing an alarm that came from a profile template makes it overridden, so a later propagation of the template leaves it alone: an alarm switched off here is no longer changed by its profile. An alarm that was deleted answers 404.

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

- `alarm_uuid` (string (uuid), required): The uuid of the alarm in the path. A soft-deleted alarm and a deleted inherited alarm’s tombstone answer 404.

### Body parameters

- `name` (string or null): The alarm’s own name, up to 255 characters; it tells apart two alarms on one metric. Send `null` to return it to the catalogue rule’s name.
- `aggregation` (string or null): How the readings in a window are combined before the comparison: `sum`, `count`, `avg`, `min`, `max` or `last`. Send `null` to return it to the rule’s default. Values:`sum``count``avg``min``max``last`(an open set: new values may be added)
- `comparison_operator` (string or null): How a reading is compared with the thresholds: `lt`, `lte`, `gt`, `gte` or `eq`. Send `null` to return it to the rule’s default. Values:`lt``lte``gt``gte``eq`(an open set: new values may be added)
- `warning_threshold` (number or null): The warning threshold, a number; negatives and fractions are allowed. Send `null` to return it to the rule’s default.
- `critical_threshold` (number or null): The critical threshold, a number; negatives and fractions are allowed. A warning threshold past the critical one, in the direction the comparison goes, is refused. Send `null` to return it to the rule’s default.
- `warning_window_minutes` (integer or null): The window, in minutes, the warning threshold is judged over, from 1 to 43200 (30 days). Send `null` to return it to the rule’s default.
- `critical_window_minutes` (integer or null): The window, in minutes, the critical threshold is judged over, from 1 to 43200 (30 days). Send `null` to return it to the rule’s default.
- `warning_consecutive_failures_count` (integer or null): Consecutive evaluations before a warning, from 1 to 100. Send `null` to return it to the rule’s default.
- `critical_consecutive_failures_count` (integer or null): Consecutive evaluations before a critical, from 1 to 100; a warning count above it is refused. Send `null` to return it to the rule’s default.
- `active` (boolean): Whether the alarm is switched on. `false` switches it off and resolves its open incidents at once; `null` is refused. An alarm that came from a profile template becomes `overridden` when it is edited, so a later propagation leaves it alone.
- `notify_on_acknowledge` (boolean or null): Whether acknowledging an incident of the alarm notifies. Send `null` to return it to the catalogue rule’s flag.
- `notify_on_resolve` (boolean or null): Whether resolving an incident of the alarm notifies. Send `null` to return it to the catalogue rule’s flag.
- `alarm_policy_uuids` (array of strings): The alarm policies the alarm notifies, a full replacement of the saved ones; `[]` detaches every policy and `null` is refused. Each uuid is a policy of this organisation.

### Returns

`200 OK`:

The alarm after the change.

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/alarms/{alarm_uuid}**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/alarms/e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->alarms->update('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Node.js:

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

const result = await wt15.alarms.update('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Python:

```python
client = Client.from_environment()

result = client.alarms.update('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "rule_slug": "example",
    "classification": "example",
    "metric_name": "example",
    "description": "example",
    "alarm_type": "example",
    "unit": "example",
    "comparison_operator": "example",
    "aggregation": "example",
    "warning_threshold": 0,
    "critical_threshold": 0,
    "warning_window_minutes": 1,
    "critical_window_minutes": 1,
    "warning_consecutive_failures_count": 1,
    "critical_consecutive_failures_count": 1,
    "self_resolving": true,
    "active": true,
    "notify_on_acknowledge": true,
    "notify_on_resolve": true,
    "entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "parent_entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b"
    },
    "alarm_policies": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "state": "critical",
    "inactive_reason": "example",
    "state_since": 1794214800000,
    "acknowledged": 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 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"
}
```

## Get one alarm

GET/v1/alarms/{alarm\_uuid}

Returns one alarm by its uuid, as the alarm list gives it: its thresholds, live state, resource and the policies it notifies. An alarm that was deleted answers 404, whether it was removed or left as a tombstone by a profile.

Needs the scope `alarms.view`.

### Path parameters

- `alarm_uuid` (string (uuid), required): The uuid of the alarm in the path. A soft-deleted alarm and a deleted inherited alarm’s tombstone answer 404.

### Returns

`200 OK`:

The alarm.

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/alarms/{alarm_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/alarms/e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->alarms->view('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Node.js:

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

const result = await wt15.alarms.view('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Python:

```python
client = Client.from_environment()

result = client.alarms.view('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "rule_slug": "example",
    "classification": "example",
    "metric_name": "example",
    "description": "example",
    "alarm_type": "example",
    "unit": "example",
    "comparison_operator": "example",
    "aggregation": "example",
    "warning_threshold": 0,
    "critical_threshold": 0,
    "warning_window_minutes": 1,
    "critical_window_minutes": 1,
    "warning_consecutive_failures_count": 1,
    "critical_consecutive_failures_count": 1,
    "self_resolving": true,
    "active": true,
    "notify_on_acknowledge": true,
    "notify_on_resolve": true,
    "entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "parent_entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b"
    },
    "alarm_policies": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "state": "critical",
    "inactive_reason": "example",
    "state_since": 1794214800000,
    "acknowledged": 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 alarms.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 alarms of a resource

GET/v1/alarms

Lists the alarms set on one resource, named by `entity_type` and `entity_uuid`, both required, with each alarm’s thresholds and live state. The state and the time it began are read from the alarm’s open incident, if any. For every alarm of the organisation in one call use `GET /v1/organisation/alarms`; for a server with its volumes, ports and units, `GET /v1/servers/{server_uuid}/alarms`. 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 `alarms.view`.

### Query parameters

- `entity_type` (string, required): The type of resource whose alarms are listed; required. Values:`domain``service``server``log_source``custom_metric``database_instance``server_port``server_system_service``server_volume`(an open set: new values may be added)
- `entity_uuid` (string (uuid), required): The uuid of the resource whose alarms are listed; required.
- `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 alarms to return in one page, from 1 to 100.
- `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 resource’s alarms.

Each item of the page:

- `uuid` (string): The alarm’s uuid.
- `name` (string): The alarm’s own name, else its rule’s.
- `rule_slug` (string): The catalogue rule’s slug.
- `classification` (string): The catalogue rule’s classification: one of `operations`, `security`, `monitoring`. On a server it decides which of the server’s three healths an open incident moves; the other resources keep one health that counts every classification.
- `metric_name` (string): The catalogue rule’s name.
- `description` (string or null): The catalogue rule’s description; null when it has none.
- `alarm_type` (string or null): `boolean` or `threshold`, as the catalogue rule says.
- `unit` (string or null): The unit of the thresholds; null when the rule has none.
- `comparison_operator` (string): How a reading is compared with the thresholds: the alarm’s own operator, else the rule’s default.
- `aggregation` (string or null): How the readings in a window are combined before the comparison; null when the alarm sets none.
- `warning_threshold` (number or null): The alarm’s own value, else the rule’s default.
- `critical_threshold` (number or null): The alarm’s own value, else the rule’s default.
- `warning_window_minutes` (integer or null): The window, in minutes, the warning threshold is judged over; null when the alarm has none.
- `critical_window_minutes` (integer or null): The window, in minutes, the critical threshold is judged over; null when the alarm has none.
- `warning_consecutive_failures_count` (integer): Consecutive evaluations before a warning: the alarm’s own count, else the rule’s default.
- `critical_consecutive_failures_count` (integer): Consecutive evaluations before a critical: the alarm’s own count, else the rule’s default.
- `self_resolving` (boolean): Whether the alarm clears itself when the condition ends (it sends no resolve notification).
- `active` (boolean): Whether the alarm is switched on.
- `notify_on_acknowledge` (boolean): Whether acknowledging an incident of this alarm notifies: the alarm’s own flag, else the catalogue’s. Never null.
- `notify_on_resolve` (boolean): Whether resolving an incident of this alarm notifies: the alarm’s own flag, else the catalogue’s. Never null.
- `entity` (object): The resource the alarm is on, of any type that has alarms.
  - `type` (string): The type of the resource, such as `server`.
  - `uuid` (string or null): The uuid of the resource; null when it no longer resolves.
  - `name` (string or null): The name of the resource; null when it no longer resolves.
- `parent_entity` (object or null): The server of a volume, port or unit; null for every other resource.
  - `type` (string): The type of the server, such as `server`.
  - `uuid` (string): The uuid of the server.
- `alarm_policies` (array of objects): The policies the alarm notifies. A caller holding `policies.view` (the key’s scope and the user’s permission) gets each policy’s `name`; without it, the uuid alone.
  - `uuid` (string): The policy’s uuid.
  - `name` (string): The policy’s name; present only for a caller holding `policies.view`.
- `state` (string): One of `ok`, `warning`, `critical`, `inactive`. Values:`critical``warning``ok``inactive`(an open set: new values may be added)
- `inactive_reason` (string or null): `switched_off` or `resource_inactive` while `state` is `inactive`; null otherwise.
- `state_since` (integer or null): Epoch milliseconds: when the open incident was triggered, while `state` is `warning` or `critical`; null otherwise. An instant: epoch milliseconds, UTC.
- `acknowledged` (boolean): Whether the open incident has been acknowledged.

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/alarms**

curl:

```bash
curl -G https://rest.watchtower15.com/v1/alarms \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -d entity_type=domain \
  -d entity_uuid=902fa808-814e-4157-af4a-f81e03dd5d21
```

PHP:

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

foreach ($wt15->alarms->list([
    'entity_type' => 'domain',
    'entity_uuid' => '902fa808-814e-4157-af4a-f81e03dd5d21',
])->autoPaging() as $item) { echo $item->uuid, "\n"; }
```

Node.js:

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

for await (const item of wt15.alarms.list({ entity_type: 'domain', entity_uuid: '902fa808-814e-4157-af4a-f81e03dd5d21' })) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.alarms.list(entity_type='domain', entity_uuid='902fa808-814e-4157-af4a-f81e03dd5d21'):
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "rule_slug": "example",
      "classification": "example",
      "metric_name": "example",
      "description": "example",
      "alarm_type": "example",
      "unit": "example",
      "comparison_operator": "example",
      "aggregation": "example",
      "warning_threshold": 0,
      "critical_threshold": 0,
      "warning_window_minutes": 1,
      "critical_window_minutes": 1,
      "warning_consecutive_failures_count": 1,
      "critical_consecutive_failures_count": 1,
      "self_resolving": true,
      "active": true,
      "notify_on_acknowledge": true,
      "notify_on_resolve": true,
      "entity": {
        "type": "example",
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      },
      "parent_entity": {
        "type": "example",
        "uuid": "75666699-b77d-4631-b576-041e8102a55b"
      },
      "alarm_policies": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "state": "critical",
      "inactive_reason": "example",
      "state_since": 1794214800000,
      "acknowledged": true
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1,
  "meta": {
    "entity": {
      "type": "example",
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "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 alarms.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 an alarm

DELETE/v1/alarms/{alarm\_uuid}

Deletes an alarm. Its open incidents resolve silently and its incident history stays. A deleted alarm does not come back by itself: not when its profile propagates its templates and not at the next deploy. To keep an alarm and turn it back on later, switch it off with `PUT /v1/alarms/{alarm_uuid}` instead. A second delete answers 404.

Needs the scope `alarms.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

- `alarm_uuid` (string (uuid), required): The uuid of the alarm in the path. A soft-deleted alarm and a deleted inherited alarm’s tombstone answer 404.

### Returns

`204 No Content`:

Nothing: the answer is 204.

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/alarms/{alarm_uuid}**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/alarms/e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$wt15->alarms->delete('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Node.js:

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

await wt15.alarms.delete('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75');
```

Python:

```python
client = Client.from_environment()

client.alarms.delete('e3dec13b-3b7d-46bc-a5f3-e122d2ad3a75')
```

**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.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"
}
```

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