1. Docs
  2. API Reference
  3. Revert this Environment from hierarchy to flat

Revert this Environment from hierarchy to flat

POST/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/revert-to-flat

Authentication

  • Bearer Token Authorization

    JWT access token

Path Parameters

Name Required Type Description
envSlugRequiredstring

Code samples

cURLJavaScriptPythonGo
curl -X POST "https://api.canopy.dev/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat" \
  -H "Authorization: Bearer $CANOPY_TOKEN"

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_movednumber*

    Number of unique (identity, role) pairs reseated at the root node.

  • assignments_deduplicatednumber*

    Number of duplicate assignments collapsed during the dedupe pass.

  • assignments_expired_droppednumber*

    Number 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_deletednumber*

    Number of non-root hierarchy nodes deleted as part of the flatten.

  • schema_clearedboolean*

    Always `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

Returned object

On this page

Related endpoints

GETList Environments in an Application
POSTCreate a new Environment in an Application
GETGet a single Environment by slug
PATCHRename or re-slug an Environment
DELETEDelete an Environment
GETExport an Environment's configuration as JSON
POSTReplace an Environment's configuration from a JSON payload (destructive)
GETGet the Environment's access model
PUTSwitch the Environment's access model
GETGet hierarchy schema for the active Environment
PATCHUpdate hierarchy schema for the active Environment