Overview
Webhooks allow Rollfi to send real-time Payroll API events to your application. Use webhooks to keep your system updated without repeatedly polling Rollfi APIs. Common webhook events include company status changes, employee status changes, employee bank account updates, company bank account updates, and pay period updates.You can find event-specific webhook payloads in the webhook reference docs.
Delivery and Retries
Rollfi sends webhook events as HTTPPOST requests with a JSON request body.
Your endpoint should return a 2xx response within 1 minute after successfully receiving the event. Rollfi treats any 2xx response as successful, including 200 OK, 202 Accepted, and 204 No Content.
A webhook delivery is considered failed when:
- Your endpoint returns a non-
2xxresponse. - Your endpoint does not respond within 1 minute.
- Your endpoint cannot be reached.
🔹 Sandbox retry schedule
| Retry attempt | Delay |
|---|---|
| 1 | 1 minute |
| 2 | 3 minutes |
| 3 | 7 minutes |
| 4 | 15 minutes |
| 5 | 60 minutes |
🔹 Retry Idempotency
Webhook delivery is at-least-once. This means the same event may be sent more than once. Webhook retries use the same payloadeventId. Because eventId is stable across retries, use it as an idempotency key to prevent duplicate processing.
Recommended behavior:
- Check whether the
eventIdhas already been processed. - If it has already been processed, return a
2xxresponse without processing it again. - If it has not been processed, process the event and store the
eventId.
eventTimeStamp, discard the older webhook and return a 2xx response. This prevents older retry deliveries from overwriting newer state and causing status regression.
—
Signed and Unsigned Webhooks
🔹 Unsigned Webhooks
Unsigned webhooks are sent as JSON over HTTPS and do not include signature headers.🔹 Signed Webhooks
Signed webhooks are sent as JSON over HTTPS with additional verification headers:| Header | Description |
|---|---|
X-Rollfi-Timestamp | Unix timestamp used for signature verification |
X-Rollfi-Signature | Signature metadata used to verify the request |
X-Rollfi-Signature uses this format:
kidis the signing key identifier.algis the signing algorithm.v1is the signature value.
Signature Verification
For signed webhooks, verify the request before processing the event. Rollfi signs this value:timestampis the value fromX-Rollfi-Timestamp.body_hashis the SHA-256 hash of the raw request body, encoded as base64url with no padding.
- Read the raw request body exactly as received.
- Read the
X-Rollfi-TimestampandX-Rollfi-Signatureheaders. - Reject the request if
X-Rollfi-Timestampis more than 300 seconds before or after your current server time. - Parse
kid,alg, andv1fromX-Rollfi-Signature. - Reject the request if
algis notRS256. - Retrieve the public key matching the
kid. - Hash the raw request body using SHA-256 and encode it as base64url with no padding.
- Build the signing input as
<timestamp>.<body_hash>. - Verify
v1using RS256 and the matching public key. - Process the event only after verification succeeds.
Public Keys
Public keys can be retrieved fromwebhook/getWebhookPublicKey.
The response returns up to two keys:
- The active key
- A retiring key, if one is still within its verification window
kid from X-Rollfi-Signature to select the correct public key.
Cache public keys by kid so you do not need to retrieve keys for every webhook. When caching a public key, store the key metadata, including verifyUntil.
Re-fetch public keys when:
- You receive a webhook signed with a
kidyou have not seen before. - Verification fails for a known
kid. - A cached key is past its
verifyUntiltime.
verifyUntil indicates the latest time a public key should be used to verify webhook signatures. Once a key is retired, it should no longer be used for verification.
Webhook retries are signed using the current active key at the time of retry. This means a retry may be signed with a different kid than the original delivery if key rotation has occurred.
⚠️ Important: Always use the kid from the webhook request to select the correct public key before verifying the signature.
Timestamp Fields
There are two timestamp values commonly used in webhook delivery:| Field | Location | Purpose |
|---|---|---|
X-Rollfi-Timestamp | Header | Unix timestamp used for signature verification |
eventTimeStamp | Payload | Original event timestamp in UTC |
X-Rollfi-Timestamp is a Unix timestamp.
eventTimeStamp is included in the webhook payload and represents when the original event occurred in Rollfi. This value is in UTC.
Recommended Handler Behavior
Your webhook handler should:- Verify the signature before processing signed webhooks.
- Reject signed webhook requests with stale timestamps.
- Return a
2xxresponse within 1 minute after accepting the event. - Store and check
eventIdto prevent duplicate processing. - Use
eventTimeStampto prevent older events from overwriting newer state. - Avoid depending on event ordering.
2xx response, and process the event asynchronously.
