# Databases

Monitored databases: collectors, queries, findings, storage and the advice drawn from them.

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

**Endpoints**

- `POST/v1/databases`
- `PUT/v1/databases/{database_uuid}`
- `GET/v1/databases/{database_uuid}`
- `GET/v1/databases`
- `DELETE/v1/databases/{database_uuid}`
- `POST/v1/databases/{database_uuid}/accept-key`
- `GET/v1/databases/{database_uuid}/capabilities`
- `GET/v1/databases/{database_uuid}/cloud`
- `GET/v1/databases/{database_uuid}/collectors/history`
- `POST/v1/databases/collector-preview`
- `GET/v1/databases/{database_uuid}/collectors`
- `GET/v1/databases/{database_uuid}/coverage`
- `POST/v1/databases/{database_uuid}/findings/{finding_uuid}/dismiss`
- `GET/v1/databases/{database_uuid}/failovers`
- `GET/v1/databases/{database_uuid}/findings`
- `GET/v1/databases/{database_uuid}/metrics`
- `POST/v1/databases/{database_uuid}/pause`
- `GET/v1/databases/{database_uuid}/queries`
- `POST/v1/databases/{database_uuid}/reassign`
- `POST/v1/databases/{database_uuid}/schema-refresh`
- `POST/v1/databases/{database_uuid}/findings/{finding_uuid}/restore`
- `POST/v1/databases/{database_uuid}/resume`
- `POST/v1/databases/{database_uuid}/advisor-run`
- `GET/v1/databases/{database_uuid}/schema-changes`
- `GET/v1/databases/{database_uuid}/storage`
- `POST/v1/databases/{database_uuid}/verify`

## The Database object

### Attributes

- `uuid` (string): The database’s uuid.
- `name` (string): The database’s name.
- `description` (string or null): The description set for the database; null when none is set.
- `provider` (string or null): The hosting provider’s key, such as `aws_rds_mysql`.
- `provider_edition` (string or null): The provider’s edition of the service, such as `aurora`; null when none applies.
- `engine` (string or null): The database engine, such as `mysql`; null until it is known.
- `engine_version` (string or null): The engine’s version as the collector reported it; null until a report arrives.
- `engine_flavour` (string or null): The engine’s flavour, such as `mariadb`; null until it is known.
- `privacy_mode` (string): How much of the database’s text the monitor keeps: `hashed`, `identifiers` or `counts`.
- `tls_mode` (string or null): How the collector secures its connection to the database with TLS; null when not set.
- `connection_type` (string or null): One of `socket`, `loopback`, `private_network`, `public_endpoint`.
- `ca_source` (string or null): Where the database’s CA comes from; the engine’s vocabulary.
- `auth_method` (string or null): How the collector signs in; the engine’s vocabulary.
- `credentials` (object or null): Where the collector’s credentials come from, by reference, never a secret: the method and, by method, the names it reads (`file` `{method}`, `socket` and `aws_iam` `{method, user}`, `aws_secrets_manager` `{method, secret, keys}`, `aws_ssm_parameter` `{method, user, password_parameter, redaction_key_parameter}`); null when none is set. With `file` the collector reads `/etc/wt15-server-agent/databases.d/<database uuid>.cnf` on its server, a path WatchTower15 does not record. `PUT` takes the same object as `credential_ref`, so it can be sent back.
  - `method` (string): How the collector finds its credentials: `file`, `socket`, `aws_secrets_manager`, `aws_ssm_parameter` or `aws_iam`. More methods may be added.
  - `user` (string): The database user the collector signs in as; with `socket`, `aws_ssm_parameter` and `aws_iam`.
  - `secret` (string): With `aws_secrets_manager`: the ARN of the AWS Secrets Manager secret that holds the credentials, a reference, never its value.
  - `keys` (object): With `aws_secrets_manager`: the names of the JSON keys inside the secret that hold the user, the password and the redaction key; names, never values.
    - `user` (string): The name of the JSON key inside the secret that holds the user.
    - `password` (string): The name of the JSON key inside the secret that holds the password: a key name, never the password.
    - `redaction_key` (string): The name of the JSON key inside the secret that holds the redaction key.
  - `password_parameter` (string): With `aws_ssm_parameter`: the name of the SSM parameter that holds the password, a reference, never its value.
  - `redaction_key_parameter` (string): With `aws_ssm_parameter`: the name of the SSM parameter that holds the redaction key, a reference, never its value.
- `collector_pool` (object): The rule that picks the database’s collectors, as stored; `GET /v1/databases/{database_uuid}/collectors` lists the servers it picks now, and `PUT` takes the same rule as `collectors`, by uuid.
  - `selection` (string or null): `servers` (the servers listed, in order of preference), `tags` (the servers carrying the tags) or null when no rule is set.
  - `servers` (array of objects): The servers listed, in order of preference; an archived or deleted server is left out.
    - `uuid` (string): The uuid of the server.
    - `name` (string or null): The name of the server; null unless the key also holds the servers.view scope and its owner may view servers.
  - `all` (array of objects): With `tags`: a server must carry every one of these tags.
    - `uuid` (string): The uuid of the tag.
    - `name` (string): The name of the tag.
  - `any` (array of objects): With `tags`: a server must carry at least one of these tags.
    - `uuid` (string): The uuid of the tag.
    - `name` (string): The name of the tag.
- `reference_key_fingerprint` (string or null): The reference key check value: a fingerprint, never the key.
- `reported_key_fingerprints` (array of strings): The distinct key check values the collectors report; `databases.acceptKey` takes one. Never a collector or its server.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`.
- `status` (string): One of `draft`, `awaiting_collector`, `verifying`, `active`, `failing`, `paused`.
- `status_reason` (string or null): Why the status is what it is: words on a draft or on a database no server can collect, the collector’s reason code on a failing one, such as `dns`, `tls_failed` or `auth_failed` (`unreachable` when it gave none); null otherwise. More codes may be added.
- `over_privileged` (boolean): Whether a collector holds more privilege than it needs.
- `layers_available` (object or null): What the collector’s probe found it can read, by layer; null before the first probe.
- `storage` (object): The database’s storage: its size, growth and forecast.
  - `size_bytes` (integer or null): The database’s size in bytes; null before the first measurement.
  - `growth_30d_bytes` (integer or null): The 30-day projection less the size, while the forecast is `ok`.
  - `days_to_full` (integer or null): The forecast number of days until the storage is full; null when it cannot be forecast.
  - `forecast_status` (string or null): The forecast’s status; null before the first forecast.
  - `ceiling_gib` (integer or null): The storage ceiling set by hand, in GiB.
  - `measured_at` (integer or null): Epoch milliseconds. When the size was measured; null before the first measurement. An instant: epoch milliseconds, UTC.
- `schema` (object): The schema collector’s state; its first seven fields are null while no pass has run.
  - `outcome` (string or null): The last attempt’s outcome.
  - `last_attempt_at` (integer or null): Epoch milliseconds. When the last schema pass was attempted; null while no pass has run. An instant: epoch milliseconds, UTC.
  - `last_pass_at` (integer or null): Epoch milliseconds. When the database last answered a schema pass; null while none has. An instant: epoch milliseconds, UTC.
  - `next_pass_at` (integer or null): Epoch milliseconds. When the next schema pass is due; null while no pass has run. An instant: epoch milliseconds, UTC.
  - `paused_reason` (string or null): Why passes are paused, when they are.
  - `paused_since` (integer or null): Epoch milliseconds. Since when schema passes are paused; null when they are not. An instant: epoch milliseconds, UTC.
  - `object_counts` (object or null): The number of tables, views and routines found by the last answered pass; null before one.
    - `tables` (integer): The number of tables.
    - `views` (integer): The number of views.
    - `routines` (integer): The number of routines.
  - `history_started_at` (integer or null): Epoch milliseconds. When the schema history began; null before it did. An instant: epoch milliseconds, UTC.
  - `last_change_at` (integer or null): Epoch milliseconds. When the last schema change was detected; null when none has been. An instant: epoch milliseconds, UTC.
- `last_received_at` (integer or null): Epoch milliseconds. When a report last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `tags` (array of objects): The tags set on the database.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
- `console_url` (string): The database’s page in the console.

**The Database object**

```json
{
  "uuid": "75666699-b77d-4631-b576-041e8102a55b",
  "name": "example",
  "description": "example",
  "provider": "example",
  "provider_edition": "example",
  "engine": "example",
  "engine_version": "example",
  "engine_flavour": "example",
  "privacy_mode": "example",
  "tls_mode": "example",
  "connection_type": "example",
  "ca_source": "example",
  "auth_method": "example",
  "credentials": {
    "method": "example",
    "user": "example",
    "secret": "example",
    "keys": {
      "user": "example",
      "password": "example",
      "redaction_key": "example"
    },
    "password_parameter": "example",
    "redaction_key_parameter": "example"
  },
  "collector_pool": {
    "selection": "example",
    "servers": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "all": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "any": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ]
  },
  "reference_key_fingerprint": "example",
  "reported_key_fingerprints": [
    "example"
  ],
  "health_status": "example",
  "status": "example",
  "status_reason": "example",
  "over_privileged": true,
  "layers_available": {},
  "storage": {
    "size_bytes": 1,
    "growth_30d_bytes": 1,
    "days_to_full": 1,
    "forecast_status": "example",
    "ceiling_gib": 1,
    "measured_at": 1794214800000
  },
  "schema": {
    "outcome": "example",
    "last_attempt_at": 1794214800000,
    "last_pass_at": 1794214800000,
    "next_pass_at": 1794214800000,
    "paused_reason": "example",
    "paused_since": 1794214800000,
    "object_counts": {
      "tables": 1,
      "views": 1,
      "routines": 1
    },
    "history_started_at": 1794214800000,
    "last_change_at": 1794214800000
  },
  "last_received_at": 1794214800000,
  "tags": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example"
    }
  ],
  "console_url": "example"
}
```

## Create a database

POST/v1/databases

Creates a database in the draft state with its default alarms, from a name, a description and a provider. Finish its connection, collectors and tags with `databases.update`, which also completes the setup. Refused when the organisation’s database limit is reached or its payment status does not allow it. Answers the database as `databases.view` does.

Needs the scope `database.edit`.

### Headers

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

### Body parameters

- `name` (string, required): The database’s name.
- `description` (string or null): A description of the database; null for none.
- `provider` (string, required): The hosting provider’s key, such as `aws_rds_mysql`.

### Returns

`201 Created`:

The database that was created.

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

**POST /v1/databases**

curl:

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

PHP:

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

$database = $wt15->databases->create(['name' => 'example', 'provider' => 'example']);
```

Node.js:

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

const result = await wt15.databases.create({ name: 'example', provider: 'example' });
```

Python:

```python
client = Client.from_environment()

result = client.databases.create(name='example', provider='example')
```

**Response (201 Created)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (402 Payment Required)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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 database

PUT/v1/databases/{database\_uuid}

Changes a database’s name, description, provider, connection, TLS and credential references, privacy mode, collector pool, host server, tags and storage ceiling; only the fields sent change. `setup_complete` leaves the draft state. The connection fields, credential references and TLS server name are accepted and never returned. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Body parameters

- `name` (string): The database’s name.
- `description` (string or null): A description of the database; null clears it.
- `provider` (string): The hosting provider’s key, such as `aws_rds_mysql`.
- `provider_edition` (string or null): The provider’s edition of the service, by its catalogue key; it must belong to the provider. Null clears it.
- `connection_type` (string or null): How the collector reaches the database: `socket`, `loopback`, `private_network` or `public_endpoint`. Values:`socket``loopback``private_network``public_endpoint`(an open set: new values may be added)
- `endpoint_host` (string or null): The host name the collector connects to. Accepted, never returned.
- `endpoint_port` (integer or null): The TCP port the collector connects to, from 1 to 65535. Accepted, never returned.
- `socket_path` (string or null): The absolute path of the Unix socket the collector connects to. Accepted, never returned.
- `tls_mode` (string or null): How the collector secures its connection with TLS; one of the modes the database’s engine supports. Values:`none``verify_identity``verify_ca``skip_verify`(an open set: new values may be added)
- `tls_server_name` (string or null): The server name the collector expects in the database’s TLS certificate. Accepted, never returned.
- `ca_source` (string or null): Where the certificate authority for the connection comes from; one of the sources the database’s engine supports. Values:`system``rds_bundle``file`(an open set: new values may be added)
- `auth_method` (string or null): How the collector signs in to the database; one of the methods the database’s engine supports. Values:`password``socket``aws_iam`(an open set: new values may be added)
- `credential_ref` (array of strings or null): A reference to the credential the collector uses, in the shape the authentication method needs; identifiers only, never a secret. Accepted; the view answers it as `credentials`.
- `redaction_key_ref` (array of strings or null): A reference to the key that redacts the database’s text, in the shape the privacy mode needs; identifiers only, never a secret. Accepted, never returned.
- `privacy_mode` (string or null): How much of the database’s text the monitor keeps: `hashed`, `identifiers` or `counts`. Values:`hashed``identifiers``counts`(an open set: new values may be added)
- `collectors` (object or null): The rule that picks the servers running the database’s collectors: explicit servers in order of preference, or a tag rule.
  - `selection` (string): `servers` for a hand-picked list, `tags` for servers chosen by their tags. Values:`servers``tags`(an open set: new values may be added)
  - `servers` (array of strings or null): The uuids of the servers, in order of preference, with `selection` `servers`.
  - `all` (array of strings or null): Servers must carry all of these tags, by uuid, with `selection` `tags`.
  - `any` (array of strings or null): Servers must carry any of these tags, by uuid, with `selection` `tags`.
- `host_server_uuid` (string (uuid) or null): The uuid of the monitored server that runs the database, for a self-managed database reached over the network; null clears it.
- `tag_uuids` (array of strings or null): The uuids of the tags to set on the database.
- `setup_complete` (boolean or null): Whether the setup is complete; true leaves the draft state, after the payment status and the organisation’s database limit are checked.
- `storage` (object): The database’s storage settings.
  - `ceiling_gib` (integer or null): The storage ceiling in whole GiB, or null to clear it. Accepted only for `aws_rds_mysql` and `aws_rds_mariadb` databases; the days to full are recomputed at once.

### Returns

`200 OK`:

The database 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/databases/{database_uuid}**

curl:

```bash
curl -X PUT https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$database = $wt15->databases->update('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.update('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.update('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (402 Payment Required)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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 database

GET/v1/databases/{database\_uuid}

Returns one database with its engine, storage and forecast, schema pass state, tags and the key check values its collectors report. Reading a database also adds any default alarm the catalogue gained since it was created, as opening it in the console does.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database.

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/databases/{database_uuid}**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$database = $wt15->databases->view('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.view('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.view('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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 databases

GET/v1/databases

Lists the organisation’s databases, worst health first unless `sort` says otherwise, one page at a time. Filter by name or endpoint, status, provider, health or tags. The current queries per second and connection use are null when the database sent no report in the last 2 minutes. 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 `database.view`.

### Query parameters

- `search` (string or null): Only databases whose name or endpoint host contains this text.
- `status` (array of strings or null): Only databases in one of these statuses: `draft`, `awaiting_collector`, `verifying`, `active`, `failing` or `paused`. A list: repeat the parameter (`status=draft&status=awaiting_collector`) or send one value (`status=draft`); `status[]=draft` is accepted too. Values:`draft``awaiting_collector``verifying``active``failing``paused`(an open set: new values may be added)
- `provider` (array of strings or null): Only databases of one of these providers, by the provider’s key. A list: repeat the parameter (`provider=<value>&provider=<value>`) or send one value (`provider=<value>`); `provider[]=<value>` is accepted too.
- `health` (array of strings or null): Only databases with one of these health statuses: `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)
- `tag_uuids` (array of strings or null): Only databases carrying all 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 sort by: `name`, `health_status`, `status` or `last_received_at`; the worst health first when omitted. Values:`name``health_status``status``last_received_at`(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 number of items in a page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the organisation’s databases.

Each item of the page:

- `uuid` (string): The database’s uuid.
- `name` (string): The database’s name.
- `engine` (string or null): The database engine, such as `mysql`; null until it is known.
- `engine_version` (string or null): The engine’s version as the collector reported it; null until a report arrives.
- `provider` (string or null): The hosting provider’s key, such as `aws_rds_mysql`.
- `health_status` (string): One of `unknown`, `healthy`, `warning`, `critical`.
- `status` (string): One of `draft`, `awaiting_collector`, `verifying`, `active`, `failing`, `paused`.
- `status_reason` (string or null): Why the status is what it is: words on a draft or on a database no server can collect, the collector’s reason code on a failing one, such as `dns`, `tls_failed` or `auth_failed` (`unreachable` when it gave none); null otherwise. More codes may be added.
- `active` (boolean): Whether monitoring is switched on.
- `privacy_mode` (string): How much of the database’s text the monitor keeps: `hashed`, `identifiers` or `counts`.
- `qps` (number or null): Queries per second, the latest value; null without a report in the last 2 minutes.
- `connections_percent` (number or null): Connections in use as a percentage of the maximum; null without a report in the last 2 minutes.
- `storage_size_bytes` (integer or null): The database’s size in bytes; null before the first measurement.
- `storage_growth_30d_bytes` (integer or null): The 30-day projection less the size, while the forecast is `ok`.
- `storage_days_to_full` (integer or null): The forecast number of days until the storage is full; null when it cannot be forecast.
- `storage_forecast_status` (string or null): The forecast’s status; null before the first forecast.
- `over_privileged` (boolean): Whether a collector holds more privilege than it needs.
- `last_received_at` (integer or null): Epoch milliseconds. When a report last arrived; null if none ever did. An instant: epoch milliseconds, UTC.
- `tags` (array of objects): The tags set on the database.
  - `uuid` (string): The tag’s uuid.
  - `name` (string): The tag’s name.
- `console_url` (string): The database’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/databases**

curl:

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

PHP:

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

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

Node.js:

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

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

Python:

```python
client = Client.from_environment()

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

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "name": "example",
      "engine": "example",
      "engine_version": "example",
      "provider": "example",
      "health_status": "example",
      "status": "example",
      "status_reason": "example",
      "active": true,
      "privacy_mode": "example",
      "qps": 0,
      "connections_percent": 0,
      "storage_size_bytes": 1,
      "storage_growth_30d_bytes": 1,
      "storage_days_to_full": 1,
      "storage_forecast_status": "example",
      "over_privileged": true,
      "last_received_at": 1794214800000,
      "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 database.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 database

DELETE/v1/databases/{database\_uuid}

Deletes a database. Its collectors are told to stop, its open incidents resolve, and its stored storage inventory is removed. The answer has no body.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`204 No Content`:

The database was 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.

**DELETE /v1/databases/{database_uuid}**

curl:

```bash
curl -X DELETE https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$wt15->databases->delete('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

await wt15.databases.delete('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

client.databases.delete('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

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

## Accept a new key check value

POST/v1/databases/{database\_uuid}/accept-key

Makes one of the key check values the collectors report (`reported_key_fingerprints`) the database’s reference, as a deliberate key rotation. Collectors that report it become eligible again, collectors still on the old key are flagged until they hold the new one, every collector probes again, and the advisor’s per-object findings are evaluated afresh. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Body parameters

- `fingerprint` (string, required): One of the database’s `reported_key_fingerprints`: a key check value (an HMAC cut to 16 hex characters), never the key.

### Returns

`200 OK`:

The database after the new key was accepted.

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/databases/{database_uuid}/accept-key**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/accept-key \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "fingerprint": "example"
  }'
```

PHP:

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

$result = $wt15->databases->acceptKey('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', ['fingerprint' => 'example']);
```

Node.js:

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

const result = await wt15.databases.acceptKey('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', { fingerprint: 'example' });
```

Python:

```python
client = Client.from_environment()

result = client.databases.accept_key('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', fingerprint='example')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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 database's capabilities

GET/v1/databases/{database\_uuid}/capabilities

Returns, for each monitoring layer of a database, whether it is available, not applicable or not collected, with the scope of a not applicable layer and the remedy of a layer that is not collected. Reading a database’s layers also adds any default alarm the catalogue gained since the database was created, as opening it in the console does.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database’s monitoring layers.

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/databases/{database_uuid}/capabilities**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/capabilities \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->capabilities('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.capabilities('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.capabilities('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "layers": [
      {
        "key": "example",
        "availability": "example",
        "scope": "example",
        "remedy": "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 database.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Get a database's cloud section

GET/v1/databases/{database\_uuid}/cloud

Returns the state of the cloud section the database’s collector reports and the facts it holds about the cloud instance: its role, class, storage, whether it is Multi-AZ and when the facts were stored. It never returns what identifies the cloud account or the instance. A database with no cloud section yet answers every field null.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database’s cloud section.

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/databases/{database_uuid}/cloud**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/cloud \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->cloud('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.cloud('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.cloud('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "status": "example",
    "reason": "example",
    "metric_count": 1,
    "multi_az": true,
    "role": "example",
    "instance_class": "example",
    "storage_type": "example",
    "iops": 1,
    "allocated_bytes": 1,
    "max_allocated_bytes": 1,
    "performance_insights_enabled": true,
    "facts_at": 1794214800000
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## List a database's collector history

GET/v1/databases/{database\_uuid}/collectors/history

Lists the moves of a database’s collector lease, newest first, one page at a time, over an optional time window; without a window every move is listed. A server is identified by its uuid only. 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 `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### 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.
- `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 number of items in a page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the lease’s moves.

Each item of the page:

- `at` (integer): Epoch milliseconds. When the move was recorded, to the second. An instant: epoch milliseconds, UTC.
- `action` (string): What happened: `promoted` (a standby became the active collector), `assigned` (a server was given a role), `demoted` (the active collector stopped) or `none` (the database was left with no collector).
- `server_uuid` (string or null): The uuid of the server the row is about; null when the row has none, as on every `none` row and on rows recorded before the uuid was kept.
- `role` (string or null): `active` or `standby` on an `assigned` row; null on every other.
- `epoch` (integer or null): The lease epoch the row carries: on `promoted` and on `assigned` as `active`; null otherwise.
- `reason` (string or null): Why the lease moved, in a fixed sentence; null where the row has none.

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/databases/{database_uuid}/collectors/history**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/collectors/history \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

foreach ($wt15->databases->collectorHistory('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')->autoPaging() as $item) { echo $item->action, "\n"; }
```

Node.js:

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

for await (const item of wt15.databases.collectorHistory('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')) {
  console.log(item.action);
}
```

Python:

```python
client = Client.from_environment()

for item in client.databases.collector_history('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b'):
    print(item.action)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "at": 1794214800000,
      "action": "example",
      "server_uuid": "e0f5add1-ce75-48d4-bb62-1712db369290",
      "role": "example",
      "epoch": 1,
      "reason": "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 database.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"
}
```

## Preview a collector pool

POST/v1/databases/collector-preview

Lists the servers that a collector selection would make candidates for a database, by hand-picked servers or by tags, with the role each would get and why a server is left out. Read-only: nothing is saved and no database is changed. Also warns about weak pools, such as a pool of one that never fails over.

Needs the scope `database.edit`.

### Headers

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

### Body parameters

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

### Returns

`200 OK`:

The candidate servers and the warnings for the selection.

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/databases/collector-preview**

curl:

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

PHP:

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

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

Node.js:

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

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

Python:

```python
client = Client.from_environment()

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

**Response (200 OK)**

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

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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 database's collectors

GET/v1/databases/{database\_uuid}/collectors

Returns the servers that collect a database: the lease epoch, and for each server its role (active, standby or cold), whether it is eligible, when it last probed the database and what the probe found, and why it cannot collect right now when it cannot. The active collector comes first, then the standby, then the other candidates. A server’s name is returned only to a key that also holds the servers.view scope; its uuid always.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database’s lease epoch and its collectors.

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/databases/{database_uuid}/collectors**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/collectors \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->collectors('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.collectors('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.collectors('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "lease_epoch": 1,
    "collectors": [
      {
        "server": {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        },
        "role": "example",
        "eligible": true,
        "last_probe_at": 1794214800000,
        "last_probe_ok": true,
        "last_probe_reason": "example",
        "probe_pending": true,
        "excluded_because": "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 database.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Get a database's data coverage

GET/v1/databases/{database\_uuid}/coverage

Returns how much of the time a database should have reported it did over a window, as a share, and every band where data is missing or accounted for, each with its cause: monitoring paused, no collector, database unreachable, a collector handover, a WatchTower15 outage, no report from the collector, and the collector-side causes. The window defaults to the last 30 days, which is also how far back coverage reaches, and is at most 31 days. When the data store does not answer, the answer says coverage is unavailable instead of failing.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### 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 database’s coverage share and bands for 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/databases/{database_uuid}/coverage**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/coverage \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->coverage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.coverage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.coverage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "window": {
      "from": 1794214800000,
      "to": 1794214800000
    },
    "available": true,
    "share": 0,
    "expected_minutes": 1,
    "covered_minutes": 1,
    "bands": [
      {
        "cause": "example",
        "from": 1794214800000,
        "to": 1794214800000,
        "reason": "example"
      }
    ]
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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"
}
```

## Dismiss an advisor finding

POST/v1/databases/{database\_uuid}/findings/{finding\_uuid}/dismiss

Dismisses an open advisor finding with a reason. It stays dismissed while it keeps firing and is resolved when it stops applying. Refused when the finding belongs to another database or is not open. Answers the finding as `databases.findings` lists it.

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

- `database_uuid` (string (uuid), required): The uuid of the database.
- `finding_uuid` (string (uuid), required): The uuid of the finding.

### Body parameters

- `reason` (string, required): Why the finding is dismissed.

### Returns

`200 OK`:

The finding after it was dismissed.

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/databases/{database_uuid}/findings/{finding_uuid}/dismiss**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/findings/01c67242-615a-4f61-a230-4f00d737d619/dismiss \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "reason": "example"
  }'
```

PHP:

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

$result = $wt15->databases->dismissFinding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619', ['reason' => 'example']);
```

Node.js:

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

const result = await wt15.databases.dismissFinding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619', { reason: 'example' });
```

Python:

```python
client = Client.from_environment()

result = client.databases.dismiss_finding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619', reason='example')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "rule_key": "example",
    "group": "example",
    "object_kind": "example",
    "object_key": "example",
    "object_names": {},
    "severity": "example",
    "status": "example",
    "statement_text": "example",
    "first_seen_at": 1794214800000,
    "last_seen_at": 1794214800000,
    "resolved_at": 1794214800000,
    "dismissed_at": 1794214800000
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## List a database's failovers

GET/v1/databases/{database\_uuid}/failovers

Lists the failovers detected on a database, newest first, one page at a time, over an optional time window; without a window every failover is listed. A server is identified by its uuid only. 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 `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### 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.
- `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 number of items in a page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the database’s failovers.

Each item of the page:

- `at` (integer): Epoch milliseconds. When the failover was recorded, to the second; the window and the order follow it. An instant: epoch milliseconds, UTC.
- `observed_at` (integer or null): Epoch milliseconds. When the collector’s snapshot that showed the failover was taken; null on a failover whose snapshot did not carry it. An instant: epoch milliseconds, UTC.
- `server_uuid` (string or null): The uuid of the server whose collector reported the failover; null when the row has none.

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/databases/{database_uuid}/failovers**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/failovers \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

foreach ($wt15->databases->failovers('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')->autoPaging() as $item) { echo json_encode($item), "\n"; }
```

Node.js:

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

for await (const item of wt15.databases.failovers('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')) {
  console.log(item);
}
```

Python:

```python
client = Client.from_environment()

for item in client.databases.failovers('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b'):
    print(item)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "at": 1794214800000,
      "observed_at": 1794214800000,
      "server_uuid": "e0f5add1-ce75-48d4-bb62-1712db369290"
    }
  ],
  "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 database.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 advisor findings

GET/v1/databases/{database\_uuid}/findings

Lists the advisor’s findings on one database, one page at a time. Without a `status` filter only the open findings are returned. Filter by severity, rule group or rule. Object names and statement texts are returned only when the database shows identifiers. 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 `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Query parameters

- `status` (string or null): Only findings in this status: `open`, `resolved` or `dismissed`; the open findings when omitted. Values:`open``resolved``dismissed`(an open set: new values may be added)
- `severity` (string or null): Only findings of this severity: `critical`, `warning` or `info`. Values:`critical``warning``info`(an open set: new values may be added)
- `group` (string or null): Only findings of rules in this group: `config`, `schema`, `workload` or `hardening`. Values:`configuration``schema``workload``hardening`(an open set: new values may be added)
- `rule` (string or null): Only findings of this advisor rule, by its key. Values:`config.buffer_pool_small``config.connections_headroom``config.tmp_disk_tables_high``config.redo_capacity_low``config.binlog_retention_short``config.durability_relaxed``config.table_open_cache_small``schema.no_primary_key``schema.redundant_index``schema.unused_index``schema.row_versions_near_limit``schema.digest_table_full``workload.no_index_statements``workload.examined_vs_sent``workload.full_joins``hardening.secure_transport_off``hardening.local_infile_on``hardening.secure_file_priv_empty``hardening.replica_writable``hardening.open_accounts``hardening.tls_certificate_expiring`(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 number of items in a page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the database’s advisor findings.

Each item of the page:

- `uuid` (string): The finding’s uuid.
- `rule_key` (string): The advisor rule’s key, such as `schema.no_primary_key`.
- `group` (string or null): The rule’s group: `config`, `schema`, `workload` or `hardening`.
- `object_kind` (string): What the finding is about: `instance`, `table`, `index`, `statement`, `account` and so on.
- `object_key` (string): The object’s key, which tells objects apart when their names are hidden.
- `object_names` (object or null): The object’s names; null unless the database shows identifiers.
- `severity` (string): One of `critical`, `warning`, `info`.
- `status` (string): One of `open`, `resolved`, `dismissed`.
- `statement_text` (string or null): A statement’s text; null unless the database shows identifiers.
- `first_seen_at` (integer or null): Epoch milliseconds. When the item was first seen. An instant: epoch milliseconds, UTC.
- `last_seen_at` (integer or null): Epoch milliseconds. When the item was last seen. An instant: epoch milliseconds, UTC.
- `resolved_at` (integer or null): Epoch milliseconds. When it stopped applying; null while it is open. An instant: epoch milliseconds, UTC.
- `dismissed_at` (integer or null): Epoch milliseconds. When it was dismissed; null otherwise. An instant: epoch milliseconds, UTC.

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/databases/{database_uuid}/findings**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/findings \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

foreach ($wt15->databases->findings('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')->autoPaging() as $item) { echo $item->uuid, "\n"; }
```

Node.js:

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

for await (const item of wt15.databases.findings('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')) {
  console.log(item.uuid);
}
```

Python:

```python
client = Client.from_environment()

for item in client.databases.findings('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b'):
    print(item.uuid)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "uuid": "75666699-b77d-4631-b576-041e8102a55b",
      "rule_key": "example",
      "group": "example",
      "object_kind": "example",
      "object_key": "example",
      "object_names": {},
      "severity": "example",
      "status": "example",
      "statement_text": "example",
      "first_seen_at": 1794214800000,
      "last_seen_at": 1794214800000,
      "resolved_at": 1794214800000,
      "dismissed_at": 1794214800000
    }
  ],
  "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 database.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Get a database's metric series

GET/v1/databases/{database\_uuid}/metrics

Returns the series of a database’s telemetry over a time window, in the one shape every series read answers: each series has its name, unit, labels, what a point means and `[t, value]` points, with `t` in epoch milliseconds. Every series of the database’s engine is present, with no points when the window holds none. The window defaults to one day and is at most 31 days. Fails with a 503 when the metric store does not answer.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Query parameters

- `set` (string or null): `cloud` reads the cloud provider’s series of the database’s host (for a database that runs on a cloud service); omit it for the database’s own series. Values:`cloud`(an open set: new values may be added)
- `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 database’s series for 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/databases/{database_uuid}/metrics**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/metrics \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->metrics('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.metrics('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.metrics('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "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 database.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"
}
```

## Pause a database

POST/v1/databases/{database\_uuid}/pause

Pauses a database: nothing is collected, no alarm evaluates and nothing is billed until it is resumed, and its setup is kept. Refused for a draft and for a database that is already paused. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database after it was paused.

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

**POST /v1/databases/{database_uuid}/pause**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/pause \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->pause('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.pause('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.pause('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## List a database's top queries

GET/v1/databases/{database\_uuid}/queries

Returns the top 50 statements of a database in a time window, ranked by the chosen sort, with the totals of all the other statements and of the whole window. The window defaults to the last day and spans at most 7 days. A database that keeps counts only answers `available: false` with `reason: counts_only` and no statements. Statement texts and schema names are returned only when the database shows identifiers.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### 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.
- `sort` (string or null): What the top 50 statements are ranked by: `total_time`, `calls`, `avg_time`, `rows_examined`, `no_index`, `errors` or `impact`; `total_time` when omitted. Values:`total_time``calls``avg_time``rows_examined``no_index``errors``impact`(an open set: new values may be added)
- `order` (string or null): The ranking direction: `asc` for the lowest first or `desc` for the highest first; `desc` when omitted. Values:`asc``desc`(an open set: new values may be added)

### Returns

`200 OK`:

The top statements of the window, the other statements and the totals.

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/databases/{database_uuid}/queries**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/queries \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->queries('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.queries('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.queries('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "available": true,
    "reason": "example",
    "window": {
      "from": 1794214800000,
      "to": 1794214800000
    },
    "statements": [
      {
        "digest_key": "example",
        "schema_key": "example",
        "schema_name": "example",
        "statement_text": "example",
        "text_truncated": true,
        "first_seen_at": 1794214800000,
        "last_seen_at": 1794214800000,
        "calls": 1,
        "total_wait_us": 1,
        "lock_time_us": 1,
        "rows_examined": 1,
        "rows_sent": 1,
        "rows_affected": 1,
        "errors": 1,
        "warnings": 1,
        "tmp_disk_tables": 1,
        "tmp_tables": 1,
        "full_joins": 1,
        "full_scans": 1,
        "sort_merge_passes": 1,
        "no_index_used": 1,
        "no_good_index_used": 1,
        "avg_wait_us": 0,
        "no_index_share": 0,
        "rows_examined_per_row_sent": 0,
        "impact_index": 0
      }
    ],
    "other": {
      "calls": 1,
      "total_wait_us": 1,
      "lock_time_us": 1,
      "rows_examined": 1,
      "rows_sent": 1,
      "rows_affected": 1,
      "errors": 1,
      "warnings": 1,
      "tmp_disk_tables": 1,
      "tmp_tables": 1,
      "full_joins": 1,
      "full_scans": 1,
      "sort_merge_passes": 1,
      "no_index_used": 1,
      "no_good_index_used": 1,
      "avg_wait_us": 0,
      "no_index_share": 0,
      "rows_examined_per_row_sent": 0
    },
    "totals": {
      "calls": 1,
      "total_wait_us": 1,
      "lock_time_us": 1,
      "rows_examined": 1,
      "rows_sent": 1,
      "rows_affected": 1,
      "errors": 1,
      "warnings": 1,
      "tmp_disk_tables": 1,
      "tmp_tables": 1,
      "full_joins": 1,
      "full_scans": 1,
      "sort_merge_passes": 1,
      "no_index_used": 1,
      "no_good_index_used": 1,
      "avg_wait_us": 0,
      "no_index_share": 0,
      "rows_examined_per_row_sent": 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 database.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"
}
```

## Reassign a database's collector

POST/v1/databases/{database\_uuid}/reassign

Moves collection to the warm standby collector at once, and the old active collector becomes the standby. Expect one gap of about 15 seconds in the rates. Refused when there is no eligible standby. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database after collection was moved.

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/databases/{database_uuid}/reassign**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/reassign \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->reassign('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.reassign('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.reassign('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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"
}
```

## Refresh a database's schema

POST/v1/databases/{database\_uuid}/schema-refresh

Queues one schema pass on the database’s active collector, to run now. The pass runs when the collector’s agent next checks in, so the answer is the database as it stands, not the result. Refused while a refresh was requested in the last 10 minutes or when the collector cannot run it. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`202 Accepted`:

The schema refresh was queued; the body is the database as it stands.

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/databases/{database_uuid}/schema-refresh**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/schema-refresh \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->refreshSchema('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.refreshSchema('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.refresh_schema('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (202 Accepted)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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"
}
```

## Restore a dismissed advisor finding

POST/v1/databases/{database\_uuid}/findings/{finding\_uuid}/restore

Restores a dismissed advisor finding, so it counts again while it keeps firing. Refused when the finding belongs to another database or is not dismissed. Answers the finding as `databases.findings` lists it.

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

- `database_uuid` (string (uuid), required): The uuid of the database.
- `finding_uuid` (string (uuid), required): The uuid of the finding.

### Returns

`200 OK`:

The finding after it was restored.

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/databases/{database_uuid}/findings/{finding_uuid}/restore**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/findings/01c67242-615a-4f61-a230-4f00d737d619/restore \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->restoreFinding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619');
```

Node.js:

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

const result = await wt15.databases.restoreFinding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619');
```

Python:

```python
client = Client.from_environment()

result = client.databases.restore_finding('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b', '01c67242-615a-4f61-a230-4f00d737d619')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "rule_key": "example",
    "group": "example",
    "object_kind": "example",
    "object_key": "example",
    "object_names": {},
    "severity": "example",
    "status": "example",
    "statement_text": "example",
    "first_seen_at": 1794214800000,
    "last_seen_at": 1794214800000,
    "resolved_at": 1794214800000,
    "dismissed_at": 1794214800000
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Resume a database

POST/v1/databases/{database\_uuid}/resume

Resumes a paused database: collection and billing start again and the payment status is checked first. The time of the last report is cleared, so nothing alarms until the first report after the resume. Refused when the database is not paused. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database after it was resumed.

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

**POST /v1/databases/{database_uuid}/resume**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/resume \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->resume('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.resume('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.resume('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (402 Payment Required)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Run a database's advisor

POST/v1/databases/{database\_uuid}/advisor-run

Queues one advisor pass on the database’s active collector, to run now. The pass runs when the collector’s agent next checks in, so the answer is the database as it stands, not the findings. Refused when the advisor cannot run it now. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`202 Accepted`:

The advisor run was queued; the body is the database as it stands.

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/databases/{database_uuid}/advisor-run**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/advisor-run \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->runAdvisor('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.runAdvisor('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.run_advisor('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (202 Accepted)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

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

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## List a database's schema changes

GET/v1/databases/{database\_uuid}/schema-changes

Lists the changes detected in a database’s schema, newest first, one page at a time. Filter by kind, action or schema, and by a time window; without a window every change is listed. Object names are returned only when the database shows identifiers; the keys always tell objects apart. 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 `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Query parameters

- `kind` (string or null): Only changes to this kind of object: `table`, `view` or `routine`; without it the history markers are listed too. Values:`table``view``routine`(an open set: new values may be added)
- `action` (string or null): Only changes of this action: `created`, `altered`, `renamed` or `dropped`. Values:`created``altered``renamed``dropped`(an open set: new values may be added)
- `schema_key` (string or null): Only changes in the schema with this key, as `databases.storage` and a change’s `schema_key` give it.
- `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.
- `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 number of items in a page, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of the database’s schema changes.

Each item of the page:

- `detected_at` (integer or null): Epoch milliseconds. When the pass detected the change. An instant: epoch milliseconds, UTC.
- `kind` (string): What changed: `table`, `view` or `routine`; `marker` for a history marker, listed only without a filter.
- `action` (string): What happened to it: `created`, `altered`, `renamed` or `dropped`; a marker’s own action otherwise.
- `object_key` (string or null): The changed object’s key, which tells objects apart when their names are hidden; null on a marker.
- `previous_object_key` (string or null): The key the object had before a rename; null otherwise.
- `schema_key` (string or null): The key of the object’s schema; null on a marker.
- `names` (object or null): The names of the keys involved; null unless the database shows identifiers.
- `details_unavailable` (boolean or null): Whether the change’s details could not be kept; null when not applicable.

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/databases/{database_uuid}/schema-changes**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/schema-changes \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

foreach ($wt15->databases->schemaChanges('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')->autoPaging() as $item) { echo $item->kind, "\n"; }
```

Node.js:

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

for await (const item of wt15.databases.schemaChanges('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')) {
  console.log(item.kind);
}
```

Python:

```python
client = Client.from_environment()

for item in client.databases.schema_changes('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b'):
    print(item.kind)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "detected_at": 1794214800000,
      "kind": "example",
      "action": "example",
      "object_key": "example",
      "previous_object_key": "example",
      "schema_key": "example",
      "names": {},
      "details_unavailable": true
    }
  ],
  "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 database.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

## Get a database's storage

GET/v1/databases/{database\_uuid}/storage

Returns a database’s size, growth and forecast, the projected size after 30, 90, 180 and 365 days, its ceiling, and its current schemas and tables by size, largest first. Schemas and tables are empty for a database that keeps counts only, and names are returned only when the database shows identifiers.

Needs the scope `database.view`.

### Path parameters

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database’s storage, forecast, schemas and tables.

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/databases/{database_uuid}/storage**

curl:

```bash
curl https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/storage \
  -H "Authorization: Bearer $WT15_API_KEY"
```

PHP:

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

$result = $wt15->databases->storage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.storage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.storage('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "measured_at": 1794214800000,
    "size_bytes": 1,
    "days_to_full": 1,
    "forecast_status": "example",
    "growth_bytes_per_day": 1,
    "projections": {
      "days_30": 1,
      "days_90": 1,
      "days_180": 1,
      "days_365": 1
    },
    "ceiling": {
      "source": "example",
      "bytes": 1
    },
    "schemas": [
      {
        "key": "example",
        "name": "example",
        "size_bytes": 1,
        "table_count": 1
      }
    ],
    "tables": [
      {
        "key": "example",
        "schema_key": "example",
        "name": "example",
        "size_bytes": 1,
        "rows_estimate": 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 database.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"
}
```

## Verify a database's collectors

POST/v1/databases/{database\_uuid}/verify

Asks every collector that can currently collect to probe the database again. The probes run when each agent next checks in, about 15 to 35 seconds later, and their results appear on the database. Refused for a draft and for a paused database. Answers the database as `databases.view` does.

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

- `database_uuid` (string (uuid), required): The uuid of the database.

### Returns

`200 OK`:

The database as it stands while the collectors probe again.

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/databases/{database_uuid}/verify**

curl:

```bash
curl -X POST https://rest.watchtower15.com/v1/databases/47883cb6-ddae-4ebc-b928-1e4ea70c7e8b/verify \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

PHP:

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

$result = $wt15->databases->verify('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Node.js:

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

const result = await wt15.databases.verify('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b');
```

Python:

```python
client = Client.from_environment()

result = client.databases.verify('47883cb6-ddae-4ebc-b928-1e4ea70c7e8b')
```

**Response (200 OK)**

```json
{
  "data": {
    "uuid": "75666699-b77d-4631-b576-041e8102a55b",
    "name": "example",
    "description": "example",
    "provider": "example",
    "provider_edition": "example",
    "engine": "example",
    "engine_version": "example",
    "engine_flavour": "example",
    "privacy_mode": "example",
    "tls_mode": "example",
    "connection_type": "example",
    "ca_source": "example",
    "auth_method": "example",
    "credentials": {
      "method": "example",
      "user": "example",
      "secret": "example",
      "keys": {
        "user": "example",
        "password": "example",
        "redaction_key": "example"
      },
      "password_parameter": "example",
      "redaction_key_parameter": "example"
    },
    "collector_pool": {
      "selection": "example",
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "all": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "any": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ]
    },
    "reference_key_fingerprint": "example",
    "reported_key_fingerprints": [
      "example"
    ],
    "health_status": "example",
    "status": "example",
    "status_reason": "example",
    "over_privileged": true,
    "layers_available": {},
    "storage": {
      "size_bytes": 1,
      "growth_30d_bytes": 1,
      "days_to_full": 1,
      "forecast_status": "example",
      "ceiling_gib": 1,
      "measured_at": 1794214800000
    },
    "schema": {
      "outcome": "example",
      "last_attempt_at": 1794214800000,
      "last_pass_at": 1794214800000,
      "next_pass_at": 1794214800000,
      "paused_reason": "example",
      "paused_since": 1794214800000,
      "object_counts": {
        "tables": 1,
        "views": 1,
        "routines": 1
      },
      "history_started_at": 1794214800000,
      "last_change_at": 1794214800000
    },
    "last_received_at": 1794214800000,
    "tags": [
      {
        "uuid": "75666699-b77d-4631-b576-041e8102a55b",
        "name": "example"
      }
    ],
    "console_url": "example"
  }
}
```

**Response (401 Unauthorized)**

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

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

**Response (403 Forbidden)**

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

```json
{
  "type": "https://docs.watchtower15.com/api/errors/forbidden/",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "This key does not have the database.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"
}
```

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