āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā š shadcn/directory/clerk/clerk-docs/reference/backend/phone-numbers/create-phone-number ā āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
createPhoneNumber()'
description: Use Clerk's JS Backend SDK to create a phone number for the specified user.
sdk: js-backend{/* clerk/javascript file: https://github.com/clerk/javascript/blob/main/packages/backend/src/api/endpoints/PhoneNumberApi.ts#L29 */}
Creates a PhoneNumber for the specified user.
function createPhoneNumber(params: CreatePhoneNumberParams): Promise<PhoneNumber>
CreatePhoneNumberParamsThe ID of the user to create the phone number for.
phoneNumberstringThe phone number to assign to the specified user. Must adhere to the E.164 format standard for phone number format.
primary?booleanWhether or not to set the phone number as the user's primary phone number. Defaults to false, unless it is the first phone number.
verified?booleanWhether or not the phone number is verified.
reservedForSecondFactorbooleanWhether or not the phone number is reserved for multi-factor authentication. The phone number must also be verified. If there are no other reserved second factors, the phone number will be set as the default second factor. </Properties>
const response = await clerkClient.phoneNumbers.createPhoneNumber({
userId: 'user_123',
phoneNumber: '15551234567',
primary: true,
verified: true,
})
This method in the SDK is a wrapper around the BAPI endpoint POST/phone_numbers. See the BAPI reference{{ target: '_blank' }} for more information.
ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā