Bradley Herrup
09/04/2025, 9:15 PMAsk Inkeep
09/04/2025, 9:15 PMAsk Inkeep
09/04/2025, 9:15 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"
}
}
}'
For large environments, use the Background API for asynchronous copying:
curl --location '<https://api.permit.io/v2/projects/default/envs/staging/copy/async>' \
-H 'authorization: Bearer API_SECRET_KEY' \
--data '{
"target_env": {
"new": {
"key": "prod",
"name": "production"
}
}
}'
What Gets Copied
Only Policy objects are copied/merged, including:
• Resources (with actions, attributes, roles, relations)
• Roles (with permissions, derivations, hierarchy)
• Condition Sets (with user sets, resource sets, rules, inheritance)
• Custom Policies
Directory objects like Users, Tenants, and Resource Instances are not copied.
CI/CD Integration
The copy-env API can be used to merge/promote changes between environments as part of your CI/CD pipeline, maintaining consistency and efficiency. (2)
GitOps Alternative
With GitOps enabled, environments are branches in your policy repository. (3) This allows you to manage policy changes through standard Git workflows - merging branches effectively promotes policies between environments.Ask Inkeep
09/04/2025, 9:16 PMOr Weis
09/04/2025, 9:17 PMAsk Inkeep
09/04/2025, 9:17 PMAsk Inkeep
09/04/2025, 9:18 PMterraform apply to deploy your policies.
Here's the documentation link for the Terraform Provider:
Permit.io Terraform Provider (1)
You can also use the Permit CLI to export your existing environment configuration as Terraform HCL files: (3)
permit env export terraform --file <http://permit-config.tf|permit-config.tf>
This makes it easy to start with Terraform even if you've already configured policies through the UI - you can export your current setup and then manage it as code going forward. (7) Ask Inkeep
09/04/2025, 9:18 PM