# Events & reconciliation

Recover missed notifications without confusing event snapshots with current payment state.

## Read your environment’s event history

Use a key with events:read. GET /events supports type, payment_id and inclusive creation-time bounds with pagination. GET /events/{id} returns a single normalized event. Event IDs belong to one project environment.

- [List events](https://veyqo.org/docs/api-events-list): GET /events

- [Retrieve an event](https://veyqo.org/docs/api-events-show): GET /events/{id}

## Snapshots and current truth

An event records what was true when it fired. A later refund does not rewrite the original payment.succeeded event. Fetch the payment/refund for its current state when reconciling a missed or out-of-order event.

The events API returns {success:true,data:event}; an outgoing webhook sends event directly. The JSON content is the same, but database serialization may change key order, so an events API response cannot replace the raw signed delivery body.

## A reconciliation worker

1. Persist the IDs of locally unresolved orders and their Veyqo payment/session IDs.
2. Poll unresolved payment records using a payments:read key and fresh verification requests where needed.
3. Page through event history for the outage window, with overlap to tolerate processing delay; deduplicate by event ID.
4. Compare verified status, amount, currency and trusted order/session association.
5. Atomically update the order and enqueue fulfilment once. Record unresolved discrepancies for investigation.
