Overview
Theevents sub-client provides real-time streaming of authorization events. You can consume events as an async generator via stream(), or use the convenience subscribe() wrapper for a callback-based approach. Events are delivered via Server-Sent Events (SSE).
events.stream()
Open an SSE connection and yield authorization events as an async generator. The connection remains open until you break out of the loop or the server closes it.Parameters
string[]
Filter to specific event types. If omitted, all event types are streamed.
string
ISO 8601 timestamp to replay events from. Useful for catching up after a disconnection.
Yielded: GrantexEvent
string
Unique event identifier.
string
Event type:
'grant.created', 'grant.revoked', 'token.issued', 'budget.threshold', or 'budget.exhausted'.string
ISO 8601 timestamp when the event occurred.
object
Event payload. Shape varies by event type — see Event types below.
events.subscribe()
Subscribe to events with a callback function. This is a convenience wrapper aroundstream() that handles the async iteration for you and returns an unsubscribe function to close the connection.
Parameters
(event: GrantexEvent) => void
required
Callback function invoked for each event.
object
Optional configuration with
eventTypes and since fields (same as stream()).