Event types
There’s also
webhook.test, sent by Send Test Event. You can’t subscribe to it.
Tracked fields
An event’sdata.object holds these fields and no others. Only a change to one of them creates an updated event. A change to any other field is not announced, which stops a busy subscription announcing itself every minute.
Every data.object also has id and object.
- Customer
- Subscription
- Invoice
These are the same values the API returns, in the same formats.
data.object is a summary, not the full object. Fetch the full object with GET /v1/{customers|subscriptions|invoices}/{id}.How the events relate
createdhas noprevious_attributes.updatedcarriesprevious_attributeswith the earlier value of each field that changed.deletedcarries the object as it was just before it was deleted.invoice.paid,invoice.voidedandinvoice.deletedreplaceinvoice.updatedwhen the status changes to that value. A status change to anything else, or any other tracked change, isinvoice.updated.subscription.endedreplacessubscription.updatedwhen the status moves toendedorcomplete. If other fields change in the same minute, you’ll also get asubscription.updated.- A move between
endedandcompleteisn’t announced.
Example payloads
Customer created
Subscription updated
Units went from 10 to 15.Invoice paid
Invoice failed to sync
Aninvoice.updated event when Xero refuses an invoice.
Test event
Send Test Event sends an event about no object, so you can check your wiring.Handling events
1
Verify the signature
Reject anything that fails. See Verify signatures.
2
Skip repeats
Look up
Saasybill-Event-Id. If you have processed it, reply 200 and stop.3
Reply straight away
Return
200 before you do slow work.4
Fetch the current state
Use
data.object.id to fetch the full object from the API, and act on what it is now. This copes with events that arrive late or out of order.