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 event-stream trigger runs when specific events occur within your Auth0 tenant. Each Event Stream Action is associated with an Event Stream and listens for a pre-defined set of Event Types (for example, successful logins, password changes, or user deletions). When a subscribed event occurs, the Action is triggered. Unlike Login or Pre-Registration Actions, Event Stream Actions run in the background and do not affect the primary transaction of the user.
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 and won’t impact the latency of your user’s experience.
References
- Event object: Provides context for both the Event Stream message and the Action execution.
- API object: Provides methods for changing the behavior of the flow.
Common use cases
Synchronize events to an external service
An event-stream Action can be used to communicate a particular event to an external service based on custom logic. The following Action demonstrates how to securely forward an event message to an external service using a stored API key:
/**
* @param {Event} event - Details about the incoming event.
* @param {EventStreamAPI} api - Methods and utilities to define event stream processing.
*/
exports.onExecuteEventStream = async (event, api) => {
const message = event.message;
try {
await fetch(event.secrets.URL, {
method: 'POST',
headers: {
'X-API-Key': event.secrets.API_KEY,
},
body: JSON.stringify(message),
});
} catch (err) {
throw new Error('External service failure');
}
return;
};
Learn more