---
title: "Postgres WAL & archive health snapshot"
method: GET
path: "/external-services/{id}/wal-health"
tags: ["External Services"]
---

# Postgres WAL & archive health snapshot

`GET /external-services/{id}/wal-health`

## Request

- Base URL: `/api` (relative, and the document was published on a file host, not at the API’s origin)
- URL: `/api/external-services/{id}/wal-health`
- Auth: none declared

Returns the latest WAL/archive health snapshot recorded by the background
health monitor for a Postgres external service. Powers the warning banner
on the service detail page when the disk is filling up due to stale
replication slots, archive backlog, or misconfigured `archive_command`.

Returns 404 when no snapshot exists yet (probe hasn't run, or the service
isn't Postgres). When the last check could not run (a database on a
worker whose agent predates the WAL probe, or cannot be reached), the 404
has type `https://temps.sh/probs/wal-health-not-checked` and carries
`reason` and `checked_at`, so the page can say the check is not happening.

## Path parameters

- `id` integer, required

## Response `200`

Latest WAL health snapshot

- PostgresWalHealth
  - `archive_backlog` integer, required: Number of `archive_status/*.ready` files — un-shipped WAL segments. 0 when `archive_status_unreadable` is set.
  - `archive_command` string, nullable: The literal `archive_command` setting. May be empty or `/bin/true` when archiving is effectively disabled despite `archive_mode = on`.
  - `archive_library` string, nullable: The `archive_library` setting (PostgreSQL 15+), when one archives WAL instead of `archive_command`.
  - `archive_mode` 'off' | 'on' | 'always' | 'unknown', required
  - `archive_oldest_ready_age_secs` integer, nullable: Age of the oldest `archive_status/*.ready` file (seconds), `None` when no segment is waiting.
  - `archive_status_unreadable` boolean: The role may not list `archive_status`: the backlog, the oldest waiting segment's age and stall detection are unknown.
  - `archiver_archived_count` integer, nullable: Segments archived since the statistics were last reset.
  - `archiver_failed_count` integer, nullable
  - `archiver_last_archived_at` string, date-time, nullable: When a segment was last archived successfully.
  - `archiver_last_failed_at` string, date-time, nullable
  - `archiver_last_failed_wal` string, nullable: The segment whose archiving failed last.
  - `max_wal_size_bytes` integer, required: `max_wal_size` setting in bytes (parsed from `pg_settings`).
  - `oldest_wal_age_secs` integer, required: Age of the oldest WAL file in `pg_wal/` (seconds).
  - `pg_wal_bytes` integer, required: Total size of files under `pg_wal/`, from `pg_ls_waldir()`.
  - `probed_at` string, date-time, required: When the snapshot was taken.
  - `stale_slots` StaleSlot[], required
    - `active` boolean, required
    - `retained_bytes` integer, required
    - `slot_name` string, required
  - `warnings` WalWarning[], required: Computed warnings, ordered by severity (critical first).
    - union: One actionable warning surfaced to the UI. Each variant carries the data needed to render a remediation hint without the frontend re-querying anything.
      - object: `pg_wal` is significantly larger than `max_wal_size`.
        - `kind` 'wal_bloat', required
        - `max_wal_size_bytes` integer, required
        - `pg_wal_bytes` integer, required
        - `ratio` number, double, required
      - object: A replication slot is holding WAL it's not consuming.
        - `active` boolean, required
        - `kind` 'stale_slot', required
        - `retained_bytes` integer, required
        - `slot_name` string, required
      - object: `archive_status/*.ready` count exceeds threshold — `archive_command` is either failing or running slower than WAL generation.
        - `kind` 'archive_backlog', required
        - `ready_count` integer, required
      - object: `archive_mode = on` and nothing stores WAL, with no `archive_library` either. With an empty `archive_command`, PostgreSQL keeps every segment waiting for a command and `pg_wal` grows; with a no-op such as `/bin/true`, every segment is counted as archived and recycled, and nothing is stored. `archive_command` on the snapshot tells them apart.
        - `kind` 'archive_mode_without_command', required
      - object: Archiving is on, but the monitoring role may not list `archive_status` (`pg_ls_archive_statusdir()` needs superuser or `pg_monitor`), so a stalled archiver that has reported no failure yet cannot be detected, and the waiting-segment count reads 0.
        - `kind` 'archive_stall_check_unavailable', required
      - object: `archive_command`'s most recent attempt failed and nothing has archived since: PostgreSQL keeps every segment from here on.
        - `kind` 'archive_failing', required
        - `last_archived_at` string, date-time, nullable
        - `last_failed_at` string, date-time, nullable
        - `last_failed_wal` string, nullable
        - `stalled_secs` integer, nullable: How long the oldest un-archived segment has waited, when archiving has stalled rather than (or as well as) failed.
      - object: Oldest WAL segment is older than `WAL_NOT_RECYCLED_AGE_SECS`. Independent signal: something is blocking recycling even if total size hasn't exploded yet.
        - `kind` 'wal_not_recycled', required
        - `oldest_age_secs` integer, required

## Other responses

- `404`: Service not found, or no WAL snapshot available. Type `https://temps.sh/probs/wal-health-not-checked` with `reason` and `checked_at` when the last check could not run
- `500`: Internal server error

## Changes

- **2026-11-13** `15bf7cea2687`: 1 breaking, 3 info
  - added `subschema #4, subschema #5` to the `warnings/items/` response property `oneOf` list for the response status `200`
  - added the optional property `archive_library` to the response with the `200` status
  - added the optional property `archive_status_unreadable` to the response with the `200` status
  - removed `subschema #4` from the `warnings/items/` response property `oneOf` list for the response status `200`
- **2026-11-13** `8b476d8ce3ea`: 1 breaking, 4 info
  - added `subschema #5` to the `warnings/items/` response property `oneOf` list for the response status `200`
  - added the optional property `archive_oldest_ready_age_secs` to the response with the `200` status
  - added the optional property `archiver_archived_count` to the response with the `200` status
  - added the optional property `archiver_last_archived_at` to the response with the `200` status
  - …1 more
- **2026-05-30** `b72341d12f63`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/external-services/:id/wal-health/get.md)

---

[API](https://skmtc.dev/gotempsh/apis/temps.md) - [All operations](https://skmtc.dev/gotempsh/apis/temps/llms.txt) - [OpenAPI document](https://skmtc.dev/gotempsh/apis/temps/revisions/3b040526eb43?raw)
