> ## Documentation Index
> Fetch the complete documentation index at: https://docs-dev-actions-triggers-reorg.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Event Stream

> Learn about Event Stream Actions, which run asynchronously when subscribed event types occur within your Auth0 tenant. They can be used to forward events to external systems without affecting the user's transaction.

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](/docs/customize/events/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.

<Frame>
  <img src="https://mintcdn.com/docs-dev-actions-triggers-reorg/OqKre0iGE0obreKI/docs/images/customize/actions/event-stream-triggers.svg?fit=max&auto=format&n=OqKre0iGE0obreKI&q=85&s=93a962fe40af412339f41f1ba1e40bec" alt="Diagram showing how Event Stream Actions subscribe to and process tenant events." width="666" height="150" data-path="docs/images/customize/actions/event-stream-triggers.svg" />
</Frame>

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](/docs/customize/actions/reference/event-stream/event-stream-event-object): Provides context for both the Event Stream message and the Action execution.
* [API object](/docs/customize/actions/reference/event-stream/event-stream-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:

```javascript lines theme={null}
/**
 * @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

* [Write Your First Action](/docs/customize/actions/write-your-first-action)
* [Create an Event Stream](/docs/customize/events/create-an-event-stream#create-an-event-stream-actions)
