def duplicate(
slug: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> ProjectResourceasync def duplicate(
slug: str,
*,
product: str | None = None,
timeout: float | None = None,
) -> ProjectResourceCopies a project, every environment under it and every variable including the stored ciphertext, in one transaction. There is no request body and no target product: the copy always lands beside the source. Verbatim ciphertext means the copy decrypts with the same passphrase as the original.
The copy is named <name> (Copy) truncated to 50 characters, with a slug derived from that name and suffixed -2, -3 and so on until it is free inside the product, falling back to a random six character suffix after enough collisions. Read the returned slug rather than guessing it. The workspace project allowance is checked before any copying starts, so a 402 or 409 leaves nothing behind.
Example
from envless import envless
clone = envless.projects.duplicate('api', product='billing')
print(clone['slug'])import asyncio
from envless import AsyncEnvless
async def main() -> None:
async with AsyncEnvless() as envless:
clone = await envless.projects.duplicate('api', product='billing')
print(clone['slug'])
asyncio.run(main())Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | str | Yes | Slug or uniqueId of the project to copy. |
product | str | No | Product slug used to disambiguate an ambiguous source 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
ProjectResource for the new copy, carrying its generated name and slug.
Worth knowing
- Needs both projects:write and variables:write. A key holding only one of them fails with 403
auth.scope_missing. - Project restricted keys are refused outright with 403
auth.key_project_restricted, because the new project could not be covered by the allowlist. - Version history is not copied, only the current state of each environment.
Required scopes
projects:write and variables:write
Underlying endpoint
POST /projects/{slug}/duplicate
Request and response schema, every error code, and a live playground.
In TypeScript
envless.projects.duplicate()
The same method in @goenvless/sdk, with the same request, retries and errors.