Environments

Envless.environments.duplicate

Copy an environment and its variables

def duplicate(project, environment, product: nil, timeout: nil)

Copies an environment and all of its variables, ciphertext included, into the same project in one transaction. There is no request body. Version history is not copied, so the clone starts with nothing published.

The copy is named <name> (Copy), truncated to 50 characters, and its slug comes from that name with a -2, -3 suffix until one is free, falling back to a random six-character suffix after enough collisions. Never guess the resulting slug, read it off the returned resource. The per-project allowance is checked before any copying starts, so a 402 or a 409 leaves nothing half-created.

Example

ruby
require "envless/sdk"

copy = Envless.environments.duplicate("api", "production")

puts copy[:slug]

Parameters

ParameterTypeRequiredDescription
projectStringYesProject slug or uniqueId that owns the source environment.
environmentStringYesSlug of the environment to copy; ids are not accepted.
product:String | SymbolNoProduct slug that disambiguates an ambiguous project slug.
timeout:Integer | Float | RationalNoSeconds each attempt of this call may take, redirects and the response body included, before it raises Envless::NetworkError with timeout? set. Overrides the client's timeout for this call, and 0 turns the limit off.

Returns

environment_resource for the new copy, including its generated slug.

Worth knowing

  • The key needs both environments:write and variables:write, since variables move with the environment.
  • Values are copied as stored ciphertext, so the copy decrypts with the same passphrase as the source.
  • exposed is false on the copy whatever the source was set to.

Required scopes

environments:write and variables:write

Underlying endpoint

POST /projects/{slug}/environments/{environmentSlug}/duplicate

Request and response schema, every error code, and a live playground.

In TypeScript

envless.environments.duplicate()

The same method in @goenvless/sdk, with the same request, retries and errors.