Learn how you can create event streams using AWS EventBridge or webhooks.
By subscribing to events, and delivering them to a destination of your choice using event streams, you can facilitate a number of related use cases, including:
Sending emails to new customers to welcome them or ask them to verify their email address.
Monitoring user lifecycle changes so that you can update CRM (customer relationship management) or billing systems.
You can create an event stream using either AWS EventBridge or webhooks. The sections below outline the setup process for both options.
By enabling event streams, you become the Controller of data exported from the Auth0 Platform and are responsible for what information is streamed, how it is secured, and how it is used. If you configure a destination endpoint that resides in a different geographic region than your Auth0 environment, this setup initiates a cross-region data transfer. You are solely responsible for managing your destination configurations and ensuring that any resulting cross-border data transfers comply with your internal policies and applicable data protection laws.
Event streams can either be provisioned using the or the Auth0 Management API. If using the , before you can set up an event stream, you need to create a machine-to-machine (M2M) application and authenticate with a Management API token. For more information, review Management API Access Tokens.
Event streams allow you to capture real-time changes within your Auth0 tenant and send them to an external system for processing.Before setting up an event stream, you need to identify the event types you want to monitor. Then, you will use your AWS account ID and region to set up your event stream, as demonstrated below.This example uses the Auth0 CLI to create an event stream that subscribes to the user.created event, which triggers whenever a new user is registered in your tenant.
To create an event stream in the Auth0 Dashboard using AWS EventBridge:
Navigate to Auth0 Dashboard > Event Streams (Early).
Select +Create Event Stream.
From the list of stream types, select AWS EventBridge. This will open the configuration form for your new EventBridge stream.
Configure Stream Details: In the configuration form, you will need to provide the following information:
Stream Name:Enter a descriptive name for your event stream. This will help you identify it within the Auth0 Dashboard.
AWS Account ID:Enter the 12-digit AWS account ID where you want the Auth0 events to be sent.
AWS Region:Select the specific AWS Region where your EventBridge event bus is located.
Select Event Types: In the Select Event Types section, choose the specific Auth0 event types you want to include in this stream. You can select multiple event types based on your requirements (e.g., user.created, user.updated, user.deleted).
Save Changes: Once you have configured the stream name, AWS details, and selected your desired event types, click the Save Changes button.
Your new event stream is now created, and Auth0 can begin publishing the selected event types to the specified AWS EventBridge event bus. You can monitor the status and manage your event stream from the Event Streams (Early) page in the Auth0 Dashboard.
Before getting started with Terraform, you need to:
Install the Terraform CLI
Install the Auth0 CLI and authenticate with auth0 login
Have your AWS Account ID and AWS region for configuring an EventBridge stream
To provision your event stream using Terraform, you need a structured project directory. See below for an example configuration when setting this up for the first time:
auth0-event-streams/├── main.tf # Core configuration: defines providers and the 'auth0_event_stream' resource.├── variables.tf # Variable declaration: defines inputs like 'aws_account_id' and 'aws_region'.└── terraform.tfvars # Variable values: holds the actual configuration values (e.g., "123456789012").
In your variables.tf file, declare the necessary input variables your stream configuration needs:
variable "aws_account_id" { description = "The 12-digit AWS Account ID where the EventBridge event bus resides." type = string}variable "aws_region" { description = "The AWS region (e.g., us-east-1) for the EventBridge event bus." type = string}
This example uses the auth0_event_stream resource to create an event stream that subscribes to the user.created event, which triggers whenever a new user is registered in your tenant. Use the following sample in your main.tf file:
If successful, this call returns the following JSON with your event stream id. New event streams are enabled by default.After you have created and saved all three of the files above, you are ready to create your stream.
As an alternative to AWS EventBridge, you can use webhooks to facilitate event streams.To get started, first set up a webhook handler to receive real-time notifications when a specific event occurs. Then, you can create your event stream.You can either create a basic webhook handler by following the instructions below, or you can use an existing service such as:
Vercel
Inngest
If you decide to use an existing service, you can proceed to Create an event stream (webhook). Otherwise, follow the instructions below to create your own basic webhook handler.
Event streams allow you to capture real-time changes within your Auth0 tenant and send them to an external system for processing.Before setting up an event stream, you need to identify the event types you want to monitor. You will then use your webhook handler to create an event stream, as demonstrated below.
Management API
Dashboard
Terraform
This example uses the Auth0 CLI to create an event stream that subscribes to the user.created event, which triggers whenever a new user is registered in your tenant. The event data is then forwarded to a webhook endpoint for further processing.
source .env # Make sure you are in the webhook directory where you created your .env fileWEBHOOK_URL="<ngrok URL>/webhook"auth0 events create -n my-event1 -t webhook -s "user.created" -c '{"webhook_endpoint":"'"${WEBHOOK_URL}"'","webhook_authorization":{"method":"bearer","token":'"${API_TOKEN}"'"}}'
If successful, this returns the following JSON with your event stream id. New event streams are enabled by default.
After you create an event stream, you can verify that the event stream exists using the following command:
auth0 events show <EVENT_STREAM_ID>
To create an event stream in the Auth0 Dashboard using AWS EventBridge:
Navigate to Auth0 Dashboard > Event Streams (Early).
Select +Create Event Stream.
From the list of stream types, select Webhook. This will open the configuration form for your new webhook stream.
Configure Stream Details: In the configuration form, you will need to provide the following information:
Stream Name:Enter a descriptive name for your event stream. This will help you identify it within the Auth0 Dashboard.
Endpoint: Enter the complete URL of the HTTP endpoint where you want Auth0 to send the events. This is the service that will receive and process the event data.
Authentication Method: Choose the authentication method required by your endpoint.
Authorization Token: If you selected Bearer Token as the authentication method, enter the required authorization token here.
Select Event Types: In the Select Event Types section, choose the specific Auth0 event types you want to include in this stream. You can select multiple event types based on your requirements (e.g., user.created, user.updated, user.deleted).
Save Changes: Once you have configured the stream name, AWS details, and selected your desired event types, click the Save Changes button.
Your new event stream is now created, and Auth0 can begin publishing the selected event types to the specified Webhook. You can monitor the status and manage your event stream from the Event Streams (Early) page in the Auth0 Dashboard.
To provision your event stream using Terraform, you’ll need a structured project directory. See below for an example configuration when setting this up for the first time:
auth0-event-streams/├── main.tf # Core configuration: defines providers and the 'auth0_event_stream' resource.├── variables.tf # Variable declaration: defines inputs like 'aws_account_id' and 'aws_region'.└── terraform.tfvars # Variable values: holds the actual configuration values (e.g., "123456789012").
In your variables.tf file, declare the necessary input variables your stream configuration will need:
variable "api_token" { description = "The secret token used for Webhook Bearer Authorization." type = string sensitive = true}variable "webhook_endpoint_url" { description = "The public HTTPS URL for the webhook handler (e.g., your ngrok URL)." type = string}
This example uses the auth0_event_stream resource to create an event stream that subscribes to the user.created event, which triggers whenever a new user is registered in your tenant. Use the following sample in your main.tf file:If successful, this call returns the following JSON with your event stream id. New event streams are enabled by default.
Event streams allow you to capture real-time changes within your Auth0 tenant and send them to an external system for processing.Before setting up an event stream, you need to identify the event types you want to monitor. This example uses the Auth0 CLI to create an event stream that subscribes to the user.created event, which triggers whenever your tenant registers a new user.
To create an event stream in the Auth0 Dashboard using Auth0 Actions:
Navigate to Auth0 Dashboard > Event Streams (Early).
Select +Create Event Stream. .
From the list of stream types, select +Auth0 Actions. This opens the configuration form for your new Auth0 Actions stream.
Configure Stream Details: In the configuration form, you need to provide the following information:
Stream Name:Enter a descriptive name for your event stream. This will help you identify it within the Auth0 Dashboard.
Select Event Types: In the Select Event Types section, choose the specific Auth0 event types you want to include in this stream. You can select multiple event types based on your requirements (e.g., Created, Updated, Deleted).
In the Action Editor, write your handler code. The system requires the onExecuteEventStream function. You can use the api object to manage success or failure states.
/** * Handler that will be called during the execution of an Event Stream. * @param {Event} event - Details about the Cloud Event. * @param {EventStreamAPI} api - Interface whose methods can be used to handle the event. */exports.onExecuteEventStream = async (event, api) => { const eventType = event.message.type; const eventData = event.message.data; console.log(`Received event: ${eventType}`); // Custom Logic: e.g., Send data to an external API // await axios.post('https://my-crm.com/ingest', eventData); // FAILURE HANDLING: // To trigger a retry, either throw an error or use api.message.fail() if (!eventData) { // api.message.fail('No data received'); throw new Error('No data received'); } // SUCCESS: // If the function ends without error, the event is marked delivered.};
Save Changes: Once you have configured the stream name and Action handler, the system automatically creates the Action, bind it to a stream, and enables it.
Your new event stream is now created, and Auth0 can begin publishing the selected event types to the specified Auth0 Action. You can monitor the status and manage your event stream from the Event Streams (Early) page in the Auth0 Dashboard.