def duplicate(slug, timeout: nil)def duplicate: (String slug, ?timeout: seconds?) -> product_resourceClones a product together with every project, environment and variable underneath it. Ciphertext is copied verbatim, so the clone decrypts with the same workspace passphrase and needs no re-encryption pass.
The name and slug of the clone are derived from the source and are not predictable, so read them off the response rather than guessing at a suffix. Version history is not carried over, so the cloned environments start with no versions.
A key restricted to specific projects is refused outright, because the clone creates project ids outside that allowlist. Both the product cap and the project cap of the plan are enforced, and either one being full fails the call.
Example
require "envless/sdk"
clone = Envless.products.duplicate("billing")
projects = Envless.products.list_all_projects(clone[:slug])
puts "#{clone[:slug]} #{projects.size}"Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
slug | String | Yes | Slug or uniqueId of the product to copy. |
timeout: | Integer | Float | Rational | No | Seconds 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
product_resource for the clone, including the generated name and slug.
Worth knowing
- Duplicating a private product keeps the privacy flag and copies the grants recorded on the source.
- The whole copy runs in one transaction, so a failed call leaves no half-built product behind.
Required scopes
products:write and projects:write and variables:write
Underlying endpoint
POST /products/{slug}/duplicate
Request and response schema, every error code, and a live playground.
In TypeScript
envless.products.duplicate()
The same method in @goenvless/sdk, with the same request, retries and errors.