Revert this Environment from hierarchy to flat
/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/revert-to-flatCollapses 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
AuthorizationJWT access token. Never send alongside X-API-Key: a request carrying both is refused.
applications.manageDeveloper ConsoleCreate, 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
data *RevertToFlatResponseDto
application/json
error *ApiErrorBodyDto
application/json
error *ApiErrorBodyDto
application/json
error *ApiErrorBodyDto
application/json
error *ApiErrorBodyDto
Errors
When the request can't be completed, the response body includes a stable error code you can branch on.
account.capability_requiredForbiddenThe signed-in user's administrator roles do not grant the capability this endpoint requires.
Ask an account administrator to grant a role carrying the capability named in the Authentication section, then retry.
Returned object
curl -X POST "https://auth.canopy-io.com/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/revert-to-flat" \ -H "Authorization: Bearer $CANOPY_TOKEN"
{ "data": { "assignments_moved": 0, "assignments_deduplicated": 0, "assignments_expired_dropped": 0, "assignments_dropped_scoped": 0, "nodes_deleted": 0, "organizations_preserved": 0, "schema_cleared": false } }
Tell us how we can improve this guide.