Create an Environment
/api/v1/applications/{id}/environmentsCreates an Environment in the Application from a name and optional slug. With copy_from naming another of its Environments by slug, that Environment's configuration (permissions, roles, the hierarchy, the sign-in policy, custom claims, OAuth client and webhook configurations) is copied; people, role assignments and API keys never are. Returns 201 with the Environment and one-time oauth_client_rotations and webhook_subscription_rotations receipts for copied secrets. A slug already used in the Application returns 409, and so does a create in an Application that already holds 10 Environments, the most it may (environment.limit). Requires application.manage.
Authentication
Authorization Option A JWT access token. Never send alongside X-API-Key: a request carrying both is refused.
X-API-Key Option B API key for management-tier access. Never send alongside an Authorization header: a request carrying both is refused.
application.manageAccountCreate, update, and delete Applications and Environments, and change Environment settings. A scoped API key must hold it as a scope; a full-access key holds every scope within its Environment except the named-only and account scopes; a developer's token needs the Console capability that covers it. A credential without it is refused with 403.
Path Parameters
idstring Required Request body
application/json
namestring Required Display name for the new Environment
slugstring Optional URL-safe slug. Lowercase alphanumeric with optional dashes (no leading/trailing dash). Auto-derived from `name` when omitted. Unique within the Application.
copy_fromstring Optional Source env slug to clone configuration from. Copies permissions, roles, role-permission joins, hierarchy nodes, OAuth client configs (without secrets), and webhook configs (without secrets). Identities and role assignments are NOT copied.
Responses
application/json
data *EnvironmentCloneResponseDto
application/json
error *ApiErrorBodyDto
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, and a correlation_id (also sent as the X-Correlation-Id header). Quote the correlation id when you contact support: it identifies the exact request in Canopy's logs. A request refused by an authorization check answers 403 with the code authorization.denied, and its data names the denial_reason and the permission checked.
authorization.deniedForbiddenThe credential does not hold the permission this operation checks: a scoped API key without the scope, a developer without the Console capability that covers it, or a permission granted somewhere other than the node the request targets. The error's data names the permission.
Add the permission named in the Authentication section to the key's scopes, or ask an account administrator to grant the covering capability, then retry. For a node-scoped operation, make sure the grant reaches the node you are acting on.
Returned object
curl -X POST "https://auth.canopy-io.com/api/v1/applications/value/environments" \ -H "X-API-Key: $CANOPY_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "string", "slug": "string", "copy_from": "string" }'
{ "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.