---
title: "POST /external-services/{id}/restore-plan"
method: POST
path: "/external-services/{id}/restore-plan"
tags: ["Restore"]
---

# POST /external-services/{id}/restore-plan

`POST /external-services/{id}/restore-plan`

## 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}/restore-plan`
- Auth: HTTP bearer

## Path parameters

- `id` integer, required

## Request body

- union
  - object: Restore the backup onto the existing service (destructive).
    - `mode` 'in_place', required
    - `backup_engine` string, nullable: Engine of the backup when specified by `backup_location` ("postgres", "redis", "mongodb", "s3"). Ignored when `backup_id` is used — we infer from the DB row.
    - `backup_id` integer, nullable: DB id of the backup to restore from. Either `backup_id` or `backup_location` MUST be provided. Use `backup_id` when restoring a backup this Temps instance recorded.
    - `backup_location` string, nullable: Raw S3 URL / key of the backup — used when restoring a backup discovered by S3 scan (i.e., produced by another Temps instance). Requires `backup_engine` and `s3_source_id` to also be set.
    - `confirm_cross_service` boolean: Explicit confirmation for a destructive cross-service restore. Restoring in place (or PITR in place) onto a service that did not produce the backup — or from a raw backup location whose origin is unknown — overwrites the target with another service's data. Such a request is rejected with `409 Conflict` unless this is `true`. The confirmation is recorded in the audit log. Ignored for modes that provision a new service and for same-service restores.
    - `s3_source_id` integer, nullable: S3 source the `backup_location` lives in. Ignored when `backup_id` is used.
  - object: Provision a new service and restore into it.
    - `mode` 'new_service', required
    - `name` string, required: Name for the new service. Orchestrator auto-suggests `{source}-restore-{yyyymmdd-hhmm}` if caller omits, but we require an explicit value at the API boundary.
    - `parameter_overrides` unknown
    - `backup_engine` string, nullable: Engine of the backup when specified by `backup_location` ("postgres", "redis", "mongodb", "s3"). Ignored when `backup_id` is used — we infer from the DB row.
    - `backup_id` integer, nullable: DB id of the backup to restore from. Either `backup_id` or `backup_location` MUST be provided. Use `backup_id` when restoring a backup this Temps instance recorded.
    - `backup_location` string, nullable: Raw S3 URL / key of the backup — used when restoring a backup discovered by S3 scan (i.e., produced by another Temps instance). Requires `backup_engine` and `s3_source_id` to also be set.
    - `confirm_cross_service` boolean: Explicit confirmation for a destructive cross-service restore. Restoring in place (or PITR in place) onto a service that did not produce the backup — or from a raw backup location whose origin is unknown — overwrites the target with another service's data. Such a request is rejected with `409 Conflict` unless this is `true`. The confirmation is recorded in the audit log. Ignored for modes that provision a new service and for same-service restores.
    - `s3_source_id` integer, nullable: S3 source the `backup_location` lives in. Ignored when `backup_id` is used.
  - object: Point-in-time recovery. Only valid on a backup that anchors a continuous change stream: a WAL-G base (Postgres) or a physical `mariadb-backup` base with archived binary logs (MariaDB).
    - `mode` 'pitr', required
    - `new_service_name` string, nullable: Required when `to_new_service` is true.
    - `target` union, required: Recovery target kind + value.
      - object: Recover to a specific timestamp.
        - `kind` 'time', required
        - `time` string, date-time, required
      - object: Recover to a specific transaction id (Postgres).
        - `kind` 'xid', required
        - `xid` string, required
      - object: Recover to a specific log sequence number (Postgres).
        - `kind` 'lsn', required
        - `lsn` string, required
      - object: Recover to a named restore point created via `pg_create_restore_point` (Postgres).
        - `kind` 'name', required
        - `name` string, required
    - `to_new_service` boolean, required: Whether PITR restores in place or creates a new service.
    - `backup_engine` string, nullable: Engine of the backup when specified by `backup_location` ("postgres", "redis", "mongodb", "s3"). Ignored when `backup_id` is used — we infer from the DB row.
    - `backup_id` integer, nullable: DB id of the backup to restore from. Either `backup_id` or `backup_location` MUST be provided. Use `backup_id` when restoring a backup this Temps instance recorded.
    - `backup_location` string, nullable: Raw S3 URL / key of the backup — used when restoring a backup discovered by S3 scan (i.e., produced by another Temps instance). Requires `backup_engine` and `s3_source_id` to also be set.
    - `confirm_cross_service` boolean: Explicit confirmation for a destructive cross-service restore. Restoring in place (or PITR in place) onto a service that did not produce the backup — or from a raw backup location whose origin is unknown — overwrites the target with another service's data. Such a request is rejected with `409 Conflict` unless this is `true`. The confirmation is recorded in the audit log. Ignored for modes that provision a new service and for same-service restores.
    - `s3_source_id` integer, nullable: S3 source the `backup_location` lives in. Ignored when `backup_id` is used.

## Response `200`

Preview of what the restore will do

- RestorePlan: Preview of a restore operation. Answers "what will happen if I click start?" with engine-level specificity so the user can confirm before committing to a destructive action.
  - `cross_service` boolean, required: Whether the backup was produced by a service other than the target (or its origin is unknown). A destructive cross-service restore must be confirmed explicitly with `confirm_cross_service: true`.
  - `destructive` boolean, required: Whether any step overwrites existing data on the target service.
  - `engine` string, required: Target engine ("postgres", etc.).
  - `errors` string[], required: Blocking problems. The UI disables the Start button when non-empty.
  - `mode` string, required: Echo of the requested mode for the UI.
  - `source_backup` PlanSourceBackup, required: Backup we'll read from.
    - `created_at` string, nullable
    - `format` string, required: "walg", "pg_dump", "mariadb_physical", "mariadb_dump", "mongodump", "redis_rdb", "s3_mirror", "unknown".
    - `id` integer, nullable: DB id, absent for orphan (S3-scan) backups.
    - `location` string, required: Resolved S3 location the orchestrator will actually use.
    - `location_was_resolved` boolean, required: True when the original row's `s3_location` was empty and we resolved a location by probing S3. The UI shows this as a warning.
    - `origin_service_name` string, nullable: Service that originally produced the backup, if known.
    - `size_bytes` integer, nullable
  - `steps` string[], required: Ordered list of human-readable actions the orchestrator will take.
  - `strategy` string, required: How the restore will be performed: "walg_restore", "pg_dump_restore", "mariadb_physical_restore", "mariadb_dump_restore", "mongodump_restore", "redis_rdb_restore", "s3_mirror_restore", or "unsupported".
  - `target_service` PlanTarget, required: Service we'll operate on (or provision a sibling of).
    - `container` string, required: Expected Docker container name.
    - `id` integer, required
    - `name` string, required
  - `warnings` string[], required: Non-blocking caveats the user should see (cross-service, empty location that will be auto-resolved, missing engine metadata, ...).

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions (requires backups:write)
- `404`: Backup or service not found

## Changes

- **2026-11-09** `12896146b193`: 4 breaking
  - removed the required property `extensions` from the response with the `400` status
  - removed the required property `extensions` from the response with the `401` status
  - removed the required property `extensions` from the response with the `403` status
  - removed the required property `extensions` from the response with the `404` status
- **2026-10-05** `2abc91dc37e1`: 2 info
  - added the new optional request property `allOf[subschema #2]/confirm_cross_service`
  - added the required property `cross_service` to the response with the `200` status
- **2026-10-05** `4b228ebed583`: 4 info
  - added the optional property `status` to the response with the `400` status
  - added the optional property `status` to the response with the `401` status
  - added the optional property `status` to the response with the `403` status
  - added the optional property `status` to the response with the `404` status
- **2026-10-05** `63a80791dc58`: 4 warning
  - removed the optional property `status` from the response with the `400` status
  - removed the optional property `status` from the response with the `401` status
  - removed the optional property `status` from the response with the `403` status
  - removed the optional property `status` from the response with the `404` status
- …earlier changes not shown

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