Skip to main content
The API object for the post-login Actions trigger exposes methods for controlling access, customizing tokens, managing authentication state, configuring redirects, and more.

api.access

Modify the access of the user that is logging in, such as rejecting the login attempt.
api.access.deny(reason)
void
Mark the current login attempt as denied. This prevents the end-user from completing the login flow. This will NOT cancel other user-related side-effects (such as metadata changes) requested by this Action.
Example
Parameters

api.accessToken

Request changes to the access token being issued.
api.accessToken.setCustomClaim(key, value)
void
Set a custom claim on the access token issued upon completion of the login flow.
Example
Parameters
api.accessToken.addScope(scope)
void
Add a scope to the access token issued upon completion of the login flow.
Example
Parameters
api.accessToken.removeScope(scope)
void
Remove a scope from the access token issued upon completion of the login flow.
Example
Parameters

api.idToken

Request changes to the ID token being issued.
api.idToken.setCustomClaim(key, value)
void
Set a custom claim on the ID token issued upon completion of the login flow.
Example
Parameters

api.authentication

Request changes to the authentication state of the current user’s session.
api.authentication.challengeWith(factor, options)
void
Request a challenge for MFA using the supplied factor. Subsequent Actions will not run until the challenge is fulfilled.
Challenge with a specific factor
Challenge with additional factors
Parameters
api.authentication.challengeWithAny(factors)
void
Request a challenge for MFA using any of the supplied factors, showing a factor selection screen.
Example
Parameters
api.authentication.enrollWith(factor, options)
void
Request an enrollment for MFA using the supplied factor.
Example
Parameters
api.authentication.recordMethod(provider_url)
void
Indicate that a custom authentication method has been completed. Only available from within onContinuePostLogin after a redirect.
Example
Parameters
api.authentication.setPrimaryUser(primary_user_id)
void
Change the primary user for the login transaction. Use in account-linking scenarios where the initiating identity is now a secondary identity of an existing user.IMPORTANT: Insecurely linking accounts can allow malicious actors to access legitimate user accounts. The identity used to authenticate must be among the secondary identities of the referenced user.
Example
Parameters

api.multifactor

Set or remove the requirement for MFA on the login attempt.
api.multifactor.enable(provider, options)
void
Enable MFA for this login flow. Users must complete the configured MFA challenge before completing login.
Example
Parameters

api.redirect

Configure and initiate external redirects.
api.redirect.encodeToken(options)
string
Create a signed session token for use as a query string parameter in a redirect. The target endpoint verifies authenticity using a shared secret.
Example
Parameters
api.redirect.sendUserTo(url, options)
void
Trigger a browser redirect to the target URL immediately after this action completes.
Example
Parameters
api.redirect.validateToken(options)
object
Retrieve and verify data encoded in a JWT passed to the /continue endpoint.
Example
Parameters

api.user

Make changes to the metadata of the user that is logging in.
api.user.setAppMetadata(key, value)
void
Set application-specific metadata for the user. This function works only with metadata in object format.
Example
Parameters
api.user.setUserMetadata(key, value)
void
Set general metadata for the user that is logging in. This function works only with metadata in object format.
Example
Parameters

api.session

Request changes to the current user’s session.
api.session.revoke(reason, options)
void
[Enterprise] Revoke the current user session and mark the login attempt as denied.
Revoke the session while preserving refresh tokens
Parameters
api.session.setExpiresAt(absolute)
void
[Enterprise] Sets a new absolute expiration time for the current session.
Example
Parameters
api.session.setMetadata(key, value)
void
[Enterprise] Sets a key-value pair in the metadata object of the current session.
Example
Parameters

api.refreshToken

Request changes to the current user’s refresh token.
api.refreshToken.revoke(reason)
void
[Enterprise] Revoke the current refresh token and deny the refresh token exchange.
Example
Parameters
api.refreshToken.setMetadata(key, value)
void
[Enterprise] Sets a key-value pair in the metadata object of the current refresh token.
Example
Parameters

api.validation

Prevent user from logging in by signaling a validation error.
api.validation.error(errorCode, errorMessage)
void
Throw a validation error to prevent login.
Example
Parameters

api.prompt

Render a custom prompt screen.
api.prompt.render(promptId, promptOptions)
void
Render a custom prompt during the login flow.
Example
Parameters

api.samlResponse

Configure custom SAML response attributes.
api.samlResponse.setAttribute(attribute, value)
void
Set attributes on the SAML assertion issued to the authenticated user.
Example
Parameters
api.samlResponse.setAudience(audience)
void
Set the audience of the SAML assertion. Default is the issuer on SAMLRequest.
Example
Parameters
api.samlResponse.setEncryptionAlgorithm(encryptionAlgorithm)
void
Set the encryption algorithm for the SAML assertion. Default is aes256-cbc.
Set the encryption algorithm to aes256-gcm (recommended)
Parameters

api.groups

Get information about user group membership.
api.groups.getUserGroups(params)
Promise<object>
Get the paginated list of groups the user belongs to.
Example
Parameters
api.groups.hasGroupMembership(groups)
Promise<object>
Check if the user is a member of any of the specified groups.
Example
Parameters

api.cache

Store and retrieve data that persists across executions.
api.cache.delete(key)
void
Delete a cached record at the supplied key if it exists.
Example
Parameters
api.cache.get(key)
object | undefined
Retrieve a cached record at the supplied key. If found, access the value via record.value.
Example
Parameters
api.cache.set(key, value, options)
void
Store or update a string value in the cache at the specified key. Values are scoped to the Trigger and subject to the Actions Cache Limits. If no lifetime is specified, a default lifetime of 15 minutes will be used.Important: This cache is designed for short-lived, ephemeral data. Items may not be available in later transactions even if they are within their supplied lifetime.
Example
Parameters