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

> Event Stream Actions について学びます。

# Event Stream トリガー

Event Stream Actions は、Auth0 テナント内で特定のイベントが発生したときに非同期で実行される関数です。これらは非ブロッキングの Action であり、ユーザー エクスペリエンスのレイテンシーに影響しません。

各 Event Stream Action は Event Stream に関連付けられており、あらかじめ定義された一連のイベントタイプ (たとえば、ログイン成功、パスワード変更、ユーザー削除) を監視します。サブスクライブしているイベントが発生すると、Action がトリガーされます。Login Action や Pre-Registration Action とは異なり、Event Stream Actions はバックグラウンドで実行され、ユーザーのメインのトランザクションには影響しません。

<Frame>
  <img src="https://mintcdn.com/translations/xwVvTWJUElMm5YAK/docs/images/customize/actions/event-stream-triggers.svg?fit=max&auto=format&n=xwVvTWJUElMm5YAK&q=85&s=83ad07ff0459e962f49e6a9ef62dd886" alt="TBD を示す図。" width="666" height="150" data-path="docs/images/customize/actions/event-stream-triggers.svg" />
</Frame>

これらの Actions は非ブロッキング (非同期) であり、特定の一連の [イベントタイプ](/ja/docs/customize/events/event-types) をサブスクライブします。

<div id="triggers">
  ## トリガー
</div>

<div id="event-stream">
  ### Event Stream
</div>

`event-stream` Actions は、サブスクライブしているイベントタイプが発生したときに実行される関数です。

<div id="references">
  #### リファレンス
</div>

* [Event object](/ja/docs/customize/actions/explore-triggers/event-stream-triggers/event-stream-event-object): Event Stream メッセージと Action の実行の両方に関する情報を提供します。
* [API object](/ja/docs/customize/actions/explore-triggers/event-stream-triggers/event-stream-api-object): フローの動作を変更するためのメソッドを提供します。

<div id="use-cases">
  ## ユースケース
</div>

<div id="synchronization">
  ### 同期
</div>

イベントストリーム Action は、カスタムロジックに基づいて特定のイベントを外部サービスに通知するために使用できます。次の Action は、保存された API キーを使用してイベントメッセージを外部サービスへ安全に転送する方法を示しています。

```javascript lines theme={null}
/**
* イベントストリームでイベントを処理する際に実行されるハンドラー。
* @param {Event} event - 受信イベントの詳細。
* @param {EventStreamAPI} api - イベントストリーム処理を定義するメソッドとユーティリティ。
*/
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;
};
```

Actions の作成方法について詳しくは、[Write Your First Action](/ja/docs/customize/actions/write-your-first-action)を参照してください。

Event Stream の作成方法について詳しくは、[Create an Event Stream](/ja/docs/customize/events/create-an-event-stream#create-an-event-stream-actions)を参照してください。
