Docs

createEmailAddress()

Creates an EmailAddress for the specified user.

function createEmailAddress(params: CreateEmailAddressParams): Promise<EmailAddress>
  • Name
    userId
    Type
    string
    Description

    The ID of the user to create the email address for.

  • Name
    emailAddress
    Type
    string
    Description

    The email address to assign to the specified user.

  • Name
    primary?
    Type
    boolean
    Description

    Whether or not to set the email address as the user's primary email address. Defaults to false, unless it is the first email address.

  • Name
    verified?
    Type
    boolean
    Description

    Whether or not the email address is verified.

const response = await clerkClient.emailAddresses.createEmailAddress({
  userId: 'user_123',
  emailAddress: 'testclerk123@gmail.com',
  primary: true,
  verified: true,
})

console.log(response)
/*
_EmailAddress {
  id: 'idn_123',
  emailAddress: 'testclerk123@gmail.com',
  verification: _Verification {
    status: 'verified',
    strategy: 'admin',
    externalVerificationRedirectURL: null,
    attempts: null,
    expireAt: null,
    nonce: null
  },
  linkedTo: []
}
*/

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/email_addresses. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on