EmailAddress

The EmailAddress object describes a User's email address.

Overview

The EmailAddress object is a model around an email address. Email addresses are used to provide identification for users.

Email addresses must be verified, so that we can make sure they can be assigned to their rightful owners. The EmailAddress object holds all necessary state around the verification process.

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

Finally, email addresses can be linked to other identifications.

Attributes

Name

Description

id

string

A unique identifier for this email address.

emailAddress

string

The value of this email address, the actual email box address.

verification

VerificationResource

An object holding information on the verification of this email address.

linkedTo

IndentificationLinkResource

An object containing information about any identifications that might be linked to this email address.

Methods

attemptVerification(code)

attemptVerification(code: string) => Promise<EmailAddressResource>

Attempts to verify this email address, passing the one-time code that was sent as an email message. The code will be sent when calling the EmailAddress.prepareVerification() method.

Parameters
Returns
Parameters

Name

Description

code

string

The one-time code to be checked. Code needs to match the value that was sent via email.

Returns

Promise<EmailAddressResource>

This method returns a Promise which resolves with an EmailAddress object.

destroy()

destroy() => Promise<void>

Delete this email address.

Parameters
Returns
Parameters

This method accepts no parameters.

Returns

Promise<void>

This method returns a Promise which doesn't resolve to any value.

prepareVerification()

prepareVerification() => Promise<EmailAddressResource>

Kick off the verification process for this email address. An email message with a one-time code will be sent to the email address box.

Parameters
Returns
Parameters

This method accepts no parameters.

Returns

Promise<EmailAddressResource>

This method returns a Promise which resolves with an EmailAddress object.

toString()

toString() => string | null

Returns the value for this email address. Can also be accessed via the EmailAddress.emailAddress attribute.

Parameters
Returns
Parameters

This method accepts no parameters.

Returns

string | null

This method returns the email address attribute.

Interfaces

IdentificationLinkResource

Property

Description

id

string

A unique identifier for the identification.

type

string

The identification type.

VerificationResource

Property

Description

status

string | null

The verification status. Possible values are:

  • unverified: The verification process has not been completed.

  • verified: The verification process has completed successfully.

  • transferable: The verification can be transferred as part of an external account verification process.

  • failed: The verification process has been completed, but failed.

  • expired: The verification is invalid because it wasn't completed in the allowed time.

strategy

string | null

The verification strategy. Possible strategy values are:

  • email_code: User will receive a one-time authentication code via email. At least one email address should be on file for the user. The email_address_id parameter can also be specified to select one of the user's known email addresses.

  • phone_code: User will receive a one-time authentication code in their phone, via SMS. At least one phone number should be on file for the user. The phone_number_id parameter can also be specified to select which of the user's known phone numbers the SMS will go to.

  • password: The user needs to provide their password in order to be authenticated.

  • oauth_google: The user will be authenticated with their Google account (Google SSO).

  • oauth_facebook: The user will be authenticated with their Facebook account (Facebook SSO).

  • oauth_hubspot: The user will be authenticated with their Hubspot account (Hubspot SSO).

  • oauth_github: The user will be authenticated with their Github account (Github SSO).

  • oauth_tiktok: The user will be authenticated with their TikTok account (TikTok SSO).

attempts

number | null

The number of attempts to complete the verification so far. Usually, a verification allows for maximum 3 attempts to be completed.

expireAt

Date | null

The timestamp when the verification will expire and cease to be valid.

error

ClerkAPIError | null

Any error that occurred during the verification process from the Clerk API.

externalVerificationRedirectURL

URL | null

If this is a verification that is based on an external account (usually oauth_*), this is the URL that the user will be redirected to after the verification is completed.