Call an external API when user verifies email id

My usecase:

  1. [my app] Creates a user on Auth0 by calling the management APIs
  2. [auth0] Automatically sends a email asking the user to verify his email id
  3. [user] Verifies email successfully
    At the end of Step 3, I want auth0 to callback an API endpoint in [my app] notifying us of the ‘emailVerified’ status.

Could you please advice how would I go about solving this? I tried plugging in the code below under Rules and hooks. They run when invoked manually (in the editor) but not automatically when the user verifies email.

if (user.emailVerified) {
	const request = require('request');
	request.post('http://my-app/endpoint', {
		json: user
	}, (error, res, body) => {
		if (error) {
			console.error(error);
			return;
		}
		console.log(statusCode: $ {
			res.statusCode
		});
		console.log(body);
	});
} else {
	console.log('Unverified user');
	console.log(user);
}

Hi @keerthi,

Currently, there is no hook or rule dedicated to running on a successful email verification, so implementing this will be a bit of a workaround.

You can use log streams, which are http events that are triggered for each log, but you will need to sift through for email verification events aka "type": "sv".

Hope this helps,
Dan

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.