Pull events from Auth0 on your own schedule using the Server-Sent Events (SSE) based Events API.
The Events API provides a pull-based alternative to Event Streams. Instead of Auth0 pushing events to a destination, your application opens a long-lived connection to GET /api/v2/events and receives events as a Server-Sent Events (SSE) stream. You control when to connect, how to resume after a disconnection, and how fast to consume events.This approach is useful when you need to:
Process events at your own pace without standing up a webhook endpoint.
Replay events from a specific point in time for backfill or recovery.
Integrate with systems that prefer polling over push-based delivery.
When your application connects to the Events API, it receives a stream of SSE messages. Each message includes an id field that acts as an offset. If the connection drops, your application reconnects and provides the last offset it received. Auth0 resumes delivery from that point, so no events are lost.The SSE stream includes the following message types:
Message type
Purpose
:connected
Confirms the connection is established. This is an SSE comment, not a data event.
retry: <ms>
Tells the SSE client how long to wait before reconnecting after a disconnect.
event: <type> (for example, user.created)
A real event with full payload in the data field.
event: offset-only
A progress marker sent at regular intervals (on heartbeat frequency). Updates the offset without delivering event data.
: followed by text (for example, : heartbeat)
A keep-alive comment that prevents proxies and load balancers from closing idle connections. No action required.
event: error
A terminal error. The stream closes after this message.
Use query parameters to filter or resume the stream:
Parameter
Type
Description
from
string
An offset returned in a previous id field. Delivery resumes after this offset.
from_timestamp
string
An ISO 8601 timestamp. Returns events that occurred at or after this time. Mutually exclusive with from. Best used for initial setup or replaying events from a known point in time; for ongoing consumption, prefer resuming with from because offsets are more precise.
event_type
string
The event type to include. Repeat the parameter for each type (for example, event_type=user.created&event_type=user.updated).
SSE connections can drop for many reasons: network issues, token expiration, or server-side connection cycling (Auth0 periodically closes connections for load balancing — typically every few minutes). Standard SSE client libraries handle this transparently by reconnecting and sending the last offset.There are two ways to supply the offset on reconnection:
Last-Event-ID header — the standard SSE reconnection mechanism. Most SSE client libraries set this header automatically when reconnecting.
from query parameter — use this when your client does not support the Last-Event-ID header.
If both are provided, the Last-Event-ID header takes precedence.
Persist the latest id value from every message (including offset-only messages) to durable storage. If your application restarts, use the persisted offset to resume delivery from where you left off.
Messages where the event field matches a known event type (for example, user.created) contain the full event payload in the data field. Parse the JSON and process the event according to your business logic.
Auth0 sends offset-only messages at regular intervals (on the heartbeat frequency) to advance your position in the stream. These messages do not contain an event payload. Update your stored offset when you receive them so that a future reconnection does not replay events you have already passed.
An event: error message signals a terminal issue such as an expired offset or a server-side problem. After receiving this message, the stream closes. Your application should log the error, then reconnect with the appropriate offset or a fresh from_timestamp.
Lines that begin with : are SSE comments used as heartbeats. They keep the connection alive through proxies and load balancers. No processing is required.
Auth0 periodically closes SSE connections for load-balancing purposes (typically every few minutes). This is expected behavior, not an error. Standard SSE client libraries (including the eventsource npm package) reconnect automatically using the Last-Event-ID header, so your application resumes from the correct offset without losing events.If you build a custom SSE client, make sure it handles connection drops gracefully by persisting the latest offset and reconnecting with it.
The eventsource npm package implements the SSE protocol and handles reconnection automatically using the Last-Event-ID header. If you use a different SSE library, verify that it supports automatic reconnection and offset forwarding.