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

# Event Testing, Observability, and Failure Recovery

> Learn more about testing and managing your events and event streams. 

<Warning>
  Events are currently available in Early Access. To use this feature, you must have an Enterprise plan. By using this feature, you agree to the applicable Free Trial terms in Okta’s [Master Subscription Agreement](https://www.okta.com/legal). To learn more about Auth0's product release cycle, read [Product Release Stages](/docs/ja-jp/troubleshoot/product-lifecycle/product-release-stages).
</Warning>

The following sections provide information about testing event streams and managing events.

## Test the event stream

After you create and enable an event stream using either AWS EventBridge or webhooks, you can test the new stream. Currently, Auth0 does not support sending events to disabled event streams.

To test your event stream, first create a user for your application by running the following with your preferred credentials:

<Tabs>
  <Tab title="Auth0 CLI">
    ```bash lines theme={null}
    auth0 users create # follow prompts to create a test user
    ```
  </Tab>

  <Tab title="cURL">
    ```bash lines theme={null}
    curl -s \
      -H "Authorization: Bearer $TOKEN" \
      -H "Content-Type: application/json" \
      -X POST https://$TENANT/api/v2/users \
      -d '{
            "email": "nick-testing-21@example.com",
            "password": "Password123!",
            "connection": "Username-Password-Authentication"
          }'
    ```
  </Tab>
</Tabs>

After the user is created, it should trigger the `user.created` event in your event stream and return a response. In this example, webhooks are used to facilitate the event stream.

```json lines expandable theme={null}
"Webhook received": {
  "id": "evt_6SfwXrtm8nVcjzzNCFFH1L",
  "source": "urn:auth0:",
  "specversion": "1.0",
  "type": "user.created",
  "time": "2025-02-02T17:56:01.573Z",
  "data": {
    "object": {
      "created_at": "2025-02-02T17:56:01.566Z",
      "email": "nick-testing-21@example.com",
      "email_verified": false,
      "identities": [
        {
          "connection": "Username-Password-Authentication",
          "isSocial": false,
          "provider": "auth0",
          "user_id": "679fb1b1e809445f129bc18d"
        }
      ],
      "name": "nick-testing-21@example.com",
      "nickname": "nick-testing-21",
      "picture": "test.png",
      "updated_at": "2025-02-02T17:56:01.566Z",
      "user_id": "auth0|679fb1b1e809445f129bc18d"
    }
  },
  "a0tenant": "acme",
  "a0stream": "est_38ANnv8pQhqsZrX2VFbftv",
  "a0purpose": "test"
}
```

You can list the event delivery failures for a specific event stream by running:

<Tabs>
  <Tab title="Auth0 CLI">
    ```bash lines theme={null}
    auth0 api get event-streams/$EVENT_STREAM_ID/deliveries
    ```
  </Tab>

  <Tab title="cURL">
    ```bash lines theme={null}
    curl -s -H "Authorization: Bearer $TOKEN" \
      "https://$TENANT/api/v2/event-streams/${EVENT_STREAM_ID}/deliveries" | jq .
    ```
  </Tab>
</Tabs>

If an empty delivery failure array is returned, your event stream is running correctly.

## Observability

To ensure the reliability of event streams, implement a monitoring process that periodically checks for delivery failures and triggers alerts when necessary.

### Polling Deliveries endpoint

Poll the Deliveries endpoint every **5 minutes** to check for failed events. Use the following API call to fetch recent event deliveries:

<Tabs>
  <Tab title="Auth0 CLI">
    ```bash lines theme={null}
    auth0 api get event-streams/$EVENT_STREAM_ID/deliveries
    ```
  </Tab>

  <Tab title="cURL">
    ```bash lines theme={null}
    curl -s -H "Authorization: Bearer $TOKEN" \
      "https://$TENANT/api/v2/event-streams/${EVENT_STREAM_ID}/deliveries" | jq .
    ```
  </Tab>
</Tabs>

If failures are detected:

* Log the failed event details.
* Alert the appropriate team or system to review and diagnose the issue.

## Recovery

Event delivery will automatically retry. To learn more, review [Best Practices](https://auth0.com/docs/customize/events/event-testing-observability-and-failure-recovery#batch-redelivery-of-failed-events).

If failures occur, use the Redelivery API to attempt event delivery again.

### Redeliver a single failed event

To retry a specific failed event, use:

<Tabs>
  <Tab title="Auth0 CLI">
    ```bash lines theme={null}
    EVENT_ID=<your event id>
    auth0 api POST event-streams/$EVENT_STREAM_ID/redeliver/$EVENT_ID --data '{}'
    ```
  </Tab>

  <Tab title="cURL">
    ```bash lines theme={null}
    curl -s -X POST -H "Authorization: Bearer $TOKEN" \
      "https://<your-domain>/api/v2/event-streams/$EVENT_STREAM_ID/redeliver/$EVENT_ID"
    ```
  </Tab>
</Tabs>

### Batch redelivery of failed events

To retry all failed events in the event stream:

<Tabs>
  <Tab title="Auth0 CLI">
    ```bash wrap lines theme={null}
    auth0 api POST event-streams/$EVENT_STREAM_ID/redeliver --data '{}'
    ```
  </Tab>

  <Tab title="cURL">
    ```bash lines theme={null}
    curl -s -X POST -H "Authorization: Bearer $TOKEN" \
      "https://<your-tenant>.auth0.com/api/v2/event-streams/<event_stream_id>/redeliver"
    ```
  </Tab>
</Tabs>

### Auto-disable mechanism

Auth0 automatically disables an event stream if excessive failures occur.

| Condition                | Action taken                            |
| ------------------------ | --------------------------------------- |
| 500 consecutive failures | Event stream is disabled automatically. |
| 5000 total failures      | Event stream is disabled automatically. |

* If an event stream is auto-disabled, you **must** use the Redelivery API to process any failed events.
* The event stream **cannot** be manually re-enabled until the total failure count drops below 5000.
* Once the number of failures is reduced, you can re-enable the stream via API.

## もっと詳しく

* [Event Types](/docs/ja-jp/customize/events/event-types)
* [Create an Event Stream](/docs/ja-jp/customize/events/create-an-event-stream)
* [Events Best Practices](/docs/ja-jp/customize/events/events-best-practices)
