Skip to main content

Set default actions for new resources

Set the actions that Permit adds to each new resource in an environment, such as read, write, or allow-review, instead of the default create, read, update, and delete. This page is for developers who automate environment setup with the Permit API.

Prerequisites

Default actions setting

The settings.default_resource_actions field of an environment lists the actions of each new resource in that environment. Set the field with the Update Environment API:

PATCH https://api.permit.io/v2/projects/{proj_id}/envs/{env_id}

The request body is an environment update object. The following body sets three default actions:

{
"settings": {
"default_resource_actions": ["read", "write", "allow-review"]
}
}

The setting applies to one environment. Other environments in the same project and workspace keep their own default actions. For the full shape of environment settings, see Default settings of a new environment.

Update the default actions with curl

The following request sets the default actions to read and write. Before you run the request:

  • Replace {project_id} and {env_id} with your project and environment IDs or keys.
  • Replace permit_env_api_key with your environment API key.
  • Edit the default_resource_actions list to the actions you want.
curl --location --request PATCH 'https://api.permit.io/v2/projects/{project_id}/envs/{env_id}' \
--header 'authorization: Bearer permit_env_api_key' \
--header 'Content-Type: application/json' \
--data-raw '{"settings":{"default_resource_actions":["read","write"]}}'

The API responds with the updated environment object.

Verify the default actions

Get the environment with the Get Environment API (GET https://api.permit.io/v2/projects/{proj_id}/envs/{env_id}). The settings.default_resource_actions field of the response lists the actions you set.