Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs-dev.auth0-mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

The post-user-registration trigger runs after a user is added to a Database or connection. Use this trigger to notify another system that a user has registered for your application. Multiple Actions can be bound to this trigger, and the Actions will run in order.
Diagram of the Actions Post User Registration Flow.
Actions in this flow are non-blocking (asynchronous): the Auth0 pipeline continues to run without waiting for the Action to finish, so the Action’s outcome does not affect the Auth0 transaction.

References

  • Event object: Provides contextual information about the newly-created user.
  • API object: Provides methods for changing the behavior of the flow.

Common use cases

Notify Slack when a new user registers

A post-user-registration Action can be used to notify a Slack channel about each new registration:
/**
 * @param {Event} event - Details about the context and user that has registered.
 * @param {PostUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of post user registration.
 */
exports.onExecutePostUserRegistration = async (event, api) => {
  const { IncomingWebhook } = require("@slack/webhook");
  const webhook = new IncomingWebhook(event.secrets.SLACK_WEBHOOK_URL);

  const text = `New User: ${event.user.email}`;
  const channel = '#some_channel';

  webhook.send({ text, channel });
};
For this Action to execute properly, the Action must contain a secret named SLACK_WEBHOOK_URL and must have a dependency on the @slack/webhook npm package.

Store the Auth0 user ID in a remote system

A post-user-registration Action can be used to store the Auth0 user ID in a remote system:
const axios = require("axios");

/**
 * @param {Event} event - Details about the context and user that has registered.
 * @param {PostUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of post user registration.
 */
exports.onExecutePostUserRegistration = async (event, api) => {
  await axios.post("https://my-api.exampleco.com/users", { params: { email: event.user.email }});
};
To use an npm library like axios, you must add the library to the Action as a dependency. To learn more, read the “Add a dependency” section in Write Your First Action.