Auth API reference

Auth API · Apps

patch/v1/apps/{app_id}/auth-configAuth

Update the per-app auth config. Only fields you pass are changed.

Path parameters

app_id*string

Id of the app.

Request body

signup_enabledboolean

Whether new EndUsers can sign up.

signup_requires_pakboolean

When true, sign-up only works from your backend: every `POST /{app_slug}/v1/auth/signup` must carry a Platform API Key (`Authorization: Bearer pcft_live_…`) from this app's workspace whose policy allows `auth.signup.create` on this app. Anonymous sign-ups get 401. Use it when your own backend gates sign-ups (CAPTCHA, invite or payment checks). Independent of `bot_protection`; an app can use both. Turning it on for an app that has no workspace is refused with 409.

signin_enabledboolean

Whether existing EndUsers can sign in.

signup_allowed_email_domainsarray

Optional allowlist of email domains for signup. Empty array = any domain.

Example: ["acme.com","acme.io"]

signup_default_rolestring

Role slug newly-signed-up EndUsers receive (e.g. `member`).

Example: "member"

session_duration_minutesnumber

Session lifetime in minutes (1 minute to 30 days).

Example: 10080

access_token_minutesnumber

EndUser access-token lifetime in minutes (5-60, default 60). Independent of `session_duration_minutes`: the session and its refresh token can live for days while the access token expires in minutes. An access token is never issued for longer than the session it belongs to has left. M2M (client-credentials) tokens are unaffected and keep their fixed one-hour lifetime.

Example: 60

max_failed_login_attemptsnumber

Consecutive failed signin attempts before an EndUser is locked out for 15 minutes. Applies to the signin lockout counters only; the separate short-burst limiter (5 attempts per identifier per minute) is fixed and not configurable.

Example: 5

password_min_lengthnumber

Minimum password length (NIST minimum is 8).

Example: 12

password_require_uppercaseboolean

Require an uppercase letter in passwords.

password_require_numberboolean

Require a digit in passwords.

password_require_symbolboolean

Require a symbol in passwords.

max_sessionsnumber

Maximum concurrent sessions per EndUser. When a signin would take the account past this number, the OLDEST session — the one created longest ago, not the one used longest ago — is revoked (audited as `auth.session.evicted`). Omit or send null for unlimited.

Example: 5

enforce_app_permissionsboolean

When true, Consumer-API routes annotated with `@RequireAppPermission(perm)` enforce the requested perm against the EndUser's role-resolved permission set. When false (default), permission checks are bypassed — any valid token can call any annotated route. Flip on once you've authored roles + permissions for this app and want them to actually mean something.

oauth_link_policyenum (3)

How to handle a federated sign-in (Apple, Google, …) that lands on a verified email already belonging to an account in this app. `confirm` (default) refuses to auto-link and surfaces `link_required` so the user signs in with their original method. `auto` silently links when the provider claims the email is verified AND the email is not a private relay. `reject` refuses outright. Private-relay emails never auto-link regardless.

allowed_redirect_originsarray

Allowed origins for the `return_to` parameter on the OAuth web redirect callback. Exact origin match (scheme + host + port); no paths, no wildcards. Empty array disables the web redirect flow for this app. Prevents the callback from acting as an open-redirect.

Example: ["https://app.example.com"]

password_breach_checkenum (3)

Whether passwords are checked against a public breach corpus (HIBP Pwned Passwords, k-anonymity range API) before being accepted. `block` (default) rejects a breached password with 400 `PASSWORD_BREACHED`. `warn` accepts it and returns `password_warnings: ["breached"]` alongside the tokens. `off` disables the lookup entirely, so no outbound call is made. The lookup always fails open — a timeout or an unreachable corpus never blocks a signup. Only the first five characters of the password's SHA-1 ever leave the service.

mfaenum (2)

Whether every EndUser must hold an MFA factor. `optional` (default) leaves MFA per-user opt-in. `required` refuses to mint a session for a user with no enabled factor: sign-in answers `{ mfa_enrollment_required: true, mfa_token, expires_at }` and the user enrols via POST /{app_slug}/v1/auth/mfa/enroll. IMPORTANT: turning this on does NOT terminate sessions that are already live — existing users keep their session until it expires or is revoked and only meet the requirement on their next sign-in. Revoke sessions explicitly if the policy has to bite immediately.

mfa_grace_daysnumber

Grace window in days, measured from ACCOUNT CREATION, during which `mfa: required` still mints ordinary tokens. The sign-in response then also carries `mfa_enrollment_due_at` so a client can prompt rather than block. 0 (default) means no grace. Note the anchor: an app that turns the policy on with existing users will find every account older than the window is already past it.

Example: 0

unverified_account_ttl_daysnumber

Delete accounts whose primary email is still unverified this many days after sign-up. Only self-sign-ups that never signed in after sign-up, hold no two-step factor, no verified contact and no social login qualify. Deletion is permanent, frees the email address and username, is audited as `auth.account.expired_unverified` and fires `user.deleted` with `reason: "unverified_expired"`. Send null to never delete. New apps start at 7; apps created before this setting existed start at null.

Example: 7

bot_protectionobject

Sign-up bot protection (Cloudflare Turnstile or hCaptcha). Fields you send are merged onto the stored block; send null to remove the block and its secret. While `enabled`, sign-up requires a `bot_protection_token` the provider accepts, checked before anything else, and fails closed (503) when the provider cannot be reached.

passwordless_emailobject

Email sign-in by magic link and/or 6-digit code, as a primary method (sign-in and sign-up in one flow). Fields you send are merged onto the stored block; send null to remove it. Needs Auth emails on with a sign-in template (`sign_in_template_name`).

test_modeobject

Test mode for CI and agents: `+pc_test` addresses sign in with a fixed code and never get email. Fields you send are merged; null removes it. Every switch is audited (`app.auth_config.test_mode_changed`) and every use too (`auth.test_identity.used`).

Response · 200

signup_enabled*boolean

Whether new users can sign up.

signup_requires_pak*boolean

When true, sign-up requires a Platform API Key from this app's workspace (anonymous sign-ups get 401).

signin_enabled*boolean

Whether existing users can sign in.

signup_allowed_email_domains*array

Email domains allowed to sign up; empty means any domain.

signup_default_role*string

Role newly signed-up users receive.

Example: "member"

session_duration_minutes*number

Session lifetime in minutes.

Example: 10080

access_token_minutes*number

Access-token lifetime in minutes (5-60).

Example: 60

max_failed_login_attempts*number

Consecutive failed sign-ins before an account is locked for 15 minutes.

Example: 5

password_min_length*number

Minimum password length.

Example: 12

password_require_uppercase*boolean

Whether passwords need an uppercase letter.

password_require_number*boolean

Whether passwords need a digit.

password_require_symbol*boolean

Whether passwords need a symbol.

max_sessions*number

Maximum concurrent sessions per user; a sign-in past it ends the oldest session.

Example: null

enforce_app_permissions*boolean

Whether routes that declare an app permission enforce it against the user's role.

oauth_link_policy*object

What a federated sign-in does when its verified email already belongs to an account in the app: `auto` links it, `confirm` asks the user to prove the existing account first, `reject` refuses the sign-in.

allowed_redirect_origins*array

Origins the OAuth web flow may redirect back to (`return_to`), exact match.

password_breach_check*object

Breached-password check on sign-up and password changes: `block`, `warn` or `off`.

Example: "block"

mfa*object

Whether every user must hold an MFA factor: `optional` or `required`.

Example: "optional"

mfa_grace_days*number

Days after account creation during which `mfa: required` still mints ordinary tokens.

Example: 0

unverified_account_ttl_days*number

Days an account may keep an unverified primary email before it is deleted. null = never.

Example: 7

bot_protection*object

Sign-up bot protection; null when not configured.

passwordless_email*object

Email sign-in (magic link / code); null when never configured.

test_mode*object

Test mode; null when never configured.

Example

Request

PATCH https://api.auth.productcraft.co/v1/apps/{app_id}/auth-config
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "signup_enabled": false,
  "signup_requires_pak": false,
  "signin_enabled": false,
  "signup_allowed_email_domains": [
    "acme.com",
    "acme.io"
  ],
  "signup_default_role": "member",
  "session_duration_minutes": 10080,
  "access_token_minutes": 60,
  "max_failed_login_attempts": 5,
  "password_min_length": 12,
  "password_require_uppercase": false,
  "password_require_number": false,
  "password_require_symbol": false,
  "max_sessions": 5,
  "enforce_app_permissions": false,
  "oauth_link_policy": "auto",
  "allowed_redirect_origins": [
    "https://app.example.com"
  ],
  "password_breach_check": "off",
  "mfa": "optional",
  "mfa_grace_days": 0,
  "unverified_account_ttl_days": 7,
  "bot_protection": {},
  "passwordless_email": {},
  "test_mode": {}
}

Response

{
  "signup_enabled": false,
  "signup_requires_pak": false,
  "signin_enabled": false,
  "signup_allowed_email_domains": [
    "string"
  ],
  "signup_default_role": "member",
  "session_duration_minutes": 10080,
  "access_token_minutes": 60,
  "max_failed_login_attempts": 5,
  "password_min_length": 12,
  "password_require_uppercase": false,
  "password_require_number": false,
  "password_require_symbol": false,
  "max_sessions": null,
  "enforce_app_permissions": false,
  "oauth_link_policy": {},
  "allowed_redirect_origins": [
    "string"
  ],
  "password_breach_check": "block",
  "mfa": "optional",
  "mfa_grace_days": 0,
  "unverified_account_ttl_days": 7,
  "bot_protection": {},
  "passwordless_email": {},
  "test_mode": {}
}