# Events

Subscribe to domain changes and read authoritative resource state.

Documented SDK: @minmoto/sdk 0.3.0

Domain clients expose subscriptions alongside their commands and queries.
For example, subscribe to Minmo Pay changes:

```ts
import { MinmoClient } from "@minmoto/sdk";

const minmo = new MinmoClient({
  partnerId: process.env.MINMO_PARTNER_ID!,
  apiKey: process.env.MINMO_API_KEY!,
});

const subscription = minmo.integrations.pay.events({
  onEvent(event) {
    console.log(event.type, event.id);
  },
  onError(error) {
    console.error("Minmo Pay event stream failed", error.message);
  },
});

await subscription.ready;

// Close during application shutdown, after finishing your workflow.
await subscription.close();
```

Treat an event as a signal that something changed. Re-read the relevant SDK
resource when current state matters. Design handlers to tolerate duplicate
events and reconnects, and handle an authoritative resync when required.

This is an SDK event stream, not a generic webhook setup procedure.
