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

> Learn about the Event Stream Actions.

# Event Stream Triggers

Event Stream Actions are logic-based functions that execute asynchronously when specific events occur within your Auth0 tenant. These are non-blocking actions and won't impact the latency of your user's experience.

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.

<Frame>
  <img src="https://mintcdn.com/docs-dev-docs-event-stream-action-templates/6a0bOHQ-5WYDVwHQ/docs/images/customize/actions/event-stream-triggers.svg?fit=max&auto=format&n=6a0bOHQ-5WYDVwHQ&q=85&s=e8961e22115b2eff3199030b784ad253" alt="Diagram showing the TBD." width="666" height="150" data-path="docs/images/customize/actions/event-stream-triggers.svg" />
</Frame>

These Actions are non-blocking (asynchronous), suscribed to a specific set of [Event Types](/docs/customize/events/event-types).

## Triggers

### Event Stream

The `event-stream` Actions are functions executed when subscribed Event Types happen.

#### References

* [Event object](/docs/customize/actions/explore-triggers/event-stream-triggers/event-stream-event-object): Provides context for both Event Stream message and Action execution.
* [API object](/docs/customize/actions/explore-triggers/event-stream-triggers/event-stream-api-object): Provides methods to modify the flow behavior.

## Use cases

### Synchronization

A 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}
/**
* Handler to be executed while processing events in an Event Stream.
* @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;
};
```

To learn more about writing Actions, read [Write Your First Action](/docs/customize/actions/write-your-first-action).

To learn more about creating an Event Stream, read [Create an Event Stream](/docs/customize/events/create-an-event-stream#create-an-event-stream-actions).
