Yorrick Elzinga
12/02/2025, 2:22 PMAsk Inkeep
12/02/2025, 2:22 PMAsk Inkeep
12/02/2025, 2:22 PMcurl --location '<https://api.permit.io/v2/projects/{project_id}/envs/{env_id}/copy>' \
-H 'authorization: Bearer API_SECRET_KEY' \
--data '{
"target_env": {
"new": {
"key": "prod",
"name": "production"
}
}'
Using the CLI
The Permit CLI provides a simpler way to copy environments (2) :
$ permit env copy --api-key permit_key --from staging --to production --conflict-strategy overwrite
What Gets Copied
When copying environments, the following policy objects are copied (1) :
• Resources (including actions, attributes, roles, and relations)
• Roles (including permissions, derivations, and hierarchy)
• Condition Sets (including user sets, resource sets, rules, and inheritance)
• Custom Policies (if using GitOps)
Note: Directory objects like Users, Tenants, and Resource Instances are NOT copied .
Handling Conflicts
When merging into an existing environment, you can choose conflict resolution strategies :
• *Fail* (default) : Rollback the entire merge if conflicts arise
• *Overwrite*: Replace existing objects with those from the source environment
This feature is particularly useful for managing changes to your policy in a controlled manner, allowing you to test changes in development before merging them to production .Ask Inkeep
12/02/2025, 2:22 PMYorrick Elzinga
12/02/2025, 2:24 PMAlon Boshi
12/02/2025, 2:30 PMNote that Directory objects like Users, Tenants, and Resource Instances are NOT copied .Just making sure you saw it. In case you want to transfer the directory - first, retrieve your data through the API or the PDP cache; then, create a script to move it to the target environment.
how to use permit cli?Have a look at our docs - here
Yorrick Elzinga
12/02/2025, 2:49 PMYorrick Elzinga
12/02/2025, 2:49 PMAlon Boshi
12/02/2025, 3:03 PMAsk Inkeep
12/02/2025, 3:03 PMAsk Inkeep
12/02/2025, 3:03 PMsetup.js file .Ask Inkeep
12/02/2025, 3:03 PMAsk Inkeep
12/02/2025, 3:03 PMYorrick Elzinga
12/02/2025, 3:03 PM