Docs

updatePhoneNumber()

Updates a PhoneNumber with a given ID with attribute values provided in a params object.

function updatePhoneNumber: (phoneNumberId: string, params: UpdatePhoneNumberParams) => Promise<PhoneNumber>;
  • Name
    primary?
    Type
    boolean
    Description

    Whether or not to set the phone number as the user's primary phone number.

  • Name
    verified?
    Type
    boolean
    Description

    Whether or not the phone number is verified.

Example

Let's start with a PhoneNumber object that looks like this:

_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: []
}

Let's update the phone number to be unverified:

const phoneNumberId = 'idn_2bxwW8Fa5Y53QcESgQ6HkTo0cgh';

const params = { verified: false };

const response = await clerkClient.phoneNumbers.updatePhoneNumber(phoneNumberId, params);

console.log(response);
/*
_PhoneNumber {
  id: 'idn_2bxwW8Fa5Y53QcESgQ6HkTo0cgh',
  phoneNumber: '15551234567',
  reservedForSecondFactor: false,
  defaultSecondFactor: false,
  verification: null,
  linkedTo: []
}
*/

As you can see in the response, the phone number is now unverified.

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint PATCH/phone_numbers/{phone_number_id}. See the BAPI reference for more details.

Feedback

What did you think of this content?