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

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

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

## 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`
- 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 `202`

Restore run started

- RestoreRunView
  - `cancel_requested_at` string, nullable: When cancellation was requested, if it was.
  - `cancellable` boolean, required: Whether `POST /restore-runs/{id}/cancel` would be accepted now.
  - `created_at` string, required
  - `error_message` string, nullable
  - `finished_at` string, nullable
  - `id` integer, required
  - `mode` string, required
  - `not_cancellable_reason` string, nullable: Why the run cannot be cancelled now; `None` when `cancellable`.
  - `phase` string, required
  - `recovery_target` unknown
  - `source_backup` RestoreRunSourceBackup, required: The backup this run restores from, so a client can show and link to it. Always present; its fields are `None` where they are unknown.
    - `backup_id` string, nullable: The backup's UUID, which addresses it in the console and the `/backups/{id}` API. `None` for a raw-location restore, or when the tracked backup has since been deleted.
    - `id` integer, nullable: `backups.id` of a tracked backup. `None` for a restore from a raw S3 location (a backup this instance did not record).
    - `location` string, nullable: Object key or `s3://` URL of the backup.
    - `s3_source_id` integer, nullable: S3 source holding the backup.
    - `taken_at` string, nullable: When the backup was taken (ISO 8601). `None` when unknown.
  - `source_backup_id` integer, nullable
  - `source_service_id` integer, required
  - `started_at` string, nullable
  - `status` string, required
  - `target_service_id` integer, nullable
  - `target_service_name` string, nullable

## Other responses

- `400`: Validation error
- `401`: Unauthorized
- `403`: Insufficient permissions
- `404`: Backup or service not found
- `409`: Conflict: a destructive cross-service restore requires explicit confirmation (`cross-service-restore-not-confirmed`), another restore is already active on this service (`restore-already-active`, with `active_restore_run_id`), data is being imported into it (`data-import-active`, with `active_data_import_run_id`), the backup is being deleted or has not completed (pending, running or failed), or a requested new-service name is already owned by a service or another active restore

## Changes

- **2026-11-24** `cf1ae7a3fbbb`: 2 breaking
  - the response property `source_backup_id` became nullable for the status `202`
  - the response property `source_backup_id` became optional for the status `202`
- **2026-11-09** `12896146b193`: 5 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
  - …1 more
- **2026-10-07** `2e9a6212c4d0`: 3 info
  - added the optional property `cancel_requested_at` to the response with the `202` status
  - added the optional property `not_cancellable_reason` to the response with the `202` status
  - added the required property `cancellable` to the response with the `202` status
- **2026-10-07** `ba1c48bc59ad`: 1 info
  - added the required property `source_backup` to the response with the `202` status
- **2026-10-05** `2abc91dc37e1`: 2 info
  - added the new optional request property `allOf[subschema #2]/confirm_cross_service`
  - added the non-success response with the status `409`

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