deploy.host-database-branches.create

Cut a branch: a full copy of the database, on the same pool host

POST /deploy/api/apps/{id}/host-database/branchesIAM deploy:ManageHostDatabaseChanges state

The pool host copies the database (pg_dump and pg_restore into a new database with its own role) while the app keeps running: the copy holds the data as of its start. It takes seconds for a small database and longer for a big one; state goes creating, then ready or failed. A branch is not billed, has the database’s size limit, and is deleted after expiresInHours. At most 2 branches per app; the pool host refuses one it has no disk for.

Request syntax

POST /deploy/api/apps/{id}/host-database/branches
{
  "expiresInHours": "number"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • expiresInHoursOptional

    number

    Hours until the branch is deleted, 1 to 168 (7 days); 24 when not given

    Constraints: integer, 1-168

Response

202 with `data`: the branch as get describes it, state creating. 400 for an app not on pooled hosting; 404 when the app has no active pool-host database; 409 when the app already has 2 branches, its database is being restored, or its pool host is not ready.

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Fields of data

  • idAlways

    string

    Branch id
  • appIdAlways

    string

    The app whose database it copies
  • nameAlways

    string

    Its database (and role) name on the pool host
  • parentNameAlways

    string

    The database it was copied from
  • stateAlways

    one of creating, ready, failed, deleting, deleted

    creating, then ready or failed; deleting, then deleted
  • errorAlways

    string, may be null

    Why the copy failed
  • bytesAlways

    number, may be null

    Its size as the pool host last reported it
  • expiresAtAlways

    string

    When it is deleted (ISO 8601)
  • createdAtAlways

    string

    When it was cut
  • readyAtAlways

    string, may be null

    When the copy was done
  • deletedAtAlways

    string, may be null

    When it was deleted
  • migrationAlways

    object, may be null

    The last migrate run on the branch; null before the first
  • migration.​stateAlways

    one of running, done, failed

    running until the pool host answers; done: exit code 0; failed otherwise
  • migration.​deploymentIdAlways

    string, may be null

    The deployment whose migrate command ran
  • migration.​requestedAtAlways

    string, may be null

    When it was asked for
  • migration.​exitCodeAlways

    number, may be null

    Its exit code; -1 when stopped after 10 minutes; null when it could not run
  • migration.​summaryAlways

    string, may be null

    What it did, in one line: "2 columns added, the 42 existing rows stay"
  • migration.​diffAlways

    object, may be null

    The shape before and after, compared; null when it could not run
  • migration.​diff.​summaryAlways

    string

    The same line
  • migration.​diff.​tablesAddedAlways

    array of string

    schema.table
  • migration.​diff.​tablesDroppedAlways

    array of string

    schema.table
  • migration.​diff.​columnsAddedAlways

    array of string

    schema.table.column and its type
  • migration.​diff.​columnsDroppedAlways

    array of string

    schema.table.column
  • migration.​diff.​columnsChangedAlways

    array of string

    schema.table.column: before → after
  • migration.​diff.​indexesAddedAlways

    array of string

    Index definitions
  • migration.​diff.​indexesDroppedAlways

    array of string

    Index definitions
  • migration.​diff.​constraintsAddedAlways

    array of string

    table: name and definition
  • migration.​diff.​constraintsDroppedAlways

    array of string

    table: name and definition
  • migration.​diff.​rowsChangedAlways

    array of string

    table: rows before → after
  • migration.​diff.​rowsBeforeAlways

    number

    Rows in the tables that stayed, before
  • migration.​diff.​rowsAfterAlways

    number

    Rows in those tables, after
  • migration.​logTailAlways

    string, may be null

    The last 64 KiB of its output
  • migration.​errorAlways

    string, may be null

    Why it could not run
  • migration.​finishedAtAlways

    string, may be null

    When the pool host answered

Checked against the handlers: every route test validates their answers against this schema.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow deploy:ManageHostDatabase on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud deploy host-database-branches create id

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_deploy_host-database-branches_create.