# Security images

Container images running on the organisation’s servers, with the servers that run them and the vulnerabilities found in them.

Its operations need the scope `servers.view`.

**Endpoints**

- `GET/v1/security/images`

## List container images

GET/v1/security/images

Lists the images the organisation’s monitored servers run (an archived, paused or revoked server is left out), one row per image digest (or image name when the digest is not known), with the servers that run it and its open findings. Filter by a vulnerability id to find every image that has it. 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 `servers.view`.

### Query parameters

- `search` (string or null): Only images with a running container whose image name contains this text, case does not matter; at most 128 characters.
- `image_digest` (string or null): Only this image digest: `sha256:` and 64 lowercase hexadecimal characters.
- `vulnerability_id` (string or null): Only images with an open finding of this vulnerability id, such as `CVE-2024-1234`; case does not matter.
- `severity` (array of strings or null): Only images with an open finding at one of these levels: `critical`, `warning` or `info`. A list: repeat the parameter (`severity=critical&severity=warning`) or send one value (`severity=critical`); `severity[]=critical` is accepted too. Values:`critical``warning``info`(an open set: new values may be added)
- `kev` (string or null): `true` lists only images with an open known exploited vulnerability, `false` only images with none (`true`, `false`, `1` or `0`). Values:`true``false``1``0`(an open set: new values may be added)
- `sort` (string or null): The column to sort by: `image_ref` (the default), `server_count`, `last_seen` or `findings` (open critical findings first, then warning, then info). Values:`image_ref``server_count``last_seen``findings`(an open set: new values may be added)
- `direction` (string or null): The sort direction, `asc` (the default) or `desc`. Values:`asc``desc`(an open set: new values may be added)
- `limit` (integer or null): The same as `per_page`, kept for existing clients.
- `include_total` (string or null): Ignored: `total` is always present. Values:`true``false``1``0`(an open set: new values may be added)
- `per_page` (integer or null): How many items one page holds, from 1 to 100; 25 when omitted.
- `page` (integer or null): The page to read, from 1; 1 when omitted. A page past the last answers no rows.

### Returns

`200 OK`:

One page of images.

Each item of the page:

- `image_digest` (string or null): The image’s digest, `sha256:` and 64 hexadecimal characters; null when the agent could not read it (the image is then known by its name).
- `image_ref` (string or null): The image’s name as the newest of its containers reports it; it comes from the host, so treat it as untrusted text.
- `image_refs` (array of strings): Up to five distinct names the image’s containers report, the newest first; they come from the host, so treat them as untrusted text.
- `server_count` (integer): How many monitored servers run the image.
- `container_count` (integer): How many running containers run the image.
- `servers` (array of objects): Up to ten of the servers that run the image, by name.
  - `uuid` (string): The UUID of the server.
  - `name` (string): The name of the server; it comes from the host, so treat it as untrusted text.
- `findings` (object): The image’s open vulnerability findings, each vulnerability in each package counted once however many of its containers carry it.
  - `open` (integer): The open findings.
  - `critical` (integer): Open findings at the critical level (a known exploited vulnerability, or a critical vendor severity).
  - `warning` (integer): Open findings at the warning level (not known exploited, with a high or medium vendor severity).
  - `info` (integer): Open findings at the info level (the rest).
  - `kev` (integer): Open findings that are known exploited vulnerabilities.
- `last_seen_at` (integer): Epoch milliseconds. The latest time the agent listed one of the image’s running containers. 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/security/images**

curl:

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

PHP:

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

foreach ($wt15->securityImages->list()->autoPaging() as $item) { echo json_encode($item), "\n"; }
```

Node.js:

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

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

Python:

```python
client = Client.from_environment()

for item in client.security_images.list():
    print(item)
```

**Response (200 OK)**

```json
{
  "data": [
    {
      "image_digest": "example",
      "image_ref": "example",
      "image_refs": [
        "example"
      ],
      "server_count": 1,
      "container_count": 1,
      "servers": [
        {
          "uuid": "75666699-b77d-4631-b576-041e8102a55b",
          "name": "example"
        }
      ],
      "findings": {
        "open": 1,
        "critical": 1,
        "warning": 1,
        "info": 1,
        "kev": 1
      },
      "last_seen_at": 1794214800000
    }
  ],
  "current_page": 1,
  "per_page": 1,
  "last_page": 1,
  "total": 1,
  "meta": {
    "unidentified_containers": 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 servers.view scope",
  "request_id": "4d1e8b7a-2c9f-4a3e-b6d5-7f0c1a2e3b4d"
}
```

**Response (404 Not Found)**

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

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

**Response (422 Unprocessable Content)**

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

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

**Response (429 Too Many Requests)**

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

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

**Response (500 Internal Server Error)**

An unexpected error.

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

Source: https://developer.watchtower15.com/api/reference/security-images/
