ci.environments.put

Create an environment or change its protection rules

PUT /ci/api/repositories/{repoId}/environments/{name}IAM ci:PutEnvironmentChanges state

Fields left out keep their value. `reviewers` are IAM user ids of this organization (up to six); one of them must approve each job. `deploymentBranchPolicy`: all, protected (branches with a protection rule) or custom (`deploymentPatterns`). Environment secrets are the org secrets environment with the same slug.

Request syntax

PUT /ci/api/repositories/{repoId}/environments/{name}
{
  "url": "string",
  "waitTimerMinutes": "number",
  "reviewers": "array of string",
  "preventSelfReview": "boolean",
  "deploymentBranchPolicy": "enum",
  "deploymentPatterns": "array of json"
}

Path parameters

  • repoIdRequired

    string

    Constraints: uuid

  • nameRequired

    string

    Constraints: 1-255 chars

Request body

  • urlOptional

    string

    Link shown for the environment (where it is deployed), up to 2000 characters; null clears it; omitted: unchanged (none on a new environment)

    Constraints: url, max 2000 chars

    May be null.

  • waitTimerMinutesOptional

    number

    Minutes a job waits at the environment before it continues, 0 to 43,200; omitted: unchanged (0 on a new environment). A job is held at most 5 h 30 min, so a longer timer never ends

    Constraints: integer, 0-43200

  • reviewersOptional

    array of string

    IAM user ids of this organization (400 otherwise), up to 6; one of them must approve each job; empty: no review; omitted: unchanged (none on a new environment)

    Constraints: uuid

  • preventSelfReviewOptional

    boolean

    The person who started the run may not approve it; omitted: unchanged (off on a new environment)

  • deploymentBranchPolicyOptional

    enum

    Which refs may deploy: all; protected (branches with a protection rule); custom (refs matching deploymentPatterns, which must then be in the same request, 400 otherwise); omitted: unchanged (all on a new environment)

    One of: all, protected, custom

  • deploymentPatternsOptional

    array of json

    Up to 50 { type: branch | tag, pattern } globs (pattern 1 to 255 characters), used by the custom policy; replaces the list; omitted: unchanged (none on a new environment)

Response

200, whether it created the environment or changed it, with the environment as the list shows it; createdByWorkflow turns false. 400 for an invalid name, a reviewer who is not an IAM user of this organization, or deploymentBranchPolicy custom without deploymentPatterns in the same body; 404 when the repository is not in this organization.

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

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 ci:PutEnvironment 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 ci environments put repoId name

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