Skip to main content
Docs

createSignInToken()

Creates a new sign-in token and associates it with the given user. By default, sign-in tokens expire in 30 days. You can optionally supply a different duration in seconds using the expires_in_seconds property.

function createSignInToken(params: CreateSignInTokensParams): Promise<SignInToken>
  • Name
    userId
    Type
    string
    Description

    The ID of the user who can use the newly created sign-in token.

  • Name
    expiresInSeconds
    Type
    string
    Description

    Specifies the life duration of the sign in token in seconds. Defaults to 2592000 (30 days)

Note

Importing clerkClient varies based on your framework. Refer to the Backend SDK 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