PhoneNumber

@Serializable
data class PhoneNumber(val id: String, val phoneNumber: String, val verification: Verification? = null, val reservedForSecondFactor: Boolean = false, val defaultSecondFactor: Boolean = false, val createdAt: Long? = null, val updatedAt: Long? = null, val linkedTo: List<String>? = null, val backupCodes: List<String>? = null)

The PhoneNumber object is a model around a phone number entity.

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 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 attemptVerification(code:) method, passing the one-time code as a parameter.

Finally, phone numbers can be used as part of multi-factor authentication. During sign-in, users can opt in to an extra verification step where they will receive an SMS message with a one-time code. This code must be entered to complete the sign-in process.

Constructors

Link copied to clipboard
constructor(id: String, phoneNumber: String, verification: Verification? = null, reservedForSecondFactor: Boolean = false, defaultSecondFactor: Boolean = false, createdAt: Long? = null, updatedAt: Long? = null, linkedTo: List<String>? = null, backupCodes: List<String>? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val backupCodes: List<String>? = null

A list of backup codes in case of lost phone number access.

Link copied to clipboard
val createdAt: Long? = null

The date when the phone number was created.

Link copied to clipboard

A boolean indicating whether this phone number is the default second factor.

Link copied to clipboard
val id: String

The unique identifier for this phone number.

Link copied to clipboard

Convenience function for telling whether or not the phone number is the primary one

Link copied to clipboard

Convenience function for telling whether or not the phone number is verified

Link copied to clipboard
val linkedTo: List<String>? = null

An object containing information about any other identification that might be linked to this phone number.

Link copied to clipboard

The phone number value.

Link copied to clipboard

A boolean indicating whether this phone number is reserved for second factor authentication.

Link copied to clipboard
val updatedAt: Long? = null

The date when the phone number was last updated.

Link copied to clipboard

An object holding information on the verification of this phone number.

Functions

Link copied to clipboard

Attempts to verify this phone number using the provided verification code.

Link copied to clipboard

Deletes this phone number from the user's account.

Link copied to clipboard

Initiates the phone number verification process by sending a verification code via SMS.

Link copied to clipboard
suspend fun PhoneNumber.update(reservedForSecondFactor: Boolean? = null, defaultSecondFactor: Boolean? = null): ClerkResult<PhoneNumber, ClerkErrorResponse>

Updates the properties of this phone number.