Docs

You are viewing an archived version of the docs.Go to latest version

updateEmailAddress()

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

function updateEmailAddress: (emailAddressId: string, params: UpdateEmailAddressParams) => Promise<EmailAddress>;
  • Name
    primary?
    Type
    boolean
    Description

    Whether or not to set the email address as the user's primary email address.

  • Name
    verified?
    Type
    boolean
    Description

    Whether or not the email address is verified.

updateEmailAddress() example

Let's start with an EmailAddress object that looks like this:

_EmailAddress {
  id: 'idn_2bxp56VCiqMn4ClF3oMXBaF9iec',
  emailAddress: 'testclerk123@gmail.com',
  verification: _Verification {
    status: 'verified',
    strategy: 'from_oauth_google',
    externalVerificationRedirectURL: null,
    attempts: null,
    expireAt: null,
    nonce: null
  },
  linkedTo: [
    _IdentificationLink {
      id: 'idn_2bxfCN3UaowKZYKJJKcefzOLq0E',
      type: 'oauth_google'
    }
  ]
}

Let's update the email address to be unverified:

const emailAddressId = 'idn_2bxp56VCiqMn4ClF3oMXBaF9iec';

const params = { verified: false };

const response = await clerkClient.emailAddresses.updateEmailAddress(emailAddressId, params);

console.log(response);
/*
_EmailAddress {
  id: 'idn_2bxp56VCiqMn4ClF3oMXBaF9iec',
  emailAddress: 'testclerk123@gmail.com',
  verification: null,
  linkedTo: []
}
*/

As you can see in the response, the email address is now unverified.

Backend API (BAPI) endpoint

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

Feedback

What did you think of this content?

Last updated on