Prompt
accounting API with webhooks and backfill
Latest observation
Nov 4, 2026
OpenAI APIWeb search: off
Are you looking for help designing, implementing, or evaluating an accounting API that supports webhooks and backfill?
If so, here’s a solid baseline architecture:
Core ideas
1) Webhooks
Use webhooks for near-real-time event delivery:
invoice.createdinvoice.updatedpayment.createdjournal_entry.postedcustomer.updated
Best practices:
- Sign webhook payloads with HMAC
- Include an
event_idandoccurred_at - Deliver events at least once
- Support retries with exponential backoff
- Make webhook receivers idempotent
2) Backfill
Backfill is for recovering missed events or historical data.
Provide one or both of these:
- Event backfill API
GET /events?since=...GET /events?cursor=...
- Resource backfill API
GET /invoices?updated_since=...GET /transactions?created_since=...
Best practices:
- Use cursor pagination, not offset
- Keep events immutable
- Allow replay from a checkpoint
- Store high-water marks per tenant/client
Recommended flow
- Client subscribes to webhook events
- API delivers events in real time
- Client stores last processed
event_idor cursor - If webhook delivery fails or data is suspected missing:
- query backfill endpoint from last checkpoint
- Client deduplicates by
event_id
Data model suggestions
Event table
event_idtenant_idevent_typeresource_typeresource_idpayloadoccurred_atsequence_number
Delivery table
delivery_idevent_idendpoint_idstatusattempt_countlast_attempt_at
Important accounting-specific concerns
- Immutable audit trail
- Strong ordering for ledger events
- Period close rules
- Late-arriving adjustments
- Reconciliation support
Example webhook payload
{
"event_id": "evt_123",
"type": "invoice.created",
"occurred_at": "2026-11-04T12:00:00Z",
"tenant_id": "acct_456",
"data": {
"invoice_id": "inv_789",
"amount": 12500,
"currency": "USD"
}
}
Example backfill endpoint
GET /v1/events?since=evt_100&limit=100
Response:
{
"data": [
{
"event_id": "evt_101",
"type": "invoice.created"
}
],
"next_cursor": "evt_101"
}
If you want, I can also help with one of these specifically:
- OpenAPI spec
- database schema
- webhook retry design
- backfill/replay algorithm
- end-to-end architecture diagram