createSignInToken()
Creates a new sign-in token for the given user. By default, sign-in tokens expire in 30 days, or in 10 minutes when secondFactorVerification is set. You can optionally specify a custom expiration time in seconds using the expiresInSeconds parameter.
Returns the created SignInToken object.
function createSignInToken(params: CreateSignInTokensParams): Promise<SignInToken>- Name
-
secondFactorVerification? - Type
"fresh" | "stale"- Description
Lets a user with a second factor enabled complete the sign-in without being prompted for it. With
fresh, the second factor is treated as verified at sign-in. Withstale, it is treated as unverified, so any reverification that requires a second factor prompts the user to complete one. Has no effect for users without a second factor enabled.
const userId = 'user_123'
const orgId = 'org_123'
const expiresInSeconds = 60 * 60 * 24 * 7 // 1 week
const response = await clerkClient.signInTokens.createSignInToken({
userId,
orgId,
expiresInSeconds,
})The orgId parameter scopes the token to an Organization: when the token is redeemed, Clerk activates that Organization for the new session. Organizations must be enabled for the instance, and the user must be a member of the Organization. To consume the returned token in a native app, pass response.token to signInWithTicket() for Android or signInWithTicket() for iOS.
Backend API (BAPI) endpoint
This method in the SDK is a wrapper around the BAPI endpoint POST /sign_in_tokens. The SDK's orgId parameter is sent to the Backend API as org_id. See the BAPI reference for more information.
Feedback
Last updated on