# Custom metrics

Custom metrics the organisation sends itself: their definitions, series and limits.

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

**Endpoints**

- `POST/v1/custom-metrics`
- `PUT/v1/custom-metrics/{custom_metric_uuid}`
- `GET/v1/custom-metrics/{custom_metric_uuid}`
- `GET/v1/custom-metrics`
- `DELETE/v1/custom-metrics/{custom_metric_uuid}`
- `POST/v1/custom-metrics/{custom_metric_uuid}/approve`
- `POST/v1/custom-metrics/{custom_metric_uuid}/discard`
- `POST/v1/custom-metrics/{custom_metric_uuid}/reset-series`
- `GET/v1/custom-metrics/{custom_metric_uuid}/samples`
- `GET/v1/custom-metrics/{custom_metric_uuid}/series`
- `GET/v1/custom-metrics/{custom_metric_uuid}/summary`

## The Custom metric object

### Attributes

- `uuid` (string): The metric’s uuid.
- `name` (string): The metric’s name.
- `description` (string or null): The metric’s description; null for none.
- `metric_key` (string): The key a publisher sends the metric under.
- `metric_type` (string): `count` sums events per step, `level` is a gauge.
- `unit` (string or null): The unit the metric’s values are measured in; null for none.
- `supported_aggregations` (array of strings): The aggregations an alarm on this metric may use, from its type.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`. `unknown` covers both a metric with no alarm and one whose alarms are not yet evaluated; `alarms_count` tells them apart.
- `alarms_count` (integer): The metric’s alarms, switched on or off: what `GET /v1/alarms` lists for it.
- `last_received_at` (integer or null): Epoch milliseconds. When a point last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `active` (boolean): Whether the metric is switched on.
- `approved_at` (integer or null): Epoch milliseconds. When the organisation accepted the metric; null while it awaits approval, when no points are stored. An instant: epoch milliseconds, UTC.
- `auto_created` (boolean): Whether it appeared from a push rather than being declared.
- `deactivated_at` (integer or null): Epoch milliseconds. When the metric was switched off; null while it is on. An instant: epoch milliseconds, UTC.
- `max_points_per_day` (integer): Points accepted a day on the live tier, the limit in force.
- `max_backfill_points_per_day` (integer): Points accepted a day on the backfill tier, the limit in force.
- `backfill_tier_days` (integer): How many days old a point must be to count against the backfill allowance.
- `retention_days` (integer): How many days the samples are kept.
- `linked_servers` (array of objects or null): The servers the metric is linked to directly; null without `servers.view`, the count kept.
  - `uuid` (string): The server’s uuid.
  - `name` (string): The server’s name.
- `linked_servers_count` (integer): How many servers the metric is linked to directly; given even when `linked_servers` is null.
- `linked_server_all_tags` (array of objects): Servers must carry ALL of these tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
  - `group` (string or null): The name of the tag’s group; null for a tag in no group.
- `linked_server_any_tags` (array of objects): Servers must carry ANY of these tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
  - `group` (string or null): The name of the tag’s group; null for a tag in no group.
- `metric_source` (object or null): The source the metric belongs to; null for none.
  - `uuid` (string): The source’s uuid.
  - `name` (string): The source’s name.
- `tags` (array of objects): The metric’s own tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
- `created_at` (integer or null): Epoch milliseconds. When the metric was created. An instant: epoch milliseconds, UTC.
- `console_url` (string): The metric’s page in the console.

**The Custom metric object**

```json
{
  "uuid": "75666699-b77d-4631-b576-041e8102a55b",
  "name": "example",
  "description": "example",
  "metric_key": "example",
  "metric_type": "example",
  "unit": "example",
  "supported_aggregations": [
    "example"
  ],
  "health_status": "example",
  "alarms_count": 1,
  "last_received_at": 1794214800000,
  "active": true,
  "approved_at": 1794214800000,
  "auto_created": true,
  "deactivated_at": 1794214800000,
  "max_points_per_day": 1,
  "max_backfill_points_per_day": 1,
  "backfill_tier_days": 1,
  "retention_days": 1,
  "linked_servers": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    }
  ],
  "linked_servers_count": 1,
  "linked_server_all_tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "group": "example"
    }
  ],
  "linked_server_any_tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "group": "example"
    }
  ],
  "metric_source": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example"
  },
  "tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    }
  ],
  "created_at": 1794214800000,
  "console_url": "example"
}
```

## Create a custom metric

POST/v1/custom-metrics

Declares a custom metric under a key, in one of the organisation’s metric sources. The key and the source are set here and never change. The metric counts against the organisation’s metric limit, and the call is refused when the plan does not allow it.

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

- `metric_key` (string, required): The key a publisher sends the metric under; required, and fixed once the metric exists.
- `name` (string or null): The metric’s display name.
- `description` (string or null): A description of the metric, up to 2000 characters; null for none.
- `unit` (string or null): The unit the metric’s values are measured in, a free display string such as `files`, `%` or `orders`; null for none.
- `metric_type` (string or null): How a point is read: `count` sums events per step, `level` is a gauge. Values:`count``level`(an open set: new values may be added)
- `metric_source_uuid` (string (uuid), required): The source the metric belongs to.
- `max_points_per_day` (integer or null): Points accepted a day on the live tier, as the metric’s own limit; the ceiling stated, 86,400,000 points a day, is the platform default and an organisation’s override may differ.
- `max_backfill_points_per_day` (integer or null): Points accepted a day on the backfill tier, as the metric’s own limit; the ceiling stated, 86,400,000 points a day, is the platform default and an organisation’s override may differ.
- `active` (boolean or null): Whether the metric is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags to put on the metric.
- `linked_server_uuids` (array of strings or null): The uuids of the servers the metric is shown on, at most 100; an empty list clears them and omitting the key keeps them.
- `linked_server_all_tag_uuids` (array of strings or null): The uuids of server tags a server must ALL carry for the metric to be shown on it, at most 20; an empty list clears them and omitting the key keeps them.
- `linked_server_any_tag_uuids` (array of strings or null): The uuids of server tags a server must carry at least ONE of for the metric to be shown on it, at most 20; an empty list clears them and omitting the key keeps them.

### Returns

`201 Created`:

The created custom metric.

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/custom-metrics**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/custom-metrics \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "metric_key": "example",
    "metric_source_uuid": "03eb8c34-ff18-4b02-987d-6231f5dcdb38"
  }'
```

PHP:

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

$customMetric = $wt15->customMetrics->create([
    'metric_key' => 'example',
    'metric_source_uuid' => '03eb8c34-ff18-4b02-987d-6231f5dcdb38',
]);
```

Node.js:

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

const result = await wt15.customMetrics.create({
  metric_key: 'example',
  metric_source_uuid: '03eb8c34-ff18-4b02-987d-6231f5dcdb38',
});
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.create(metric_key='example', metric_source_uuid='03eb8c34-ff18-4b02-987d-6231f5dcdb38')
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "metric_key": "example",
    "metric_type": "example",
    "unit": "example",
    "supported_aggregations": [
      "example"
    ],
    "health_status": "example",
    "alarms_count": 1,
    "last_received_at": 1794214800000,
    "active": true,
    "approved_at": 1794214800000,
    "auto_created": true,
    "deactivated_at": 1794214800000,
    "max_points_per_day": 1,
    "max_backfill_points_per_day": 1,
    "backfill_tier_days": 1,
    "retention_days": 1,
    "linked_servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "linked_servers_count": 1,
    "linked_server_all_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "linked_server_any_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "metric_source": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "created_at": 1794214800000,
    "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 custom_metrics.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 custom metric

PUT/v1/custom-metrics/{custom\_metric\_uuid}

Changes the fields sent: name, description, unit, type, per-day point limits, whether it is switched on, tags and linked servers. A limit equal to the one in force is not stored, so the metric keeps following the organisation’s. A metric awaiting approval cannot be switched on or off.

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

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Body parameters

- `name` (string or null): The metric’s display name.
- `description` (string or null): A description of the metric, up to 2000 characters; null for none.
- `unit` (string or null): The unit the metric’s values are measured in, a free display string such as `files`, `%` or `orders`; null for none.
- `metric_type` (string or null): How a point is read: `count` sums events per step, `level` is a gauge. Values:`count``level`(an open set: new values may be added)
- `max_points_per_day` (integer or null): Points accepted a day on the live tier, as the metric’s own limit; the ceiling stated, 86,400,000 points a day, is the platform default and an organisation’s override may differ.
- `max_backfill_points_per_day` (integer or null): Points accepted a day on the backfill tier, as the metric’s own limit; the ceiling stated, 86,400,000 points a day, is the platform default and an organisation’s override may differ.
- `active` (boolean or null): Whether the metric is switched on.
- `tag_uuids` (array of strings or null): The uuids of the tags to put on the metric.
- `linked_server_uuids` (array of strings or null): The uuids of the servers the metric is shown on, at most 100; an empty list clears them and omitting the key keeps them.
- `linked_server_all_tag_uuids` (array of strings or null): The uuids of server tags a server must ALL carry for the metric to be shown on it, at most 20; an empty list clears them and omitting the key keeps them.
- `linked_server_any_tag_uuids` (array of strings or null): The uuids of server tags a server must carry at least ONE of for the metric to be shown on it, at most 20; an empty list clears them and omitting the key keeps them.

### Returns

`200 OK`:

The custom metric 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/custom-metrics/{custom_metric_uuid}**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$customMetric = $wt15->customMetrics->update('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.update('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.update('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "metric_key": "example",
    "metric_type": "example",
    "unit": "example",
    "supported_aggregations": [
      "example"
    ],
    "health_status": "example",
    "alarms_count": 1,
    "last_received_at": 1794214800000,
    "active": true,
    "approved_at": 1794214800000,
    "auto_created": true,
    "deactivated_at": 1794214800000,
    "max_points_per_day": 1,
    "max_backfill_points_per_day": 1,
    "backfill_tier_days": 1,
    "retention_days": 1,
    "linked_servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "linked_servers_count": 1,
    "linked_server_all_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "linked_server_any_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "metric_source": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "created_at": 1794214800000,
    "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 custom_metrics.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 custom metric

GET/v1/custom-metrics/{custom\_metric\_uuid}

Returns one custom metric with its source, tags, linked servers and the limits in force. Linked server names are given only to a key holding `servers.view`; without it `linked_servers` is null and the count is kept.

Needs the scope `custom_metrics.view`.

### Path parameters

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Returns

`200 OK`:

The custom metric.

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/custom-metrics/{custom_metric_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8 \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$customMetric = $wt15->customMetrics->view('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.view('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.view('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "metric_key": "example",
    "metric_type": "example",
    "unit": "example",
    "supported_aggregations": [
      "example"
    ],
    "health_status": "example",
    "alarms_count": 1,
    "last_received_at": 1794214800000,
    "active": true,
    "approved_at": 1794214800000,
    "auto_created": true,
    "deactivated_at": 1794214800000,
    "max_points_per_day": 1,
    "max_backfill_points_per_day": 1,
    "backfill_tier_days": 1,
    "retention_days": 1,
    "linked_servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "linked_servers_count": 1,
    "linked_server_all_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "linked_server_any_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "metric_source": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "created_at": 1794214800000,
    "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 custom_metrics.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 custom metrics

GET/v1/custom-metrics

Returns the organisation’s custom metrics, filtered by name or key, health, type, source and tags, and sorted as asked. `alarms_count` says which metrics carry 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 `custom_metrics.view`.

### Query parameters

- `search` (string or null): Matches the metric’s name or key.
- `health` (array of strings or null): Only metrics in one of these health states: `unknown`, `healthy`, `warning` or `critical`. A list: repeat the parameter (`health=unknown&health=healthy`) or send one value (`health=unknown`); `health[]=unknown` is accepted too. Values:`unknown``healthy``warning``critical`(an open set: new values may be added)
- `metric_type` (array of strings or null): Only metrics of one of these types: `count` or `level`. A list: repeat the parameter (`metric_type=count&metric_type=level`) or send one value (`metric_type=count`); `metric_type[]=count` is accepted too. Values:`count``level`(an open set: new values may be added)
- `metric_source_uuids` (array of strings or null): Only metrics that belong to one of these sources, by uuid. A list: repeat the parameter (`metric_source_uuids=<uuid>&metric_source_uuids=<uuid>`) or send one value (`metric_source_uuids=<uuid>`); `metric_source_uuids[]=<uuid>` is accepted too.
- `tag_uuids` (array of strings or null): Only metrics carrying one of these tags, by uuid. 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 field to order by: `name`, `metric_key`, `last_received_at` or `health_status`. Values:`name``metric_key``last_received_at``health_status`(an open set: new values may be added)
- `direction` (string or null): The sort direction: `asc` 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): The page size, 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 organisation’s custom metrics.

Each item of the page:

- `uuid` (string): The metric’s uuid.
- `name` (string): The metric’s name.
- `metric_key` (string): The key a publisher sends the metric under.
- `metric_type` (string): `count` sums events per step, `level` is a gauge.
- `unit` (string or null): The unit the metric’s values are measured in; null for none.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`. `unknown` covers both a metric with no alarm and one whose alarms are not yet evaluated; `alarms_count` tells them apart.
- `alarms_count` (integer): The metric’s alarms, switched on or off: what `GET /v1/alarms` lists for it.
- `last_received_at` (integer or null): Epoch milliseconds. When a point last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `active` (boolean): Whether the metric is switched on.
- `approved_at` (integer or null): Epoch milliseconds. When the organisation accepted the metric; null while it awaits approval, when no points are stored. An instant: epoch milliseconds, UTC.
- `auto_created` (boolean): Whether it appeared from a push rather than being declared.
- `metric_source` (object or null): The source the metric belongs to; null for none.
  - `uuid` (string): The source’s uuid.
  - `name` (string): The source’s name.
- `tags` (array of objects): The metric’s own tags.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
- `console_url` (string): The metric’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/custom-metrics**

curl:

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

PHP:

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

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

Node.js:

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

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

Python:

```python
client = Client.from_environment()

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

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "metric_key": "example",
      "metric_type": "example",
      "unit": "example",
      "health_status": "example",
      "alarms_count": 1,
      "last_received_at": 1794214800000,
      "active": true,
      "approved_at": 1794214800000,
      "auto_created": true,
      "metric_source": {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      },
      "tags": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "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 custom_metrics.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 custom metric

DELETE/v1/custom-metrics/{custom\_metric\_uuid}

Deletes the custom metric and resolves its open incidents. The answer has no body.

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

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Returns

`204 No Content`:

The custom metric 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/custom-metrics/{custom_metric_uuid}**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8 \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$wt15->customMetrics->delete('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

await wt15.customMetrics.delete('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

client.custom_metrics.delete('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

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

## Approve a custom metric

POST/v1/custom-metrics/{custom\_metric\_uuid}/approve

Accepts a metric that appeared from a push, so that its points are stored from then on. The call is refused when the plan does not allow it or the organisation’s metric limit is reached.

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

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Returns

`200 OK`:

The approved custom metric.

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/custom-metrics/{custom_metric_uuid}/approve**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/approve \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->customMetrics->approve('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.approve('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.approve('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "metric_key": "example",
    "metric_type": "example",
    "unit": "example",
    "supported_aggregations": [
      "example"
    ],
    "health_status": "example",
    "alarms_count": 1,
    "last_received_at": 1794214800000,
    "active": true,
    "approved_at": 1794214800000,
    "auto_created": true,
    "deactivated_at": 1794214800000,
    "max_points_per_day": 1,
    "max_backfill_points_per_day": 1,
    "backfill_tier_days": 1,
    "retention_days": 1,
    "linked_servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "linked_servers_count": 1,
    "linked_server_all_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "linked_server_any_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "metric_source": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "created_at": 1794214800000,
    "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 custom_metrics.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"
}
```

## Discard a custom metric

POST/v1/custom-metrics/{custom\_metric\_uuid}/discard

Permanently deletes a metric that still awaits approval, which never stored any points. The answer has no body.

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

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Returns

`204 No Content`:

The custom metric was discarded; 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.

**POST /v1/custom-metrics/{custom_metric_uuid}/discard**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/discard \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$wt15->customMetrics->discard('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

await wt15.customMetrics.discard('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

client.custom_metrics.discard('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

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

## Reset a custom metric's series

POST/v1/custom-metrics/{custom\_metric\_uuid}/reset-series

Deletes all stored points of an approved metric from the metrics store before answering; the metric itself stays. A metric awaiting approval is refused.

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

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### Returns

`200 OK`:

The custom metric after its points were deleted.

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/custom-metrics/{custom_metric_uuid}/reset-series**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/reset-series \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->customMetrics->resetSeries('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.resetSeries('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.reset_series('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "metric_key": "example",
    "metric_type": "example",
    "unit": "example",
    "supported_aggregations": [
      "example"
    ],
    "health_status": "example",
    "alarms_count": 1,
    "last_received_at": 1794214800000,
    "active": true,
    "approved_at": 1794214800000,
    "auto_created": true,
    "deactivated_at": 1794214800000,
    "max_points_per_day": 1,
    "max_backfill_points_per_day": 1,
    "backfill_tier_days": 1,
    "retention_days": 1,
    "linked_servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "linked_servers_count": 1,
    "linked_server_all_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "linked_server_any_tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example",
        "group": "example"
      }
    ],
    "metric_source": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    },
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "created_at": 1794214800000,
    "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 custom_metrics.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"
}
```

## Get a custom metric's raw samples

GET/v1/custom-metrics/{custom\_metric\_uuid}/samples

Returns each value pushed for the metric with its own time in epoch milliseconds, oldest first, over a window that defaults to the last hour and spans at most one day. Two samples at one time are both returned. Pages hold up to `per_page` samples (`limit` is the same; 1,000 by default, at most 10,000); pass `next_cursor` back as `cursor` for the next page, which keeps the first page’s window. Each page first counts the samples left in its window: more than 100,000 is refused with 422 naming the count, and so is a window the store refuses for its own sample limit; ask for a shorter window. A metric awaiting approval stores no samples, so the answer is `available: false` with `reason: awaiting_approval` and no samples.

Needs the scope `custom_metrics.view`.

### Path parameters

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### 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.
- `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): The number of samples in a page, from 1 to 10,000; 1,000 when omitted.

### Returns

`200 OK`:

One page of the metric’s raw samples.

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/custom-metrics/{custom_metric_uuid}/samples**

curl:

```bash
curl https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/samples \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->customMetrics->samples('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.samples('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.samples('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "available": true,
    "reason": "example",
    "metric": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "metric_key": "example",
      "metric_type": "example",
      "unit": "example"
    },
    "window": {
      "from": 1794214800000,
      "to": 1794214800000
    },
    "samples": [
      [
        0
      ]
    ],
    "next_cursor": "example",
    "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 custom_metrics.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"
}
```

**Response (503 Service Unavailable)**

A data store did not answer within the request's 10 seconds; try again shortly (`store_unavailable`).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/store_unavailable/",
  "title": "Store unavailable",
  "status": 503,
  "code": "store_unavailable",
  "detail": "A data store did not answer; try again shortly",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a custom metric's series

GET/v1/custom-metrics/{custom\_metric\_uuid}/series

Returns the metric’s points over a window, which defaults to the last day and reaches back as far as the metric is kept (1,095 days). Each point summarises the step that ends at its time: with `step=1d` the point at a day’s 00:00 UTC holds the day before. `tz`, an IANA time zone name such as `Europe/London`, puts the `1d` points at the zone’s local midnights and the `1w` points on its Mondays, each still holding the step that ends at it; a day with a clock change is 23 or 25 hours long, so read each point’s own time rather than multiples of `step_seconds`, and know that `tz=UTC` is not the same as no `tz` (a `1w` point sits on Mondays 00:00 UTC, without `tz` on Thursdays); with any other step `tz` changes nothing, and the answer gives the `tz` sent. `aggregation` chooses how: `avg`, `min`, `max` or `last` for a `level` metric, `sum` for a `count` one; omitted, a level reads its value at each step and a count its sum. `step` chooses the width, `30s` to `1w`, and is refused when it cuts the window into more than 720 points; omitted, it follows the window’s length. A step with no value is a missing point, not a zero. The store reads at most 30,000,000 samples of one metric in a query, so a dense metric’s longest window is shorter (about 300 days at the default 100,000 points a day); beyond it the answer is 422 asking for a shorter window. A metric awaiting approval stores no points, so the answer is `available: false` with `reason: awaiting_approval` and an empty series.

Needs the scope `custom_metrics.view`.

### Path parameters

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

### 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.
- `aggregation` (string or null): How each step summarises the samples inside it: `avg`, `min`, `max` or `last` for a `level` metric, `sum` for a `count` one (the metric’s `supported_aggregations`). Omitted, a level reads its value at each step and a count its sum. Values:`avg``min``max``last``sum`(an open set: new values may be added)
- `step` (string or null): The width of one step: `30s`, `1m`, `5m`, `30m`, `2h`, `6h`, `1d` or `1w`, refused when it cuts the window into more than 720 points. Omitted, the step follows the window’s length. Values:`30s``1m``5m``30m``2h``6h``1d``1w`(an open set: new values may be added)
- `tz` (string or null): An IANA time zone name such as `Europe/London`. With a `1d` or `1w` step (sent, or chosen by the window’s length) each point sits at a local midnight of the zone, and a `1w` point on a Monday’s; with any other step it changes nothing. Omitted, the steps are aligned to UTC as before.

### Returns

`200 OK`:

The metric’s points over the window.

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/custom-metrics/{custom_metric_uuid}/series**

curl:

```bash
curl https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/series \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->customMetrics->series('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.series('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.series('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "available": true,
    "reason": "example",
    "aggregation": "example",
    "tz": "example",
    "metric": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "metric_key": "example",
      "metric_type": "example",
      "unit": "example"
    },
    "window": {
      "from": 1794214800000,
      "to": 1794214800000
    },
    "source": "example",
    "step_seconds": 1,
    "series": [
      {
        "name": "example",
        "unit": "example",
        "labels": {
          "mount": "example",
          "device": "example",
          "interface": "example",
          "state": "example",
          "cpu": "example"
        },
        "point_meaning": "example",
        "points": [
          [
            0
          ]
        ]
      }
    ]
  }
}
```

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

**Response (503 Service Unavailable)**

A data store did not answer within the request's 10 seconds; try again shortly (`store_unavailable`).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/store_unavailable/",
  "title": "Store unavailable",
  "status": 503,
  "code": "store_unavailable",
  "detail": "A data store did not answer; try again shortly",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

## Get a custom metric's summary

GET/v1/custom-metrics/{custom\_metric\_uuid}/summary

Returns statistics of the metric’s samples over a window, which defaults to the last day and reaches back as far as the metric is kept (1,095 days; an earlier start is served from it): the number of samples, their sum, minimum, maximum, average, median (`p50`) and 95th percentile (`p95`), the times of the first and the last sample, and the last value. Each is null when the window holds no sample. A window of 31 days or less reads the samples themselves, and the answer says `rolled_up: false`; a longer one reads the daily summaries the platform keeps for the whole UTC days up to the start of yesterday and the samples for the rest, and says `rolled_up: true`: `p50` and `p95` are then approximated from a histogram of the values, within about 14% of the exact value, and are null when the window holds a negative value, and every other statistic is exact. A metric whose history is not summarised yet answers `available: false` with `reason: rollup_pending`; a backfilled value, or a reset, reaches the longer windows within about an hour. A window of 31 days or less that the store refuses because it holds more samples than one query reads (30,000,000 of one metric) answers 422 asking for a shorter window; data denser than the default 100,000 points a day can also end at the read budget with 503 `store_unavailable`. A metric awaiting approval stores no samples, so the answer is `available: false` with `reason: awaiting_approval` and every statistic null.

Needs the scope `custom_metrics.view`.

### Path parameters

- `custom_metric_uuid` (string (uuid), required): The uuid of the custom metric in the path.

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

### Returns

`200 OK`:

The metric’s statistics over the window.

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/custom-metrics/{custom_metric_uuid}/summary**

curl:

```bash
curl https://rest.watchtower15.com/v1/custom-metrics/fb761b25-d897-4fd8-8109-5a76004ae1d8/summary \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->customMetrics->summary('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Node.js:

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

const result = await wt15.customMetrics.summary('fb761b25-d897-4fd8-8109-5a76004ae1d8');
```

Python:

```python
client = Client.from_environment()

result = client.custom_metrics.summary('fb761b25-d897-4fd8-8109-5a76004ae1d8')
```

**Response (200 OK)**

```json
{
  "data": {
    "available": true,
    "reason": "example",
    "metric": {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "metric_key": "example",
      "metric_type": "example",
      "unit": "example"
    },
    "window": {
      "from": 1794214800000,
      "to": 1794214800000
    },
    "rolled_up": true,
    "sample_count": 1,
    "sum": 0,
    "min": 0,
    "max": 0,
    "avg": 0,
    "p50": 0,
    "p95": 0,
    "first_at": 1794214800000,
    "last_at": 1794214800000,
    "last": 0
  }
}
```

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

**Response (503 Service Unavailable)**

A data store did not answer within the request's 10 seconds; try again shortly (`store_unavailable`).

```json
{
  "type": "https://docs.watchtower15.com/api/errors/store_unavailable/",
  "title": "Store unavailable",
  "status": 503,
  "code": "store_unavailable",
  "detail": "A data store did not answer; try again shortly",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

Source: https://developer.watchtower15.com/api/reference/custom-metrics/
