# OS updates

The agent reads the host’s own package manager (`dnf`, `yum` or `apt`) from what it already has on disk. It never runs the package manager, and never downloads anything itself. Three calls give you what it read:

| Call | Scope | Answers |
| --- | --- | --- |
| `GET /v1/servers/{server_uuid}/os-updates` | `servers.view` | `200`, the summary: counts, release, kernel, reboot, freshness |
| `GET /v1/servers/{server_uuid}/os-updates/packages` | `security.view` | `200`, a page of pending packages |
| `POST /v1/servers/{server_uuid}/os-updates/recheck` | `security.edit` | `202`, the recheck the agent will answer |

The summary carries counts only. Package names and versions are a map of what an attacker could use, so the list needs `security.view`, as the console’s drawer does. A key needs the scope and your role the same permission; see [authentication and keys](https://developer.watchtower15.com/api/authentication/).

An uuid that does not exist, or belongs to another organisation, answers `404` `not_found`: the two cannot be told apart. A scope or permission the key lacks answers `403` `forbidden`.

## Read the summary

`GET /v1/servers/{server_uuid}/os-updates` returns one object per server, built from the same report the console’s OS updates card shows.

-   **`status`** is `ok`, `no_metadata` (the host has no package lists, or it runs Windows), `unsupported`, `failed` or `not_reported` (no report yet). The set is open: treat a value you do not know as “not counted”.
-   **`reported_at`** and **`stale`**: when the last report arrived, and `true` when that is over two days ago. `observed_at` is when the agent read the host.
-   **`host`** is what the host’s own package manager sees. `security_by_level` counts security updates as `critical`, `important`, `moderate`, `low` and `unknown` (an advisory that gives no severity). `security_published` is `false` when the host’s package sources publish no security data, and then `updates_security` is `null`, never 0.
-   **`security_by_level`**, in `host` and in `at_latest`, is `null` when its levels are not known, never a row of zeros: always on Ubuntu and Debian, whose package lists give no severity, and on other servers until their levels have been read. Read `updates_security` for the total.
-   **`release_locked`** and **`at_latest`** are for Amazon Linux 2023 only, below.
-   **`kernel`** and **`reboot`**: the running kernel and the newest one present on the host, and whether the host needs a reboot, since when and why.
-   **`recheck`**: whether you can ask for a recheck now, and the last one asked. `recheck.state` `available` means `POST /v1/servers/{server_uuid}/os-updates/recheck` (scope `security.edit`) will be accepted now.

Every time is in epoch milliseconds, as everywhere in the API (see [times and windows](https://developer.watchtower15.com/api/times-and-windows/)).

```plaintext
curl https://rest.watchtower15.com/v1/servers/$SERVER_UUID/os-updates \
  -H "Authorization: Bearer $WT15_API_KEY"
```

```json
{
  "data": {
    "package_manager": "dnf",
    "status": "ok",
    "reason": null,
    "observed_at": 1794563310000,
    "reported_at": 1794563312000,
    "stale": false,
    "metadata_refreshed_at": 1794559800000,
    "host": {
      "updates_total": 0,
      "updates_security": 0,
      "security_published": true,
      "security_by_level": { "critical": 0, "important": 0, "moderate": 0, "low": 0, "unknown": 0 },
      "security_pending_since": null,
      "packages_truncated": false
    },
    "release_locked": {
      "current": "2023.5.20240624",
      "follows_latest": false,
      "latest": "2023.9.20251110",
      "latest_released_on": "2025-11-10",
      "releases_behind": 31,
      "days_behind": 498
    },
    "at_latest": {
      "status": "matched",
      "reason": null,
      "release": "2023.9.20251110",
      "matched_at": 1794563400000,
      "checked_at": 1794563460000,
      "stale": false,
      "updates_total": 214,
      "updates_security": 96,
      "security_by_level": { "critical": 4, "important": 51, "moderate": 38, "low": 3, "unknown": 0 },
      "advisory_counts": { "critical": 3, "important": 44, "moderate": 29, "low": 2, "unknown": 0, "total": 78 },
      "kernel_candidate": "6.1.158-178.288.amzn2023",
      "security_pending_since": 1780000000000,
      "packages_truncated": false
    },
    "kernel": { "running": "6.1.94-99.176.amzn2023", "newest_present": "6.1.94-99.176.amzn2023", "update_available": false },
    "reboot": { "required": false, "since": null, "source": null, "package_count": 0 },
    "recheck": { "state": "available", "available_at": null, "last": null }
  }
}
```

A server that has not reported answers `status` `not_reported` with every other field `null` but `recheck`.

## Amazon Linux 2023: the host and the latest release

An Amazon Linux 2023 server is locked to the release it was built from. Inside that release its package manager sees almost nothing waiting, however far behind it is. So the summary answers two scopes:

-   **`host`**: what `dnf check-update` on the server would list, inside its locked release.
-   **`at_latest`**: what `dnf upgrade --releasever=latest` would install, with the severity of every security update and the advisories behind them. WatchTower15 matches the server’s package inventory against Amazon’s own metadata for the latest release every hour, and within about 5 minutes of a new inventory.

`release_locked` says which release the server is on and how far behind it is. Both are `null` on a server that is not a locked Amazon Linux 2023 server (Ubuntu, a server that follows `latest`, Windows). `at_latest.status` is `matched`, `awaiting_match` (no inventory matched yet), `no_inventory` or `index_unavailable`; its `stale` is `true` when the match was last confirmed over two days ago.

> **The fifth level:** `security_by_level` has a fifth key, `unknown`, in both scopes, for a security update whose advisory gives no severity. Ubuntu and Debian servers have no levels at all: read `updates_security` for their total.

## List the pending packages

`GET /v1/servers/{server_uuid}/os-updates/packages` returns a page of the packages the server has waiting, security updates first. The list pages by `page` and `per_page` like every page list: see [pagination](https://developer.watchtower15.com/api/pagination/).

### Parameters

| Parameter | Type | Meaning |
| --- | --- | --- |
| `scope` | `host`, `latest` | `host` (the default): what the host’s own package manager lists. `latest`: what `dnf upgrade --releasever=latest` would install on a server locked to an Amazon Linux 2023 release; empty for any other server. The set is open. |
| `security_only` | boolean | `true` lists only security updates. |
| `per_page` | integer | Rows per page, 1 to 100; 25 by default. `limit` is the same. |
| `page` | integer | The page to read, from 1; 1 by default. |

### Returns

`data`, the packages; `current_page`, `per_page`, `last_page` and `total`, the number of stored packages that match; and `meta`: the `scope` read, `updates_total`, the scope’s own count of pending updates, `truncated`, `true` when the server had more than 500 and only the first 500 are kept, and `release`, on the `latest` scope the Amazon Linux 2023 release the match was made against (the summary’s `at_latest.release`), `null` on `host` and when no match is stored.

### A package

| Field | Type | Meaning |
| --- | --- | --- |
| `name` | string | The package’s name. |
| `arch` | string | Its architecture, such as `x86_64` or `noarch`. |
| `current_version` | string | The version on the host now. |
| `available_version` | string | The version the update installs. |
| `repository` | string or `null` | The repository that offers it. On the `host` scope, the one the host’s package manager offers it from; on the `latest` scope, always `amazonlinux`, because the latest-release list is read from Amazon’s AL2023 core repository. |
| `security` | boolean | Whether a security advisory names this update. |
| `severity` | string or `null` | `critical`, `important`, `moderate`, `low` or `unknown`: the worst severity of the advisories that name it; `unknown` for a security update whose advisory gives none; `null` when it is not a security update. The set is open. |
| `vendor_severity` | string or `null` | That severity in the distribution’s own words. |
| `advisory` | string or `null` | The id of the worst advisory. |
| `advisories` | array | `latest` scope only: every advisory that names the update, worst first, at most 16. Never `null`: it is empty on the `host` scope, and empty when none is known yet, so a `latest` row with `advisory` set and `advisories` empty was matched before the advisories were kept and has them after the next hourly match. |
| `advisories[].id` | string | The advisory’s id, such as `ALAS2023-2025-1180`. |
| `advisories[].severity` | string | Its severity. |
| `advisories[].cve_ids` | array of strings | The CVE ids it fixes, at most 32. |
| `advisories[].cve_ids_truncated` | boolean | `true` when it names more than 32. |
| `advisories_truncated` | boolean or `null` | `true` when more than 16 advisories name the update; `null` on the `host` scope. |
| `only_at_latest` | boolean or `null` | `latest` scope only: `true` when the host’s own list does not have this update, so only moving to the latest release brings it. `null` on the `host` scope, and when the host’s list was cut at 500, since a package past the cut would read `true`. |

```plaintext
curl -G https://rest.watchtower15.com/v1/servers/$SERVER_UUID/os-updates/packages \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -d scope=latest \
  -d security_only=true \
  -d per_page=2
```

```json
{
  "data": [
    {
      "name": "openssl-libs",
      "arch": "x86_64",
      "current_version": "1:3.0.8-1.amzn2023.0.12",
      "available_version": "1:3.2.2-1.amzn2023.0.2",
      "repository": "amazonlinux",
      "security": true,
      "severity": "important",
      "vendor_severity": "important",
      "advisory": "ALAS2023-2025-1180",
      "advisories": [
        { "id": "ALAS2023-2025-1180", "severity": "important", "cve_ids": ["CVE-2025-9230", "CVE-2025-9231"], "cve_ids_truncated": false },
        { "id": "ALAS2023-2024-0705", "severity": "moderate", "cve_ids": ["CVE-2024-5535"], "cve_ids_truncated": false }
      ],
      "advisories_truncated": false,
      "only_at_latest": true
    }
  ],
  "current_page": 1,
  "per_page": 2,
  "last_page": 9,
  "total": 18,
  "meta": { "scope": "latest", "updates_total": 214, "truncated": false, "release": "2023.12.20261102" }
}
```

## Recheck after you patch

`POST /v1/servers/{server_uuid}/os-updates/recheck`

The agent reads the package manager’s state on a schedule, so a server you have just patched can show the old counts for a while. A recheck asks the agent to read it again at once and send it. The call takes no body and answers `202` with the recheck; the agent answers it within a few minutes.

### Follow it

Read the summary until `recheck.last.status` is no longer `pending` or `dispatched`:

-   **`completed`**: the agent’s report arrived. Then read `status`: when it is `ok`, `host` and `reported_at` are current. When it is `failed`, the agent could not read the package manager (`reason` says why, for example `rpmdb_busy` while a patch is still finishing), and the counts are those of the last report that could: ask again once `recheck.available_at` has passed. On Amazon Linux 2023, `at_latest` follows within about 5 minutes when the installed packages changed: watch `at_latest.matched_at`.
-   **`expired`**: no report arrived within 15 minutes. Nothing more happens; ask again.

### When a recheck is refused

The summary’s `recheck.state` says, before you call, whether a recheck would be accepted: `available`, or the reason it would not be. A refused call answers `422` `invalid_request` on `os_updates_recheck`, with the sentence below, and starts nothing. The reasons are checked in this order:

| `recheck.state` | When | The sentence |
| --- | --- | --- |
| `unsupported` | The server runs Windows. | Windows servers report their updates from Windows Update: a recheck is not available for them. |
| `container` | The agent runs in a container, which has no package manager to read. | This agent runs in a container: pending updates are not read for container installs. |
| `agent_update` | The server’s agent is older than the recheck. | The agent on this server needs updating before it can recheck its updates. |
| `not_active` | The server or its agent is switched off or not approved. | The server or its agent is not active. |
| `pending` | A recheck is still waiting for the agent. | A recheck is already waiting for the agent. |
| `too_soon` | The last recheck was asked less than 10 minutes ago; `available_at` says when the next one can be. | One recheck every 10 minutes: try again later. |

> **Read the state first:** If `recheck.state` is not `available`, the call will be refused. On `too_soon`, wait until `available_at`; on `pending`, wait for the recheck already asked.

A call can carry an `Idempotency-Key`, so a script that timed out can send it again without asking twice: see [idempotent requests](https://developer.watchtower15.com/api/idempotent-requests/).

```plaintext
curl -X POST https://rest.watchtower15.com/v1/servers/$SERVER_UUID/os-updates/recheck \
  -H "Authorization: Bearer $WT15_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```json
{
  "data": {
    "state": "pending",
    "available_at": null,
    "last": {
      "uuid": "8b1d6f3e-2c4a-4e7b-9a50-3f6d1c2e8a47",
      "status": "pending",
      "issued_at": 1794563700000,
      "expires_at": 1794564600000,
      "completed_at": null
    }
  }
}
```

```json
{ "type": "…/api/errors/invalid_request/", "status": 422, "code": "invalid_request",
  "detail": "The request is invalid",
  "errors": { "os_updates_recheck": ["One recheck every 10 minutes: try again later."] } }
```

## Example: check a server after patching

Ask for a recheck, wait for it, then read the counts. A script that patches many servers can do this for each one; each server takes one recheck every 10 minutes.

```plaintext
api=https://rest.watchtower15.com/v1/servers/$SERVER_UUID/os-updates
auth="Authorization: Bearer $WT15_API_KEY"

curl -sS -X POST "$api/recheck" -H "$auth" -H "Idempotency-Key: $(uuidgen)"

# every 30 s, up to 15 minutes
until s=$(curl -sS "$api" -H "$auth" | jq -r .data.recheck.last.status);
      [ "$s" = completed ] || [ "$s" = expired ]; do sleep 30; done

# the counts are current only when status is "ok"
curl -sS "$api" -H "$auth" | jq '.data | {status, reason, reported_at, host: .host.security_by_level}'
```

Source: https://developer.watchtower15.com/api/os-updates/
