Hi. is there a way to easily copy and port over a ...
# permit-saas
e
Hi. is there a way to easily copy and port over a 'staging' env policies, resources, roles, etc... into production environment to seed it?
a
Hi @Engineering Swantide, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Yes, you can copy environments in Permit.io to port policies, resources, roles, and other schema objects from staging to production. (1) ​*Using the API*​ You can copy an environment using the API:
Copy code
curl --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 asynchronous endpoint:
Copy code
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*​ Environment copying applies only to Policy objects, not Directory objects. The copied objects include: • Resource • Resource Actions • Resource Action Groups • Resource Attributes • Resource Roles • Resource Relations • Roles • Role Permissions • Role Derivations • Role Hierarchy • Condition Sets • User Sets • Resource Sets • Condition Sets Rules • Condition Sets Inheritance • Custom Policies Directory objects like Users, Tenants, and Resource Instances are not copied. ​*Using the CLI*​ You can also use the Permit CLI: (2)
Copy code
permit env copy --api-key permit_key --from staging --to production
To learn more, see the sources I considered: [[1] Create a new Environment](https://docs.permit.io/manage-your-account/creating-environments) [[2] Introducing the New Permit.io CLI: A New Era of Access Control Developer Experience](https://www.permit.io/blog/introducing-the-new-permit-cli)
e
when you say 'user sets' does that mean all of our users and their established roles in one env to another?
o
@Ask Inkeep
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
No, "User Sets" does ​*not*​ mean your users and their role assignments. (1) User Sets are ​*Policy objects*​ that define groups or collections of users based on certain criteria - they're part of your authorization schema. When you copy environments, ​*Directory objects*​ like Users, Tenants, and Resource Instances are ​*not copied*​. This means: • Your actual user records are not copied • User role assignments are not copied • Tenant data is not copied • Resource instances are not copied Only the ​*Policy schema*​ gets copied - the structure and rules of your authorization model (resources, roles, permissions, condition sets, user sets definitions, etc.) . If you need to migrate user data and role assignments from staging to production, you'll need to handle that se
To learn more, see the sources I considered: [[1] Create a new Environment](https://docs.permit.io/manage-your-account/creating-environments)
o
UsersSets are also referred to in the UI as Dynamic roles, and are part of the ABAC subsystem