Skip to main content

createSignInToken()

Creates a new sign-in token for the given user. By default, sign-in tokens expire in 30 days. 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
    expiresInSeconds
    Type
    number
    Description

    The number of seconds until the sign-in token expires. By default, the duration is 2592000 (30 days).

  • Name
    userId
    Type
    string
    Description

    The ID of the user to create the sign-in token for.

Note

Using clerkClient varies based on the SDK you're using. Refer to the overview for usage details, including guidance on how to access the userId and other properties.

const userId = 'user_123'

const expiresInSeconds = 60 * 60 * 24 * 7 // 1 week

const response = await clerkClient.signInTokens.createSignInToken({
  userId,
  expiresInSeconds,
})

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/sign_in_tokens. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on