Skip to Content
You are viewing a beta version of Clerk Docs
Visit the latest docs
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

createPhoneNumber()

Creates a PhoneNumber for the specified user.

function createPhoneNumber: (params: CreatePhoneNumberParams) => Promise<PhoneNumber>;

CreatePhoneNumberParams

NameTypeDescription
userIdstringThe ID of the user to create the phone number for.
phoneNumberstringThe phone number to assign to the specified user.
primary?booleanWhether or not to set the phone number as the user's primary phone number.
verified?booleanWhether or not the phone number is verified.

createPhoneNumber() example

const response = await clerkClient.phoneNumbers.createPhoneNumber({ userId: "user_2bxfCJOe0Ocd8DNe9hFN3EXvfOu", phoneNumber: "15551234567", primary: true, verified: true }) console.log(response); /* _PhoneNumber { id: 'idn_2bxwW8Fa5Y53QcESgQ6HkTo0cgh', phoneNumber: '15551234567', reservedForSecondFactor: false, defaultSecondFactor: false, verification: _Verification { status: 'verified', strategy: 'admin', externalVerificationRedirectURL: null, attempts: null, expireAt: null, nonce: null }, linkedTo: [] } */

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/phone_numbers. See the BAPI reference(opens in a new tab) for more details.

What did you think of this content?

Clerk © 2024