Revert this Environment from hierarchy to flat
/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/revert-to-flatAuthentication
- Bearer Token
AuthorizationJWT access token
Path Parameters
| Name | Required | Type | Description |
|---|---|---|---|
envSlug | string |
Code samples
curl -X POST "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat" \
-H "Authorization: Bearer $CANOPY_TOKEN"const response = await fetch("https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat", {
method: "POST",
headers: {
"Authorization": "Bearer $CANOPY_TOKEN"
},
});
const data = await response.json();import requests
response = requests.post(
"https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat",
headers={
"Authorization": "Bearer $CANOPY_TOKEN"
},
)
data = response.json()package main
import (
"net/http"
)
func main() {
req, _ := http.NewRequest("POST", "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat", nil)
req.Header.Set("Authorization", "Bearer $CANOPY_TOKEN")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
}Responses
200 Assignments consolidated to root, nodes deleted, schema cleared. Sibling envs in the same Application are unaffected.
{
"assignments_moved": 0,
"assignments_deduplicated": 0,
"assignments_expired_dropped": 0,
"nodes_deleted": 0,
"schema_cleared": false
}application/json
assignments_moved *numberNumber of unique (identity, role) pairs reseated at the root node.
assignments_deduplicated *numberNumber of duplicate assignments collapsed during the dedupe pass.
assignments_expired_dropped *numberNumber of expired assignments (those whose `effective_to` was already in the past) that were discarded during the flatten. Expired rows grant no access; preserving them as unbounded root rows would silently reinstate dead access, so they're dropped. Surfaced explicitly so the admin sees the cleanup actually happened.
nodes_deleted *numberNumber of non-root hierarchy nodes deleted as part of the flatten.
schema_cleared *booleanAlways `true` on success — the schema is wiped from `Application.settings`.
400 This Environment is already using flat access model
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)
404 Environment not found in this Application