Skip to Content
Clerk logo

Clerk Docs

Ctrl + K
Go to clerk.com

PhoneNumber

The PhoneNumber object describes a phone number. Phone numbers can be used as a proof of identification for users, or simply as a means of contacting users.

Phone numbers must be verified to ensure that they can be assigned to their rightful owners. The PhoneNumber object holds all the necessary state around the verification process.

The verification process always starts with the PhoneNumber.prepareVerification() method, which will send a one-time verification code via an SMS message. The second and final step involves an attempt to complete the verification by calling the PhoneNumber.attemptVerification() method, passing the one-time code as a parameter.

Finally, phone numbers are used as part of multi-factor authentication. Users receive an SMS message with a one-time code that they need to provide as an extra verification step.

Properties

NameTypeDescription
idstringA unique identifier for this phone number.
phoneNumberstringThe value of this phone number, in E.164 format(opens in a new tab).
reservedForSecondFactorbooleanSet to true if this phone number is reserved for multi-factor authentication (2FA). Set to false otherwise.
defaultSecondFactorbooleanSet to true if this phone number is the default second factor. Set to false otherwise. A user must have exactly one default second factor, if multi-factor authentication (2FA) is enabled.
verificationVerificationAn object holding information on the verification of this phone number.
linkedToArray<{id: string, type: string}>An object containing information about any other identification that might be linked to this phone number.
backupCodes`string[]undefined`

Methods

create()

Creates a new phone number for the current user.

function create(): Promise<PhoneNumber>;

destroy()

Deletes this phone number.

function destroy(): Promise<void>;

toString()

Returns the phone number value in E.164 format(opens in a new tab). Can also be accessed via the PhoneNumber.phoneNumber attribute.

function toString(): string;

Additional methods

In addition to the methods listed above, the PhoneNumber class also has the following methods:

Validation

Second factor

Last updated on April 19, 2024

What did you think of this content?

Clerk © 2024