Generate an email link
Generates email links and OTPs to be sent via a custom email provider.
- The following types can be passed into
generateLink()
:signup
,magiclink
,invite
,recovery
,email_change_current
,email_change_new
,phone_change
. generateLink()
only generates the email link foremail_change_email
if the Secure email change is enabled in your project's email auth provider settings.generateLink()
handles the creation of the user forsignup
,invite
andmagiclink
.
Parameters
params
REQUIRED
GenerateLinkParamstype
REQUIRED
signup | invite | magiclink | recovery | email_change_current | email_change_newemail
REQUIRED
stringpassword
Optional
stringOnly required if type is `signup`.
newEmail
Optional
stringOnly required if type is `email_change_current` or `email_change_new`.
options
Optional
objectdata
REQUIRED
objectCustom JSON object containing user metadata, to be stored in the `raw_user_meta_data` column. Only accepted if type is `signup`, `invite`, or `magiclink`.
redirectTo
REQUIRED
stringA redirect URL which will be appended to the generated email link.
const { data, error } = await supabase.auth.admin.generateLink({
type: 'signup',
email: '[email protected]',
password: 'secret'
})