# Health

The organisation’s health at a glance: a summary and a map of what needs attention.

**Endpoints**

- `GET/v1/health/map`
- `GET/v1/health/summary`

## Get the health map

GET/v1/health/map

Returns the console’s heat map: for each requested resource type, the counts per health bucket and the cells themselves, worst first. A type the key may not view comes back as `available: false` and nothing else; incidents on a cell are left empty unless the key may also view incidents.

### Query parameters

- `types` (array of strings or null): The resource types to include: any of `servers`, `domains`, `services`, `log_sources`, `custom_metrics` and `databases`; with none, all of them. A list: repeat the parameter (`types=servers&types=domains`) or send one value (`types=servers`); `types[]=servers` is accepted too. Values:`servers``domains``services``log_sources``custom_metrics``databases`(an open set: new values may be added)
- `include_healthy` (string or null): Whether healthy resources are returned as rows (`true` or `false`); they are left out by default. They still count in `counts`. Values:`true``false``1``0`(an open set: new values may be added)
- `limit` (integer or null): How many rows to return for each type, from 1 to 100; 50 when omitted.

### Returns

`200 OK`:

The health map, one section per resource type.

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/health/map**

curl:

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

PHP:

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

$result = $wt15->health->map();
```

Node.js:

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

const result = await wt15.health.map();
```

Python:

```python
client = Client.from_environment()

result = client.health.map()
```

**Response (200 OK)**

```json
{
  "data": {
    "types": [
      {
        "type": "example",
        "available": true,
        "total": 1,
        "counts": {
          "critical": 1,
          "unreachable": 1,
          "warning": 1,
          "unknown": 1,
          "healthy": 1,
          "unwatched": 1
        },
        "rows": [
          {
            "entity": {},
            "console_url": "example",
            "health": "example",
            "bucket": "example",
            "note": "example",
            "since_at": 1794214800000,
            "issue_count": 1,
            "issues": []
          }
        ],
        "rows_omitted": 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 domains.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 (`invalid_request`; `errors` names the parameters).

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Get the health summary

GET/v1/health/summary

Returns the counts the console’s dashboard opens with: active, warning and critical resources for servers, domains, services and log sources, and how many domain and service scans ran recently. A section the key may not view comes back as `available: false` and nothing else, so the call never answers 403.

### Returns

`200 OK`:

The health counts, one section per resource type.

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/health/summary**

curl:

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

PHP:

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

$result = $wt15->health->summary();
```

Node.js:

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

const result = await wt15.health.summary();
```

Python:

```python
client = Client.from_environment()

result = client.health.summary()
```

**Response (200 OK)**

```json
{
  "data": {
    "generated_at": 1794214800000,
    "servers": {
      "available": true,
      "active": 1,
      "warning": 1,
      "critical": 1,
      "seen_last_5m": 1,
      "seen_last_1h": 1,
      "security": {
        "warning": 1,
        "critical": 1
      }
    },
    "domains": {
      "available": true,
      "active": 1,
      "warning": 1,
      "critical": 1
    },
    "services": {
      "available": true,
      "active": 1,
      "warning": 1,
      "critical": 1
    },
    "log_sources": {
      "available": true,
      "active": 1,
      "warning": 1,
      "critical": 1,
      "received_last_5m": 1,
      "received_last_1h": 1
    },
    "scans": {
      "domains": {
        "available": true,
        "last_1h": 1,
        "last_24h": 1
      },
      "services": {
        "available": true,
        "last_1h": 1,
        "last_24h": 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 domains.edit scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

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