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

Collapses the hierarchy-mode Environment named by :envSlug back to flat. Without organizations: surviving assignments are rebased onto the single root node and de-duplicated by identity and role (with effective-date windows merged so no identity loses access), expired assignments are dropped, and all non-root nodes are deleted bottom-up. With organizations enabled: the organizations and their memberships stay untouched, the nodes beneath them are deleted bottom-up, and the assignments made at those nodes are dropped (assignments_dropped_scoped) rather than widened to the organization or the root. Either way the hierarchy_schema is cleared and the access model is set to flat. Returns 200 with the summary; 400 when the Environment is already flat, 404 when the slug does not exist. Emits an application.hierarchy_reverted audit event.

Authentication

Bearer TokenAuthorization

JWT access token. Never send alongside X-API-Key: a request carrying both is refused.

Requires capability applications.manageDeveloper Console

Create, edit, and delete Applications and Environments. Granted through an administrator role in the Admin Workspace; a valid token without it is refused with 403.

Path Parameters

envSlugstring Required

Responses

application/json

  • dataRevertToFlatResponseDto*

application/json

  • errorApiErrorBodyDto*

application/json

  • errorApiErrorBodyDto*

application/json

  • errorApiErrorBodyDto*

application/json

  • errorApiErrorBodyDto*

Errors

When the request can't be completed, the response body includes a stable error code you can branch on.

403account.capability_requiredForbidden
When it happens

The signed-in user's administrator roles do not grant the capability this endpoint requires.

Remediation

Ask an account administrator to grant a role carrying the capability named in the Authentication section, then retry.

Returned object

Request
curl -X POST "https://auth.canopy-io.com/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat" \
  -H "Authorization: Bearer $CANOPY_TOKEN"
Response
{
  "data": {
    "assignments_moved": 0,
    "assignments_deduplicated": 0,
    "assignments_expired_dropped": 0,
    "assignments_dropped_scoped": 0,
    "nodes_deleted": 0,
    "organizations_preserved": 0,
    "schema_cleared": false
  }
}
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
GETGet an Environment's sign-in settings
PATCHChange an Environment's sign-in settings
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
PUTSwitch the Environment's organizations container on or off
GETGet hierarchy schema for the active Environment
PATCHUpdate hierarchy schema for the active Environment
GETList hierarchy node types with existing nodes
Was this page helpful?

Tell us how we can improve this guide.