1. Docs
  2. API Reference
  3. Change an Environment's sign-in settings

Change an Environment's sign-in settings

PATCH/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/{envSlug}/auth-settings

Updates the sign-in settings of the Environment named by :envSlug, applying any supplied fields (mfa, allow_self_signup, self_signup_require_captcha, login_require_captcha, password_login_enabled, email_otp_login_enabled, self_signup_daily_cap, access_token_ttl_seconds, refresh_token_ttl_days, allowed_web_origins, sso_return_urls); omitted fields are left unchanged and allowed_web_origins are normalized and de-duplicated on save. Returns 404 when the slug does not exist. Emits an environment.auth_settings_updated audit event recording which keys changed.

Authentication

Bearer TokenAuthorization

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

Requires capability auth_settings.manageDeveloper Console

Change Environment sign-in settings. 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

mfaobject Optional

MFA enforcement keys persisted under `env.settings`. Send the subset of keys you want to change; omitted keys retain their prior value.

allow_self_signupboolean Optional

Per-environment opt-in for browser-direct, publishable-key self-signup (`POST /v1/identity/auth/register`). Off by default; persisted under `env.settings.allow_self_signup`.

self_signup_require_captchaboolean Optional

Require a Cloudflare Turnstile CAPTCHA on self-signup for this Environment. Off by default; persisted under `env.settings.self_signup_require_captcha`. Enable only once the signup page renders the Turnstile widget, or registrations will be rejected.

login_require_captchaboolean Optional

Require a Cloudflare Turnstile CAPTCHA on login for this Environment. Off by default; persisted under `env.settings.login_require_captcha`. Enable only once the login page renders the Turnstile widget, or logins will be rejected.

password_login_enabledboolean Optional

Enable password (email + password) login for this Environment. On by default; persisted under `env.settings.password_login_enabled`. Set false for a passwordless-only Environment.

email_otp_login_enabledboolean Optional

Enable passwordless email-OTP login for this Environment. Off by default (opt-in); persisted under `env.settings.email_otp_login_enabled`. When on, identities can sign in with an emailed 6-digit code via /login/email-otp/*.

self_signup_daily_capnumber Optional

Maximum self-signup registrations allowed per UTC day for this Environment. 0 (the default) means no cap. When exceeded, registration returns 429. Persisted under `env.settings.self_signup_daily_cap`.

range 0–100000

access_token_ttl_secondsnumber Optional

Lifetime in seconds of the access tokens (JWTs) this Environment issues to identities. Defaults to 900 (15 minutes). Persisted under `env.settings.access_token_ttl_seconds`; applies to tokens minted after the change.

range 60–3600

refresh_token_ttl_daysnumber Optional

Lifetime in days of the refresh tokens this Environment issues to identities — effectively how long a session survives without re-authentication. Defaults to 180. Persisted under `env.settings.refresh_token_ttl_days`; applies to tokens minted after the change.

range 1–365

allowed_web_originsstring[] Optional

Browser Origins allowed to call this Environment's public identity-auth API cross-origin (CORS), e.g. `https://app.example.com`. Required to use the Direct-API flow from a browser SPA; empty means no browser client is permitted (server-to-server with an API key is unaffected). Persisted under `env.settings.allowed_web_origins`.

sso_return_urlsstring[] Optional

Allowlist of return URLs for publishable-key (Direct-API) SSO. After the IdP round-trip, `/v1/identity/auth/sso/*` redirects back to one of these with a single-use `sso_token`; an unregistered return URL is rejected (exact match — no open redirect). Persisted under `env.settings.sso_return_urls`.

Responses

application/json

  • dataEnvironmentAuthSettingsResponseDto*

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 PATCH "https://auth.canopy-io.com/portal/v1/accounts/{accountSlug}/applications/{appSlug}/environments/value/auth-settings" \
  -H "Authorization: Bearer $CANOPY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mfa": {
      "mfa_required": false,
      "mfa_grace_period_days": 0,
      "mfa_trusted_device_days": 0,
      "mfa_factor_allowlist": [
        "totp"
      ],
      "mfa_after_sso": "exempt",
      "webauthn_rp_id": "acme.com",
      "webauthn_origins": [
        "https://portal.acme.com"
      ]
    },
    "allow_self_signup": false,
    "self_signup_require_captcha": false,
    "login_require_captcha": false,
    "password_login_enabled": false,
    "email_otp_login_enabled": false,
    "self_signup_daily_cap": 0,
    "access_token_ttl_seconds": 0,
    "refresh_token_ttl_days": 0,
    "allowed_web_origins": [
      "string"
    ],
    "sso_return_urls": [
      "string"
    ]
  }'
Response
{
  "data": {
    "environment_slug": "string",
    "mfa_required": false,
    "mfa_grace_period_days": 0,
    "mfa_trusted_device_days": 0,
    "mfa_factor_allowlist": [
      "string"
    ],
    "mfa_after_sso": "exempt",
    "webauthn_rp_id": "string",
    "webauthn_origins": [
      "string"
    ],
    "allow_self_signup": false,
    "self_signup_require_captcha": false,
    "login_require_captcha": false,
    "password_login_enabled": false,
    "email_otp_login_enabled": false,
    "self_signup_daily_cap": 0,
    "access_token_ttl_seconds": 0,
    "refresh_token_ttl_days": 0,
    "allowed_web_origins": [
      "string"
    ],
    "sso_return_urls": [
      "string"
    ]
  }
}
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
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
POSTRevert this Environment from hierarchy to flat
Was this page helpful?

Tell us how we can improve this guide.