---
title: "POST /external-services/{id}/data-imports"
method: POST
path: "/external-services/{id}/data-imports"
tags: ["External Services"]
---

# POST /external-services/{id}/data-imports

`POST /external-services/{id}/data-imports`

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

## Path parameters

- `id` integer, required

## Request body

- StartDataImportRequest: Start importing an external database into a database of this service.
  - `confirm_target_database` string, nullable: Required when `replace` is true: must repeat `target_database`.
  - `replace` boolean: Drop and re-create `target_database` when it already holds data.
  - `source_url` string, required: Connection string of the database to copy, e.g. `postgres://user:password@db.example.com:5432/app?sslmode=require`. Must name the database. Never stored or returned.
  - `target_database` string, required: Database of this service that receives the data. Created when it does not exist; typically a project environment's database (`<project>_<environment>`).
  - `timeout_minutes` integer, nullable: Transfer time limit in minutes (default 60, maximum 1440).

## Response `202`

Import started; poll the run

- DataImportRunResponse: One data import run.
  - `atomic` boolean, required: Whether a failed run leaves no imported data behind.
  - `cancel_requested` boolean, required
  - `created_at` string, date-time, required
  - `created_by` integer, nullable
  - `error_message` string, nullable: Why the run did not succeed, in one or two sentences.
  - `finished_at` string, date-time, nullable
  - `helper_output` string, nullable: Last lines the transfer printed (dump/restore tool output), with every secret removed. Present for successful runs too.
  - `id` integer, required
  - `phase` string, required: `preparing_target`, `transferring`, `verifying` or `finished`. Only a successful run reaches `finished`; otherwise this is where it stopped.
  - `replace_existing` boolean, required
  - `service_id` integer, required
  - `service_type` string, required
  - `source` string, required: Source connection string with its credentials masked.
  - `source_database` string, required
  - `started_at` string, date-time, required
  - `started_by` DataImportRunStarter, nullable: The user who started a data import.
    - `email` string, required
    - `name` string, required
    - `user_id` integer, required
  - `status` string, required: `running`, `succeeded`, `failed`, `cancelled` or `interrupted`.
  - `target_database` string, required
  - `target_object_count` integer, nullable: Tables/collections in the target after a successful import.
  - `target_size_bytes` integer, nullable
  - `timeout_seconds` integer, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: Invalid source connection string, target database, timeout or missing replace confirmation
- `401`: Unauthorized
- `403`: Insufficient permissions, or a deployment token
- `404`: Service not found
- `409`: The service is not running (`service-not-ready`), the target database holds data and replace was not requested (`target-not-empty`), an import into it is already running (`import-already-running`, with `active_run_id`), or the service is being restored (`restore-in-progress`)
- `422`: The service's engine or topology cannot receive imports
- `428`: Replacing a database requires recent MFA verification
- `502`: The target service could not be inspected or prepared
- `503`: This process has no Docker daemon

## Changes

- **2026-11-09** `12896146b193`: 9 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
  - …5 more
- **2026-10-08** `60e75ea854a4`: 1 info
  - endpoint added

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