Guides
Webhooks
Webhooks are a way to receive real-time updates from Clasp. They allow your application to be notified automatically when certain events occur in Clasp, eliminating the need to continuously poll the API for changes.
Overview
When an important change happens in your Clasp account (like a member being updated or an employer being created), Clasp generates an event and sends an HTTP POST request to your configured endpoint with details about what changed. Please reach out to Clasp to get started.
Event Payload
Each event is sent as a JSON payload with the following structure:
Field Descriptions
id
: Unique identifier for the eventevent_type
: The type of change that occurredobject_id
: Identifier of the object that changedobject_type
: Type of object that changedcreated_at
: Timestamp when the event occurred
Supported Events
Object Types | Event Types |
---|---|
- member | - created |
- dependent | - updated |
- employer | - deleted |
- payroll_benefit |
Security
Verifying Webhook Signatures
Every webhook request includes two important headers:
Clasp-Event-Timestamp
: When the event was sentClasp-Event-Signature
: HMAC signature of the event
To verify the event is legitimate via the signature:
- Concatenate the event payload with the timestamp:
${payload}.${timestamp}
- Create an HMAC SHA-256 digest with the shared secret
- Compare the calculated signature with
Clasp-Event-Signature
Here’s a Python example of signature verification:
Best Practices
1. Response
- Return a 200 status code as quickly as possible
- Store the event ID to prevent duplicate processing
- New event and object types will be added over time. Ensure a 200 response is returned for all events
- Clasp will retry failed event deliveries up to 10 times when an error response is returned
2. Fetching Current Data
- Use the
object_type
andobject_id
to determine which API endpoint to query - Fetch the current state from the API