Skip to content

Auth & identity

End-user authentication as a service — users, sessions, JWT/JWKS verification, OAuth and GDPR/CCPA consent — on infrai's own self-built identity engine behind one key.

1. Overview

Base path: https://api.infrai.cc/v1/auth
Auth header: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/auth capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/auth/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

2. Methods (17)

2.1auth.user.create

POST /v1/auth/user/create

Create an end-user identity on infrai's self-built auth engine. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
emailstring
Required
User email address.
format: email
passwordstringOptionalOptional initial password (vendor-dependent).
metadataRecord<string, unknown>OptionalArbitrary key/value metadata stored on the user.
vendor"infrai_native" | nullOptionalOptional explicit vendor pin.
mode"default_vendor" | "verified_account"OptionalProvisioning mode — managed.
default: "default_vendor"
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

AuthUser { user_id, email, email_verified, created_at }
NameTypeDescription
user_idstringUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
emailstringEmail address
format: email
email_verifiedbooleanWhether the email address has been verified
default: false
phonestring | nullPhone number in E.164 format
mfa_enabledbooleanWhether multi-factor authentication is enabled for this user
default: false
created_atstringISO 8601 timestamp when this resource was created
format: date-time
last_login_atstring | nullISO 8601 timestamp of the last successful login
format: date-time
metadataobject | nullArbitrary key-value metadata attached to this resource
vendorstring | nullSticky: vendor of record for this user.

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/user/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email": "user@example.com"}'

2.2auth.user.get

GET /v1/auth/user/get/{user_id}

Fetch a single auth user by user_id.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.

Returns

AuthUser
NameTypeDescription
user_idstringUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
emailstringEmail address
format: email
email_verifiedbooleanWhether the email address has been verified
default: false
phonestring | nullPhone number in E.164 format
mfa_enabledbooleanWhether multi-factor authentication is enabled for this user
default: false
created_atstringISO 8601 timestamp when this resource was created
format: date-time
last_login_atstring | nullISO 8601 timestamp of the last successful login
format: date-time
metadataobject | nullArbitrary key-value metadata attached to this resource
vendorstring | nullSticky: vendor of record for this user.

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/user/get/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.3auth.user.get_by_email

GET /v1/auth/user/get_by_email

Look up an auth user by email address.

Parameters

NameTypeRequiredDescription
emailstring
Required
User email address.

Returns

AuthUser
NameTypeDescription
user_idstringUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
emailstringEmail address
format: email
email_verifiedbooleanWhether the email address has been verified
default: false
phonestring | nullPhone number in E.164 format
mfa_enabledbooleanWhether multi-factor authentication is enabled for this user
default: false
created_atstringISO 8601 timestamp when this resource was created
format: date-time
last_login_atstring | nullISO 8601 timestamp of the last successful login
format: date-time
metadataobject | nullArbitrary key-value metadata attached to this resource
vendorstring | nullSticky: vendor of record for this user.

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/user/get_by_email \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.4auth.user.list

GET /v1/auth/user/list

Cursor-paginated list of auth users for the account.

Parameters

NameTypeRequiredDescription
cursorstringOptionalOpaque pagination cursor.
limitnumberOptionalMaximum number of items to return.

Returns

{ items: AuthUser[], next_cursor?: string }
NameTypeDescription
itemsobject[]List of user records
next_cursorstring | nullCursor for next page; null if last page
totalintegerNumber of items in this page

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/user/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.5auth.user.update

PATCH /v1/auth/user/update/{user_id}

Update mutable fields (metadata, phone, MFA) of an existing auth user. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
metadataRecord<string, unknown>OptionalArbitrary key/value metadata stored on the user.
email_verifiedbooleanOptionalMark the user email as verified.
mfa_enabledbooleanOptionalEnable or disable MFA for the user.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

AuthUser
NameTypeDescription
user_idstringUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
emailstringEmail address
format: email
email_verifiedbooleanWhether the email address has been verified
default: false
phonestring | nullPhone number in E.164 format
mfa_enabledbooleanWhether multi-factor authentication is enabled for this user
default: false
created_atstringISO 8601 timestamp when this resource was created
format: date-time
last_login_atstring | nullISO 8601 timestamp of the last successful login
format: date-time
metadataobject | nullArbitrary key-value metadata attached to this resource
vendorstring | nullSticky: vendor of record for this user.

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X PATCH https://api.infrai.cc/v1/auth/user/update/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "sample"}'

2.6auth.user.delete

DELETE /v1/auth/user/delete/{user_id}

Delete an auth user and cascade-revoke its sessions. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.

Returns

{ ok: boolean }
NameTypeDescription
okbooleanWhether the user was deleted
user_idstring | nullIdentifier of the deleted user

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X DELETE https://api.infrai.cc/v1/auth/user/delete/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.7auth.session.create

POST /v1/auth/session/create

Mint an authenticated session for a user. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
method"password" | "magic_link" | "otp" | "oauth" | "passkey"OptionalAuthentication method used for the session.
default: "password"
mfa_factorstringOptionalMFA factor / code when require_mfa is set.
require_mfabooleanOptionalRequire an MFA factor to issue the session.
default: false
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Session { session_id, access_token, refresh_token, expires_at }
NameTypeDescription
challenge_idstringIdentifier for the authentication challenge
method"password" | "magic_link" | "otp" | "oauth" | "passkey"Authentication method used (e.g. email_otp, oauth, password)
redirect_uristring | nullFor oauth method.
expires_atstringISO 8601 timestamp when this resource or token expires
format: date-time

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/session/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "sample"}'

2.8auth.session.verify

GET /v1/auth/session/verify/{session_id}

Verify a session_id / JWT against the infrai JWKS and return the Session.

Parameters

NameTypeRequiredDescription
session_idstring
Required
The session id.

Returns

{ valid: boolean, user_id?, expires_at? }
NameTypeDescription
session_idstringUnique identifier for this session
user_idstringUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
started_atstringISO 8601 timestamp when execution started
format: date-time
expires_atstringISO 8601 timestamp when this resource or token expires
format: date-time
ipstring | nullIP address from which the session was created
uastring | nullUser-Agent string from the session creation request
mfa_factorstring | nullActive MFA factor (see enums/AuthFactor).

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/session/verify/SESSION_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.9auth.session.refresh

POST /v1/auth/session/refresh

Exchange a refresh token for a new session; enforces 5-min cooldown (AUTH_REFRESH_TOO_FREQUENT). Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
refresh_tokenstring
Required
A valid refresh token to exchange for a new session.
≥ 1 chars
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

Session
NameTypeDescription
access_tokenstringShort-lived access token for API authentication
refresh_tokenstringLong-lived token used to obtain new access tokens
expires_inintegerSeconds until access_token expiry.
≥ 1

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/session/refresh \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"refresh_token": "sample"}'

2.10auth.session.revoke

POST /v1/auth/session/revoke/{session_id}

Revoke a single session by session_id. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
session_idstring
Required
The session id.
≥ 1 chars
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

{ ok: boolean }
NameTypeDescription
okbooleanWhether the session was revoked
countintegerNumber of sessions revoked (auth.session.revoke_all_for_user only)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/session/revoke/SESSION_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"session_id": "sample"}'

2.11auth.session.revoke_all_for_user

POST /v1/auth/session/revoke_all_for_user/{user_id}

Revoke all active sessions for a user (e.g. password reset / logout-everywhere). Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
except_session_idstringOptionalKeep this session; revoke all others.

Returns

{ revoked: number }
NameTypeDescription
okbooleanWhether the session was revoked
countintegerNumber of sessions revoked (auth.session.revoke_all_for_user only)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/session/revoke_all_for_user/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "sample"}'

2.12auth.session.list_for_user

GET /v1/auth/session/list_for_user/{user_id}

List active sessions for a given user.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.

Returns

{ items: Session[] }
NameTypeDescription
itemsobject[]List of session records

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/session/list_for_user/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.13auth.consent.grant

POST /v1/auth/consent/grant/{user_id}

Record a GDPR/CCPA consent grant for a user/category. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
category"marketing" | "analytics" | "essential" | "third_party"
Required
Consent category, e.g. marketing or analytics.
sourcestringOptionalHow the consent was captured.
default: "explicit"
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

{ ok: boolean }
NameTypeDescription
okbooleanWhether the operation succeeded
consent_idstringIdentifier of the consent record (auth.consent.grant only)
user_idstringUser identifier
categorystringConsent category affected
grantedbooleanWhether consent is granted (auth.consent.grant only)
granted_atstring | nullISO 8601 timestamp when consent was granted (auth.consent.grant only)
revoked_atstring | nullISO 8601 timestamp when consent was revoked, if any (auth.consent.grant only)
sourcestringHow consent was captured, e.g. 'explicit' (auth.consent.grant only)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/consent/grant/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "sample", "category": "marketing"}'

2.14auth.consent.revoke

POST /v1/auth/consent/revoke/{user_id}

Revoke a previously granted consent for a user/category. Accepts idempotency_key.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
category"marketing" | "analytics" | "essential" | "third_party"
Required
Consent category, e.g. marketing or analytics.
idempotency_keystringOptionalClient-supplied key to make the call idempotent.

Returns

{ ok: boolean }
NameTypeDescription
okbooleanWhether the operation succeeded
consent_idstringIdentifier of the consent record (auth.consent.grant only)
user_idstringUser identifier
categorystringConsent category affected
grantedbooleanWhether consent is granted (auth.consent.grant only)
granted_atstring | nullISO 8601 timestamp when consent was granted (auth.consent.grant only)
revoked_atstring | nullISO 8601 timestamp when consent was revoked, if any (auth.consent.grant only)
sourcestringHow consent was captured, e.g. 'explicit' (auth.consent.grant only)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/consent/revoke/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"user_id": "sample", "category": "marketing"}'

2.15auth.consent.check

GET /v1/auth/consent/check/{user_id}/{category}

Check whether a user currently holds consent for a given category (boolean).

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.
categorystring
Required
Consent category, e.g. marketing or analytics.

Returns

{ granted: boolean, source?, granted_at? }
NameTypeDescription
resultbooleanWhether consent is currently granted for this user/category

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/consent/check/USER_ID/CATEGORY \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.16auth.consent.list_for_user

GET /v1/auth/consent/list_for_user/{user_id}

List all consent records for a user across GDPR categories.

Parameters

NameTypeRequiredDescription
user_idstring
Required
The user id.

Returns

{ items: Array<{ category, granted, source?, granted_at? }> }
NameTypeDescription
itemsobject[]List of consent records

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X GET https://api.infrai.cc/v1/auth/consent/list_for_user/USER_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

2.17auth.identity.resolve

POST /v1/auth/identity/resolve

Resolve-or-create a unified end-user from a third-party identity you've already verified — the tenant-vouched model (Auth0/Clerk-style). For native Sign in with Apple: your backend verifies Apple's identityToken (signature against Apple's JWKS, iss/aud), then calls this with the Apple sub to bind and return a stable infrai user. Idempotent: the same (provider, value) always resolves to the same user_id. No infrai-side per-app registration is required.

Parameters

NameTypeRequiredDescription
type"email" | "phone" | "external"
Required
Identity kind: "external" (a third-party provider subject), "email", or "phone".
e.g. email
valuestring
Required
The identity value — for external, the provider subject (e.g. the Apple `sub`).
e.g. user@example.com
providerstringOptionalProvider for an external identity, e.g. "apple", "google", "wechat".
createbooleanOptionalWhether to create a new identity if none matches.
default: true
verifiedbooleanOptionalMark the identity as proven — set true once your backend has verified the provider token.
account_idstringOptionalThe account id to associate with the resolved identity.

Returns

{ user: AuthUser, identity: Identity, created: boolean }
NameTypeDescription
userobjectThe resolved end-user record
identityobjectThe matched identity record (type/provider/value/user_id/verified/created_at)
createdbooleanWhether a new user was minted by this call (auth.identity.resolve only)

Example

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."
bash
curl -X POST https://api.infrai.cc/v1/auth/identity/resolve \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"type": "email", "value": "user@example.com"}'
Advanced: pin a vendor

By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.

GET /v1/discovery/{capability}

auth.user.create

3. All capabilities

Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.

auth.consent.checkGET /v1/auth/consent/check/{user_id}/{category}

Check whether a user currently holds consent for a given category (boolean).

Parameters (2)
NameTypeRequiredDescription
categorystringRequiredPath parameter.
user_idstringRequiredPath parameter.
auth.consent.grantPOST /v1/auth/consent/grant/{user_id}

Record a GDPR/CCPA consent grant for a user/category. Accepts idempotency_key.

Parameters (4)
NameTypeRequiredDescription
user_idstringRequiredPath param.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
category"marketing" | "analytics" | "essential" | "third_party"RequiredConsent category (e.g. marketing, analytics)
sourcestringOptionalHow consent was captured.
default: "explicit"
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.consent.list_for_userGET /v1/auth/consent/list_for_user/{user_id}

List all consent records for a user across GDPR categories.

Parameters (1)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
auth.consent.revokePOST /v1/auth/consent/revoke/{user_id}

Revoke a previously granted consent for a user/category. Accepts idempotency_key.

Parameters (3)
NameTypeRequiredDescription
user_idstringRequiredPath param.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
category"marketing" | "analytics" | "essential" | "third_party"RequiredConsent category (e.g. marketing, analytics)
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.email.change_confirmPOST /v1/auth/email/change_confirm

Confirm an email change with the single-use token from the new address; switches the user's email. Returns AUTH_TOKEN_REUSED on replay. Accepts idempotency_key.

Parameters (2)
NameTypeRequiredDescription
tokenstringRequiredAuthentication or verification token
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.email.change_requestPOST /v1/auth/email/change_request

Start an email change for a user; sends a single-use signed verification token to the NEW address (self-built, no BYOK). Accepts idempotency_key.

Parameters (3)
NameTypeRequiredDescription
user_idstringRequiredUser identifier associated with this resource
≥ 1 chars
new_emailstringRequiredNew email address; the signed verification link is sent here.
≥ 3 charsformat: email
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.email.send_codePOST /v1/auth/email/send_code

Send a short-lived single-use email OTP to a user for verification or passwordless login (self-built). Accepts idempotency_key.

Parameters (4)
NameTypeRequiredDescription
emailstringRequiredEmail address
≥ 3 charsformat: email
purpose"verify" | "login"OptionalPurpose of the DNS record
default: "verify"
localestringOptionalEnd-user's current language (BCP-47, e.g. 'zh-CN' / 'en'); the OTP email is rendered in it (zh/en supported, default en). Pass your app's UI locale so the code reaches the user in their language.
e.g. zh-CN
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.email.verifyPOST /v1/auth/email/verify

Verify an email OTP AND log in: on success resolves-or-creates the unified user (passwordless signup) and mints a session, returning {verified, user_id, created, session_id, access_token, refresh_token, expires_at} — a one-call login matching Auth0/Clerk/Supabase verifyOtp. Pass login=false for a bare code-check. Wrong/expired returns AUTH_CODE_INVALID. Accepts idempotency_key.

Parameters (3)
NameTypeRequiredDescription
emailstringRequiredEmail address
≥ 3 charsformat: email
codestringRequiredAuthorization code from the OAuth provider
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.identity.addPOST /v1/auth/identity/add/{user_id}

Bind an additional login identity (email/phone/external) to an existing user. Idempotent if already this user's; IDENTITY_ALREADY_LINKED if another user owns it (no auto-merge).

Parameters (7)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
type"email" | "phone" | "external"RequiredIdentity kind.
e.g. email
valuestringRequiredThe identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).
e.g. user@example.com
providerstring | nullOptionalFor type=external: the provider id (e.g. wechat, google, github).
createboolean | nullOptionalresolve(): create a unified user when none matches (default true).
default: true
verifiedboolean | nullOptionalMark the identity verified on attach (e.g. a tenant-vouched external subject).
account_idstring | nullOptionalTenant scope (defaults to the authenticated account).
auth.identity.getPOST /v1/auth/identity/get

Look up the end-user that owns a given identity (email/phone/external subject) without creating one; returns IDENTITY_NOT_FOUND if unknown.

Parameters (6)
NameTypeRequiredDescription
type"email" | "phone" | "external"RequiredIdentity kind.
e.g. email
valuestringRequiredThe identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).
e.g. user@example.com
providerstring | nullOptionalFor type=external: the provider id (e.g. wechat, google, github).
createboolean | nullOptionalresolve(): create a unified user when none matches (default true).
default: true
verifiedboolean | nullOptionalMark the identity verified on attach (e.g. a tenant-vouched external subject).
account_idstring | nullOptionalTenant scope (defaults to the authenticated account).
auth.identity.listGET /v1/auth/identity/list/{user_id}

List every login identity (email/phone/external) attached to a user.

Parameters (1)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
auth.identity.removeDELETE /v1/auth/identity/remove/{user_id}/{identity_id}

Unlink one identity from a user; refuses IDENTITY_LAST_REMAINING when it is the user's only remaining identity.

Parameters (2)
NameTypeRequiredDescription
identity_idstringRequiredPath parameter.
user_idstringRequiredPath parameter.
auth.identity.resolvePOST /v1/auth/identity/resolve

Unified login/register: resolve a (tenant-vouched) email, phone, or external-provider identity to its end-user, minting the user + identity if unknown. type=external + provider (e.g. 'wechat') + value=<subject> handles any third-party login; one person who arrives via different identities maps to the SAME user_id.

Parameters (6)
NameTypeRequiredDescription
type"email" | "phone" | "external"RequiredIdentity kind.
e.g. email
valuestringRequiredThe identity address/subject — an email, an E.164 phone, or a provider subject id (must match `type`).
e.g. user@example.com
providerstring | nullOptionalFor type=external: the provider id (e.g. wechat, google, github).
createboolean | nullOptionalresolve(): create a unified user when none matches (default true).
default: true
verifiedboolean | nullOptionalMark the identity verified on attach (e.g. a tenant-vouched external subject).
account_idstring | nullOptionalTenant scope (defaults to the authenticated account).
auth.oauth.authorize_urlGET /v1/auth/oauth/authorize_url

Build the provider authorize URL (provider must be one of the enabled set — see auth.oauth.providers) with state, nonce and PKCE challenge; return_to/redirect_uri must be in the account's registered allowlist.

Parameters (3)
NameTypeRequiredDescription
provider"google" | "github" | "apple" | "facebook"RequiredOAuth provider name (e.g. google, github)
return_tostring | nullOptionalUnified-brand transit (preferred): final web URL or app deep link to 302 back to after Infrai's transit endpoint completes the flow. Must be in the account's allowlist.
e.g. https://app.example.com/auth/done
redirect_uristring | nullOptionalLegacy customer-BFF: the caller's own provider redirect URI (used when `return_to` is absent). Must be in the account's allowlist.
format: urie.g. https://app.example.com/oauth/callback
auth.oauth.callbackPOST /v1/auth/oauth/callback

Complete the OAuth flow: validate state + redirect_uri, exchange the code, link/create the user and mint a session. Honest typed error if the provider is not configured.

Parameters (6)
NameTypeRequiredDescription
provider"google" | "github" | "apple" | "facebook"RequiredOAuth provider name (e.g. google, github)
codestringRequiredAuthorization code from the OAuth provider
≥ 1 chars
statestringRequiredCurrent lifecycle state of this resource
≥ 1 chars
redirect_uristringRequiredRedirect URI registered with the OAuth provider
≥ 1 charsformat: uri
code_verifierstring | nullOptionalPKCE verifier matching the challenge from authorize_url.
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.oauth.providersGET /v1/auth/oauth/providers

List the OAuth providers an end user can sign in with right now, each flagged ready (real client_id configured), plus the unified consent-screen brand. The runtime companion to the AuthProvider enum in discovery.

No request parameters.

auth.password.changePOST /v1/auth/password/change

Change a user's password after verifying the current one (AUTH_INVALID_CREDENTIALS on mismatch); argon2id re-hash. Accepts idempotency_key.

Parameters (4)
NameTypeRequiredDescription
user_idstringRequiredUser identifier associated with this resource
≥ 1 chars
current_passwordstringRequiredCurrent password for verification
≥ 1 chars
new_passwordstringRequiredNew password for the account
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.password.reset_confirmPOST /v1/auth/password/reset_confirm

Confirm a password reset with {email, code, new_password} — verifies the 6-digit code from reset_request, re-hashes (argon2id) and revokes all sessions. Wrong/expired code returns AUTH_CODE_INVALID; weak password returns AUTH_PASSWORD_TOO_WEAK. Accepts idempotency_key.

Parameters (4)
NameTypeRequiredDescription
emailstringRequiredEmail address
format: email
codestringRequiredAuthorization code from the OAuth provider
4–8 chars
new_passwordstringRequiredNew password for the account
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.password.reset_requestPOST /v1/auth/password/reset_request

Request a password reset (code-style, Supabase pattern); always returns 200 (no user-existence leak) and emails a single-use 6-digit code when the email is known. Accepts idempotency_key.

Parameters (2)
NameTypeRequiredDescription
emailstringRequiredEmail address
≥ 3 charsformat: email
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.phone.send_codePOST /v1/auth/phone/send_code

Send a short-lived single-use phone (SMS) OTP to a user (self-built; SMS delivery depends on infra.sms). Accepts idempotency_key.

Parameters (4)
NameTypeRequiredDescription
phonestringRequiredPhone number in E.164 format
≥ 3 chars
purpose"verify" | "login"OptionalPurpose of the DNS record
default: "verify"
localestringOptionalEnd-user's current language (BCP-47, e.g. 'zh-CN' / 'en'); the OTP SMS is rendered in it (zh/en supported, default en). Pass your app's UI locale so the code reaches the user in their language.
e.g. zh-CN
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.phone.verifyPOST /v1/auth/phone/verify

Verify a phone OTP AND log in: on success resolves-or-creates the unified user (passwordless signup) and mints a session, returning {verified, user_id, created, session_id, access_token, refresh_token, expires_at} — a one-call login matching Auth0/Clerk/Supabase. Pass login=false for a bare code-check. Wrong/expired returns AUTH_CODE_INVALID. Accepts idempotency_key.

Parameters (3)
NameTypeRequiredDescription
phonestringRequiredPhone number in E.164 format
≥ 3 chars
codestringRequiredAuthorization code from the OAuth provider
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.session.createPOST /v1/auth/session/create

Mint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.

Parameters (5)
NameTypeRequiredDescription
user_idstringRequiredUser identifier associated with this resource
pattern: ^au_usr_[A-Za-z0-9]{20,}$
method"password" | "magic_link" | "otp" | "oauth" | "passkey"OptionalAuthentication method used (e.g. email_otp, oauth, password)
default: "password"
mfa_factorstring | nullOptionalMFA factor / code when require_mfa.
require_mfabooleanOptionalWhether MFA is required to complete authentication
default: false
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.session.list_for_userGET /v1/auth/session/list_for_user/{user_id}

List active sessions for a given user.

Parameters (1)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
auth.session.refreshPOST /v1/auth/session/refresh

Exchange a refresh token for a new session; enforces 5-min cooldown (AUTH_REFRESH_TOO_FREQUENT). Accepts idempotency_key.

Parameters (2)
NameTypeRequiredDescription
refresh_tokenstringRequiredLong-lived token used to obtain new access tokens
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.session.revokePOST /v1/auth/session/revoke/{session_id}

Revoke a single session by session_id. Accepts idempotency_key.

Parameters (2)
NameTypeRequiredDescription
session_idstringRequiredPath param; the session to revoke.
≥ 1 chars
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.session.revoke_all_for_userPOST /v1/auth/session/revoke_all_for_user/{user_id}

Revoke all active sessions for a user (e.g. password reset / logout-everywhere). Accepts idempotency_key.

Parameters (2)
NameTypeRequiredDescription
user_idstringRequiredPath param; revoke all this user's active sessions.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
except_session_idstring | nullOptionalKeep this one session alive (e.g. the current browser).
auth.session.verifyGET /v1/auth/session/verify/{session_id}

Verify a session_id / JWT against the vendor JWKS (RS256+ES256) and return the Session.

Parameters (1)
NameTypeRequiredDescription
session_idstringRequiredPath parameter.
auth.token.jwksGET /v1/auth/token/jwks

Return the public JWKS (EdDSA) for offline verification of Infrai-issued access JWTs — clients verify tokens with zero round-trips.

No request parameters.

auth.user.createPOST /v1/auth/user/create

Create an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key.

Parameters (6)
NameTypeRequiredDescription
emailstringRequiredEmail address
format: email
passwordstring | nullOptionalOptional initial password (vendor-dependent).
metadataobject | nullOptionalArbitrary key-value metadata attached to this resource
vendor"infrai_native" | nullOptionalExplicit vendor pin (auth is self-operated: infrai_native only).
mode"default_vendor" | "verified_account"OptionalDelivery mode or operation mode
default: "default_vendor"
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry
auth.user.deleteDELETE /v1/auth/user/delete/{user_id}

Delete an auth user and cascade-revoke its sessions. Accepts idempotency_key.

Parameters (1)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
auth.user.getGET /v1/auth/user/get/{user_id}

Fetch a single auth user by user_id from its pinned vendor.

Parameters (1)
NameTypeRequiredDescription
user_idstringRequiredPath parameter.
auth.user.get_by_emailGET /v1/auth/user/get_by_email

Look up an auth user by email address.

No request parameters.

auth.user.listGET /v1/auth/user/list

Cursor-paginated list of auth users for the account.

No request parameters.

auth.user.updatePATCH /v1/auth/user/update/{user_id}

Update mutable fields (metadata, phone, MFA) of an existing auth user. Accepts idempotency_key.

Parameters (5)
NameTypeRequiredDescription
user_idstringRequiredPath param; the user to update.
pattern: ^au_usr_[A-Za-z0-9]{20,}$
metadataobject | nullOptionalArbitrary key-value metadata attached to this resource
email_verifiedboolean | nullOptionalWhether the email address has been verified
mfa_enabledboolean | nullOptionalWhether multi-factor authentication is enabled for this user
idempotency_keystring | nullOptionalClient-provided idempotency key; prevents duplicate execution on retry

4. End-to-end example

A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.

A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.

python
#!/usr/bin/env python3
"""Infrai · auth — runnable real-app example (single file, zero deps).

Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request

KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..."  # <- your key
BASE = "https://api.infrai.cc"


# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
    req = request.Request(
        BASE + path, method=method,
        data=json.dumps(body).encode() if body is not None else None,
        headers={"Authorization": f"Bearer {KEY}",
                 "Content-Type": "application/json"})
    try:
        with request.urlopen(req, timeout=60) as r:
            return json.loads(r.read())
    except error.HTTPError as e:
        return json.loads(e.read())


def show(label, resp):
    print(f"\n== {label} ==")
    print(json.dumps(resp, indent=2, ensure_ascii=False))
    return resp


# 1) auth.user.create — POST /v1/auth/user/create · Create an auth user across a vendor (Clerk/WorkOS/Supabase Auth). Pins the vendor of record (sticky-on-resource). Accepts idempotency_key.
r1 = show("auth.user.create", infrai("POST", "/v1/auth/user/create", {"email":"user@example.com"}))

# 2) auth.session.create — POST /v1/auth/session/create · Mint an authenticated session for a user; routes to the user's pinned vendor. May return AUTH_MFA_REQUIRED. Accepts idempotency_key.
r2 = show("auth.session.create", infrai("POST", "/v1/auth/session/create", {"user_id":"sample"}))

# 3) auth.user.get_by_email — GET /v1/auth/user/get_by_email · Look up an auth user by email address.
r3 = show("auth.user.get_by_email", infrai("GET", "/v1/auth/user/get_by_email"))