Skip to main content

createPhoneNumber()

Creates a new phone number for the given user.

Returns the created PhoneNumber object.

function createPhoneNumber(params: CreatePhoneNumberParams): Promise<PhoneNumber>
  • Name
    phoneNumber
    Type
    string
    Description

    The phone number to assign to the specified user. Must be in E.164 format.

  • Name
    primary?
    Type
    boolean
    Description

    Whether the phone number should be the primary phone number. Defaults to false, unless it is the first phone number added to the user.

  • Name
    reservedForSecondFactor?
    Type
    boolean
    Description

    Whether the phone number should be reserved for multi-factor authentication. The phone number must also be verified. If there are no other reserved , the phone number will be set as the default second factor. Defaults to false.

  • Name
    userId
    Type
    string
    Description

    The ID of the user to create the phone number for.

  • Name
    verified?
    Type
    boolean
    Description

    Whether the phone number should be verified. Defaults to false.

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 response = await clerkClient.phoneNumbers.createPhoneNumber({
  userId: 'user_123',
  phoneNumber: '15551234567',
  primary: true,
  verified: true,
})

Backend API (BAPI) endpoint

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

Feedback

What did you think of this content?

Last updated on