Skip to main content
The API object for the custom-token-exchange Actions trigger includes:

api.access

Modify the access of the token exchange request, such as rejecting the request.

api.access.deny(code, reason)

Mark the current token exchange as denied. If the request is being denied due to an invalid subject token, we recommend that api.access.rejectInvalidSubjectToken be used instead, to distinguish between brute force attempts on the subject token, and other reasons to deny the request.
Parameters

api.access.rejectInvalidSubjectToken(reason)

Mark the provided subject token from the request as invalid. This will cause the request to be rejected with an “invalid_request” error code. This will signal to the Attack Protection features that an invalid subject token has been provided, so that protections to prevent brute force attacks on the subject token can be applied.
Parameters

api.authentication

Indicate the result of the authentication of the subject token, to specify the user whom tokens will be issued for.

api.authentication.setUserById(user_id)

Indicate the user corresponding to the subject_token, by providing the userId. The token exchange request will issue tokens for this user. This must be an existing user. Note: Exactly one of api.authentication.setUserByConnection api.authentication.setUserById must be called by the Custom Token Exchange action.
Parameters

api.authentication.setUserByConnection(connection_name, user_attributes, options)

Indicate the user corresponding to the subject_token, by providing a connection and user attributes. The token exchange request will issue tokens for this user. This can be either an existing user, or a new user. If the user does not exist, it will be created. The user_id property of the user_profile will be used to determine if the user already exists. Note: Exactly one of api.authentication.setUserByConnection api.authentication.setUserById must be called by the Custom Token Exchange action.
Set user by connection with full profile attributes
Create a user without verifying email
Parameters

api.authentication.setOrganization(organization_id_or_name)

Set the organization for the user associated with the token exchange.
Parameters

api.authentication.setActor(actor)

Set the actor for the token exchange to represent the entity acting on behalf of the subject. Must be used alongside the setUserById or SetUserByConnection commands. Calling setActor is optional. Receiving an actor_token in the request does not automatically produce an act claim; the Action must explicitly call this method. Refresh tokens are not issued when an actor is set for the transaction.
Parameters

api.user

Request changes to the user corresponding to the subject token.

api.user.setAppMetadata(key, value)

Set application-specific metadata for the user corresponding to the subject token.
Parameters

api.user.setUserMetadata(key, value)

Set general metadata for the user corresponding to the subject token.
Parameters

api.cache

Store and retrieve data that persists across executions.

api.cache.delete(key)

Delete a record describing a cached value at the supplied key if it exists. Parameters

api.cache.get(key)

Retrieve a record describing a cached value at the supplied key, if it exists. If a record is found, the cached value can be found at the value property of the returned object. Parameters

api.cache.set(key, value, options)

Store or update a string value in the cache at the specified key. Values stored in this cache are scoped to the Trigger in which they are set. They are subject to the Actions Cache Limits. Values stored in this way will have lifetimes of up to the specified ttl or expires_at values. If no lifetime is specified, a default of lifetime of 15 minutes will be used. Lifetimes may not exceed the maximum duration listed at Actions Cache Limits. 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 their lifetime. Parameters