Replace an Environment's configuration from a JSON payload (destructive)
/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/importReplaces the target Environment's configuration (resolved by :envSlug) with the supplied export document. This is destructive: existing roles, permissions, nodes, OAuth clients, webhook subscriptions, and pending invites in the target are wiped before the payload is applied within a single transaction; identities, memberships, and assignments survive except where cascading role/node deletes remove dangling rows. The payload must declare a supported format_version (400 otherwise) and contain exactly one root node, with duplicate keys, cyclic parents, orphaned nodes, and unknown permission references each rejected as 400. Returns 200 with one-time OAuth client and webhook signing-secret rotation receipts and emits an environment.imported audit event; 404 when the slug does not exist.
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 Request body
application/json
format_versionnumber Required source_envobject Required access_modelenum Required organizations_enabledboolean Required hierarchy_schemaobject Required permissionsany[] Required rolesany[] Required nodesany[] Required oauth_clientsany[] Required webhooksany[] Required metadataobject Optional Responses
application/json
data *EnvironmentCloneResponseDto
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/import" \ -H "Authorization: Bearer $CANOPY_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "format_version": 1, "source_env": {}, "access_model": "flat", "organizations_enabled": false, "hierarchy_schema": {}, "permissions": [ null ], "roles": [ null ], "nodes": [ null ], "oauth_clients": [ null ], "webhooks": [ null ], "metadata": {} }'
{ "data": { "environment": { "id": "string", "application_id": "string", "name": "string", "slug": "string", "is_production": false, "settings": {}, "version": 0, "created_at": "2026-04-20T12:00:00.000Z", "updated_at": "2026-04-20T12:00:00.000Z" }, "oauth_client_rotations": [ { "source_client_id": "string", "client_id": "string", "client_secret": "string" } ], "webhook_subscription_rotations": [ { "id": "string", "url": "string", "secret": "string" } ] } }
Tell us how we can improve this guide.