def duplicate(
project: str,
environment: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> EnvironmentResourceasync def duplicate(
project: str,
environment: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> EnvironmentResourceCopies 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
from envless import envless
clone = envless.environments.duplicate('api', 'production')
print(clone['slug'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
clone = await envless.environments.duplicate('api', 'production')
print(clone['slug'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
project | str | Yes | Project slug or uniqueId that owns the source environment. |
environment | str | Yes | Slug of the environment to copy; ids are not accepted. |
product | str | No | Product slug that disambiguates an ambiguous project slug. |
timeout | float | No | Seconds each attempt of this call may take, the response body included, before it raises EnvlessNetworkError with is_timeout set. Overrides the client's timeout for this call, and 0 turns the limit off. |
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.
exposedisFalseon 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.