---
title: "Upgrade external service to new Docker image with data migration This endpoint uses service-specific upgrade procedures (e.g., pg_upgrade for PostgreSQL)"
method: POST
path: "/external-services/{id}/upgrade"
tags: ["External Services"]
---

# Upgrade external service to new Docker image with data migration This endpoint uses service-specific upgrade procedures (e.g., pg_upgrade for PostgreSQL)

`POST /external-services/{id}/upgrade`

## 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}/upgrade`
- Auth: none declared

## Path parameters

- `id` integer, required

## Request body

- UpgradeExternalServiceRequest
  - `docker_image` string, required: Docker image to upgrade to (e.g., "gotempsh/postgres-walg:18-bookworm") This will trigger pg_upgrade for PostgreSQL or equivalent upgrade procedures for other services

## Response `200`

Service upgraded successfully

- ExternalServiceInfo
  - `connection_info` string, nullable
  - `continuous_archive_pinned_at` string, nullable: When `continuous_archive_s3_source_id` was last set. Null alongside a non-null source id means it was set by the original provisioning flow rather than an explicit repoint.
  - `continuous_archive_s3_source_id` integer, nullable: S3 source ID that this service's continuous archiving (Postgres/ Timescale WAL-G `archive_command`, or MariaDB's binlog shipper) currently writes to. Null for service types with no continuous archiving concept, or a Postgres/MariaDB service that has never had one provisioned. Change it with `repoint_continuous_archive_source`.
  - `created_at` string, required
  - `error_message` string, nullable: Error message from failed initialization.
  - `id` integer, required
  - `members` ServiceMemberInfo[]: Cluster members (empty for standalone services).
    - `compute_ip` string, nullable: Container's IP on the `temps-overlay` multi-host network. Populated by the lifecycle hook (ADR-011 Phase 3); `None` on single-host clusters where the overlay isn't attached.
    - `container_name` string, required
    - `hostname` string, nullable
    - `id` integer, required
    - `live_state` string, nullable: Live FSM state from the pg_auto_failover monitor (`primary`, `secondary`, `catchingup`, `report_lsn`, …). `None` when the monitor is unreachable, the service is not a cluster, or the row is the monitor itself. **The UI must render the role badge from this field**, falling back to `role` only when `live_state` is null. `role` is now config-only (`monitor` or `replica`); flipping the badge to "primary" when the monitor elects a new one used to require a reconciler that lagged ~5s behind real failovers — and during that window the UI showed two primaries. `live_state` is read directly from the monitor on every list, so it can never lag.
    - `node_id` integer, nullable
    - `ordinal` integer, required
    - `port` integer, nullable
    - `provisioning_error` string, nullable: Most recent provisioning failure message, when `status='failed'`. Set by the background task so the UI can show *why* the new replica didn't come up.
    - `provisioning_step` string, nullable: Last-attempted phase of the async `add_cluster_member` background task (e.g. `validating`, `provisioning_container`, `done`, `failed`). `None` for members not created through that flow — the UI falls back to the `status` column for those.
    - `role` string, required: Configured member kind. For a PostgreSQL cluster this is `monitor` or `replica`, and every data node is `replica`, including the current primary: which node is primary is runtime state, read it from `live_state`.
    - `status` string, required
  - `metrics_enabled` boolean: Whether metric collection is enabled for this service. The UI uses this to decide whether to poll the monitoring endpoints.
  - `name` string, required
  - `node_id` integer, nullable: Node ID where the service runs. Null means control plane (local).
  - `readiness` ServiceReadiness, nullable: Startup readiness of a service that is `starting` or failed to start.
    - `deadline_secs` integer, required: How long the gate waits before reporting failure.
    - `failure` InitializationFailure, nullable: A failed initialization, as shown to the operator.
      - `kind` 'store_init_failed' | 'restart_loop' | 'timeout', required: Why the gate gave up.
      - `log_excerpt` string[], required: Container log lines that explain the failure, oldest first. Secrets are redacted. Empty when the logs could not be read.
      - `next_actions` ReadinessNextAction[], required: Suggested next steps, most useful first.
      - `reason` string, required: What happened, including the last probe's typed reason.
    - `phase` 'starting' | 'failed', required: Where the gate is for a service.
    - `reason` string, nullable: Latest reason the service is not usable yet, from the engine's authenticated probe. Null before the first probe.
    - `restart_count` integer, required: Container restarts since the gate started.
    - `started_at` string, required: When the gate started waiting (ISO 8601, UTC).
  - `service_type` 'mariadb' | 'mongodb' | 'postgres' | 'redis' | 's3' | 'kv' | 'blob' | 'rustfs' | 'minio', required
  - `status` string, required
  - `topology` string, required: Service topology: "standalone" (single container) or "cluster" (HA multi-member).
  - `updated_at` string, required
  - `version` string, nullable

## Other responses

- `400`: Invalid request or upgrade not supported
- `404`: Service not found
- `409`: A major upgrade is already in progress, or duplicate service names prevent safe resource control
- `500`: Internal server error

## Changes

- **2026-10-09** `c2e6bffeca6c`: 1 info
  - added the optional property `readiness` to the response with the `200` status
- **2026-09-07** `cfd9d4606e8c`: 2 info
  - added the optional property `continuous_archive_pinned_at` to the response with the `200` status
  - added the optional property `continuous_archive_s3_source_id` to the response with the `200` status
- **2026-07-27** `1b060c0a4ba3`: 1 warning, 1 info
  - added the new `mariadb` enum value to the `service_type` response property for the response status `200`
  - added the non-success response with the status `409`
- **2026-06-05** `61b7612b2d33`: 1 info
  - added the optional property `metrics_enabled` to the response with the `200` status
- **2026-05-30** `b72341d12f63`: 4 info
  - added the optional property `members/items/compute_ip` to the response with the `200` status
  - added the optional property `members/items/live_state` to the response with the `200` status
  - added the optional property `members/items/provisioning_error` to the response with the `200` status
  - added the optional property `members/items/provisioning_step` to the response with the `200` status

[Operation history](https://skmtc.dev/gotempsh/apis/temps/changes/external-services/:id/upgrade/post.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)
