Thin events
Events are thin. An event says what happened and which object it happened to, and doesn’t carry a copy of the object.related_object.url to read the object as it is now. This has
three advantages:
- You always act on current state. A delayed or out-of-order delivery can’t overwrite newer data with older data.
- No personal data in transit. Deliveries contain IDs only, so nothing sensitive sits in your request logs or queues.
- No payload versions. The object comes back in the API version your code asks for.
request is set when one of your own API calls caused the event, and holds its request ID and
idempotency key.
Set up an endpoint
secret, which starts with whsec_. This is the
only time it’s returned, so store it. enabled_events takes event types,
or ["*"] for all of them. One endpoint receives events for all your employers; use the event’s
employer field to route them.
Handle a delivery
Hammock sends each event as aPOST with a JSON body and a Hammock-Signature header.
1
Verify the signature
Check the
Hammock-Signature header against the raw request body before you trust it. See
verify signatures.2
Acknowledge quickly
Return any
2xx status within 10 seconds. Put the event on a queue and do the work
afterwards, so a slow job doesn’t turn into a failed delivery.3
Skip duplicates
An event can be delivered more than once. Record the
id of each event you process and ignore
repeats.4
Fetch the object
Retrieve
related_object.url and act on what comes back.