deploy.previews.configure

Set up, change or turn off an app's preview environments

PUT /deploy/api/apps/{id}/previewsIAM deploy:UpdatePreviewSettingsChanges stateDestructive

A preview is an app of its own on one small machine, at https://<branch>.<app>.<org>.apps.<root>. With trigger pull_request, a pull request into the app’s branch gets one when it opens and loses it when it merges or closes; with branch, every pushed branch other than the app’s gets one and loses it when the branch is deleted. A push to the branch redeploys it. It is deleted idleDays after the last push unless kept. Its env: the app’s plain variables, the secrets named in sharedSecretKeys, then envOverrides. With databaseBranch, a Postgres branch of the app’s bound database (pr-<n> for a pull request); without it, no database. Each step is the commit status `ews/preview`; the pull request gets one comment with the URL and the cost when it first serves. Previews are made as the person who pushed or opened the pull request, who needs deploy:CreatePreview on the app; at most maxPreviews at once.

Request syntax

PUT /deploy/api/apps/{id}/previews
{
  "enabled": "boolean",
  "trigger": "enum",
  "envOverrides": "map of string",
  "sharedSecretKeys": "array of string",
  "databaseBranch": "boolean",
  "idleDays": "number",
  "maxPreviews": "number",
  "instanceType": "string"
}

Path parameters

  • idRequired

    string

    Constraints: uuid

Request body

  • enabledRequired

    boolean

    Whether pull requests (or branches) get preview environments

  • triggerOptional

    enum

    pull_request: a preview per open pull request into the app’s branch; branch: one per pushed branch

    One of: pull_request, branch

    Default: "pull_request"

  • envOverridesOptional

    map of string

    Plain variables set in every preview on top of the app’s (a key here wins)

    Constraints: key=value

    Default: {}

  • sharedSecretKeysOptional

    array of string

    Secret-bound variables of the app that previews get too; every other secret is withheld (plain values are copied)

    Constraints: max 128 chars, /^[A-Za-z_][A-Za-z0-9_]*$/

    Default: []

  • databaseBranchOptional

    boolean

    Give each preview a Postgres branch of the app’s bound database; off: previews get no database binding

    Default: false

  • idleDaysOptional

    number

    Delete a preview this many days after the last push to its branch, unless kept

    Constraints: integer, 1-90

    Default: 7

  • maxPreviewsOptional

    number

    At most this many previews at once; the next one is refused with a commit status

    Constraints: integer, 1-20

    Default: 10

  • instanceTypeOptional

    string

    Machine type of a preview; null: the smallest the region offers

    Constraints: 1-32 chars

    Default: null

    May be null.

Response

200 with `data` as list. 409 when enabled on a pooled app, an app without a repository, or a preview. Turned off, open previews are deleted within the hour.

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

Fields of data

  • settingsAlways

    object, may be null

    null: previews are not set up
  • settings.​enabledAlways

    boolean

    Whether pull requests (or branches) get preview environments
  • settings.​triggerWhen present

    one of pull_request, branch

    pull_request: a preview per open pull request into the app’s branch; branch: one per pushed branch
  • settings.​envOverridesWhen present

    map

    Plain variables set in every preview on top of the app’s (a key here wins)
  • settings.​sharedSecretKeysWhen present

    array of string

    Secret-bound variables of the app that previews get too; every other secret is withheld (plain values are copied)
  • settings.​databaseBranchWhen present

    boolean

    Give each preview a Postgres branch of the app’s bound database; off: previews get no database binding
  • settings.​idleDaysWhen present

    number

    Delete a preview this many days after the last push to its branch, unless kept
  • settings.​maxPreviewsWhen present

    number

    At most this many previews at once; the next one is refused with a commit status
  • settings.​instanceTypeWhen present

    string, may be null

    Machine type of a preview; null: the smallest the region offers
  • repositoryAlways

    object, may be null

    The repository the app builds from; previews need one
  • repository.​idAlways

    string

    The repository
  • repository.​nameAlways

    string

    Its name
  • previewsAlways

    array of object

    Open previews, oldest first
  • previews[].​idAlways

    string

    The preview’s own app id
  • previews[].​nameAlways

    string

    Its name: the app’s, with the pull request or branch
  • previews[].​branchAlways

    string

    The branch it deploys
  • previews[].​prNumberAlways

    number, may be null

    Its pull request; null for a branch preview
  • previews[].​urlAlways

    string

    Where it answers
  • previews[].​statusAlways

    string

    The app status: created, deploying, active, failed, deleting
  • previews[].​instanceTypeAlways

    string

    Its machine type
  • previews[].​eurPerHourAlways

    number, may be null

    What its machine costs per hour, net
  • previews[].​costSoFarAlways

    number, may be null

    Started hours since it was created × the hourly price
  • previews[].​createdAtAlways

    string

    When it was created
  • previews[].​lastPushAtAlways

    string, may be null

    The last push to its branch
  • previews[].​keepAlways

    boolean

    Kept: never deleted for being idle
  • previews[].​idleDeleteAtAlways

    string, may be null

    When it is deleted if nobody pushes before; null when kept or previews are off
  • previews[].​lastDeploymentAlways

    object, may be null

    Its newest deployment
  • previews[].​lastDeployment.​idAlways

    string

    The deployment
  • previews[].​lastDeployment.​statusAlways

    string

    Its status
  • previews[].​lastDeployment.​commitAlways

    string, may be null

    The commit it deploys
  • previews[].​databaseAlways

    string, may be null

    The database branch it is bound to, in words; null: none
  • totalsAlways

    object

    What the open previews cost
  • totals.​eurPerHourAlways

    number

    All open previews, per hour
  • totals.​costSoFarAlways

    number

    All open previews, since each was created

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:UpdatePreviewSettings 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 previews configure id --enabled

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_deploy_previews_configure.