Reset Password from UL page - connecting to custom email provider

I implemented a custom email provider to connect my emails to SendGrid and be able to map template_id to an email so that we can manage our html/text email markup directly in SendGrid. For reset_password, the key here is URL that is generated and embedded into the email. THe issue is that URL is NOT available on the event object and thus I have no way of intercepting this event and refactoring it into a SG Api call with template_id, and URL as personalization variables passed to SG via API. It’s in the text and html fields of the event object - but I don’t want to parse those to retrieve that URL. What am I doing wrong here? Anyway else trying to do this. I should say the main driver here is that we want to manage our templates in SG, not in A0.

You’re right that the URL is embedded within the text and html fields rather than being available as a separate property, which makes it challenging to extract without parsing.

I would create my own password reset endpoint that:

  • Generate a password reset ticket using Auth0 management API
  • Construct the reset URL yourself
  • Sends the email via SendGrid with your template
// Example endpoint
app.post('/api/password-reset', async (req, res) => {
  const { email } = req.body;
  
  // Create password reset ticket via Auth0 Management API
  const ticket = await auth0.createPasswordChangeTicket({
    email,
    connection_id: 'your-connection-id'
  });
  
  // Send via SendGrid
  await sgMail.send({
    to: email,
    templateId: 'your-reset-password-template',
    dynamicTemplateData: {
      reset_url: ticket.ticket,
      // other variables
    }
  });
});

Auth0 Management API endpoint: Create a password change ticket | Auth0 Management API v2

Let me know if this helps

Thanks,
Suman Saurav

So, just so I am clear - and this was one of my thoughts - still seems like a lot of extr work all for just one non-exposed value in event.. but

in my custom email provider handler, you are saying once I’ve intercepted the event (reset password), make a call to the Auth0API and get a ticket (URL) - and use that?

Or actually host an entirely different endpoint to call that abstracts all that away from the handler?

I would build a new endpoint to generate password reset ticket and use the value inside template.

I am not sure if you using any other endpoint from Auth0 Management API. If yes, this is just adding a new endpoint to existing APIs.