Events
Events are a way of being notified of important actions happening within an organization. For example, Polytomic will create a sync.completed
event any time a sync finishes. These events are accessible via the Events API. We also offer the ability to set up outgoing webhooks which will send realtime events as they happen.
Polytomic is designed for at most once delivery, which means we may fail to send some events. Additionally, events cannot be re-sent once they have been delivered. Therefore, if your use case demands a high level of assurance that all changes to a resource are processed without any missing events, we advise building a fallback polling system that periodically fetches the desired events using the events endpoint.
Events accessible via the Events endpoint are persisted for 48 hours, after which they will not be available.
Event Types
The event types are as follows:
sync.running
sync.failed
sync.canceled
sync.completed
sync.completed_with_errors
bulk_sync.running
bulk_sync.completed
bulk_sync.canceled
bulk_sync.failed
bulk_sync.completed_with_error
Webhooks
Webooks can be set up using the webhook API endpoints. Each webhook will fire events for the organization in which it exists. Currently, only one webhook per organization is allowed.
HMAC Validation
HMAC validation can be used to ensure the events you receive are legitimate. When creating or updating a webook, there’s a required secret
field. Polytomic will hash each message and include a Polytomic-Signature
header in each POST using that secret. You can use the secret
field to validate that the signature matches.
Delivery
We require that the endpoint returns a 2xx
response code. If a 2xx
is not returned, the event will be retried 5 times with exponential backoff. There are no guarantees around ordering.
Record logs
Note that the sync.complete
event payload (example illustrated at the bottom of this page) also contains logs (split into JSON files) of records that were inserted or updated by Polytomic. See keys total_records
, inserted_records
, and updated_records
in the event payload.
Event payload examples
Consuming Events
Below is a brief example (written in Go) of consuming events from a webhook: