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 that 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)

const userId = 'user_2f9RVdIOe8JzGlfc3HWwXDg1AaX';

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

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

console.log(response);
/*
_SignInToken {
  id: 'sit_123',
  userId: 'user_123',
  token: 'eyJ...',
  status: 'pending',
  url: 'https://prepared-phoenix-00.accounts.dev/sign-in?__clerk_ticket=eyJ...',
  createdAt: 1719952616214,
  updatedAt: 1719952616214
}
*/

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 details.

Feedback

What did you think of this content?