Events
Events notify you when important actions happen inside an organization.
For example, Polytomic emits a sync.completed event every time a sync
finishes.
You can consume events in two ways:
- Poll the events endpoint.
- Register a webhook to receive events in real time.
⚠️ At-most-once delivery
Polytomic delivers each event at most once and does not re-send events after delivery. If you need guaranteed processing of every change, build a fallback that polls the events endpoint in addition to consuming the webhook.
Retention
Polytomic retains events for 48 hours. After that they are no longer available from the events endpoint.
Event types
The event types are as follows:
sync.runningsync.failedsync.canceledsync.completedsync.completed_with_errorsbulk_sync.runningbulk_sync.completedbulk_sync.canceledbulk_sync.failedbulk_sync.completed_with_error
Webhooks
Create and manage webhooks through the webhook API endpoints. A webhook fires events for the organization it belongs to. Each organization can have one webhook.
HMAC validation
Use HMAC validation to confirm that a delivered event came from
Polytomic. When you create or update a webhook, you supply a secret.
Polytomic signs each delivery with that secret and passes the signature in
the Polytomic-Signature header. Compute the same HMAC on the request body
and compare.
Delivery
Your endpoint must return a 2xx status code. If it does not, Polytomic
retries the delivery up to five times with exponential backoff. Event ordering
is not guaranteed.
Record logs
The sync.completed event payload (see the example below) includes
links to JSON logs of the records Polytomic inserted or updated. See the
total_records, inserted_records, and updated_records fields.
Event payload examples
Consuming events
The following Go example receives a webhook delivery and verifies the HMAC signature:
