duplicate(project: string, environment: string, options?: ProductScope): Promise<EnvironmentResource>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 resolved resource. The per-project allowance is checked before any copying starts, so a 402 or a 409 leaves nothing half-created.
Example
const copy = await envless.environments.duplicate('api', 'production')
console.log(copy.slug)Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | string | Yes | Project slug or uniqueId that owns the source environment. |
environment | string | Yes | Slug of the environment to copy; ids are not accepted. |
options.product | string | No | Product slug that disambiguates an ambiguous project slug. |
options.signal | AbortSignal | No | Cancels the request. |
Returns
EnvironmentResource 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.
exposedis 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 Python
envless.environments.duplicate()
The same method in envless-sdk, the Python SDK, with the same request, retries and errors.
In Ruby
Envless.environments.duplicate
The same method in envless-sdk, the Ruby gem, with the same request, retries and errors.
In PHP
$envless->environments->duplicate()
The same method in envless/sdk, the PHP SDK, with the same request, retries and errors.