Add resource permissions to existing roles
/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/setup/resource-permissionsAuthentication
- Bearer Token
AuthorizationJWT access token
Request body
resources *BootstrapResourceDto[]Resources to generate permissions for
role_permissions *ResourcePermissionRoleDto[]Permission assignments for existing roles. Empty array creates the permissions without binding them to any role.
Code samples
curl -X POST "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/setup/resource-permissions" \
-H "Authorization: Bearer $CANOPY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"resources": [
{
"name": "notes",
"actions": [
"create",
"read",
"update",
"delete"
]
}
],
"role_permissions": [
{
"role_id": "string",
"permission_keys": [
"invoices.create",
"invoices.read"
]
}
]
}'const response = await fetch("https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/setup/resource-permissions", {
method: "POST",
headers: {
"Authorization": "Bearer $CANOPY_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"resources": [
{
"name": "notes",
"actions": [
"create",
"read",
"update",
"delete"
]
}
],
"role_permissions": [
{
"role_id": "string",
"permission_keys": [
"invoices.create",
"invoices.read"
]
}
]
}),
});
const data = await response.json();import requests
response = requests.post(
"https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/setup/resource-permissions",
headers={
"Authorization": "Bearer $CANOPY_TOKEN",
"Content-Type": "application/json"
},
json={
"resources": [
{
"name": "notes",
"actions": [
"create",
"read",
"update",
"delete",
],
},
],
"role_permissions": [
{
"role_id": "string",
"permission_keys": [
"invoices.create",
"invoices.read",
],
},
],
},
)
data = response.json()package main
import (
"bytes"
"encoding/json"
"net/http"
)
func main() {
payload := map[string]interface{}{
"resources": []interface{}{
map[string]interface{}{
"name": "notes",
"actions": []interface{}{
"create",
"read",
"update",
"delete",
},
},
},
"role_permissions": []interface{}{
map[string]interface{}{
"role_id": "string",
"permission_keys": []interface{}{
"invoices.create",
"invoices.read",
},
},
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/setup/resource-permissions", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer $CANOPY_TOKEN")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
}Responses
201 Permissions created and assigned to existing roles in a single transaction
{
"permissions_created": 0,
"skipped_permissions": 0,
"roles_updated": 0
}application/json
permissions_created *numberNumber of permissions created
skipped_permissions *numberNumber of permissions skipped (already exist)
roles_updated *numberNumber of roles that received new permissions
401 Invalid or expired token
403 This token is not authorized for this endpoint (wrong principal type — e.g., admin token on identity-only endpoint, or vice versa)