Overview
Webhooks instantly inform your application about significant events, such as payroll submissions or updates, without the need for polling.Use Cases:
- Alerting when users submit or create payroll data. This use case can be handled by subscribing for event of type
user-payroll-submitted - Notifying upon successful account linkages. Not yet supported as event type.
- Triggering actions after data updates. Not yet supported as event type.
user-payroll-submitted subscription enabled, a webbook will be delivered with the respective user information enclosed.
Quick Reference:
- Webhooks List: Detailed descriptions of all events you can subscribe to.
- Setup Guide: Instructions for subscribing and managing webhooks.
Supported Event:
user-payroll-submitted- notifies when any user creates an entry with new payroll data. Includes the payroll data entry as json ifinclude_payloadis set in the configuration.- No more events are supported at the moment.
Setting Up Webhooks
Create a webhook by sending a POST request. Specify which events to monitor and where to send notifications.- events: Choose events like
user-payroll-submittedfor targeted notifications. - name: Label your webhook for easier management.
- url: Your endpoint to receive webhook payloads.
- signing_secret: (Optional) A secret for secure webhook verification.
- encryption_key: (Optional) A Base64-encoded 32-byte key used to encrypt webhook payloads.
Verifying Webhooks
If the optionalsigning_secret was provided in the webhook subscription, it can be used to validate incoming webhook
signatures, ensuring data integrity and authenticity.
When encryption is enabled, the message is first encrypted and then signed.
Therefore, the signature should be verified against the encrypted message,
not the decrypted content.
To verify if a received webhook event is authentic:
- Encode the webook payload with the
signing_secretusingHMAC-SHA512. You can then check that the result of this encoding matches the contents in theX-Teal-Signatureheader. If it matches then the webhook received is genuine. Example verification:
signing_secret was mysecret and you received the following webhook payload:
Generating Encryption Keys
If you want to use encrypted webhooks, you’ll need to provide a 32-byte encryption key encoded in Base64 when creating your webhook. Here’s how to generate a secure random key in different languages:Decrypting Webhook Payloads
When you provide anencryption_key, the webhook payload will be encrypted using AES/GCM/NoPadding. To decrypt:
- The encrypted payload is sent in the request body
- The initialization vector is provided in the
X-Teal-Encryption-IVheader (Base64 encoded)
Webhook Management
Viewing subscriptions
List your current webhooks with a simple GET request to our webhook endpointGET /webhooks.
Deleting subscriptions
Unsubscribe using the webhook ID in the requestDELETE /webhooks/{webhook_id}
Best Practices
- Secure Endpoints: Ensure your webhook URL is HTTPS-secured to safeguard transmitted data.
- Manage Secrets: Keep your
signing_secretandencryption_keyconfidential. - Use Encryption: Consider using the encryption feature when your team doesn’t control HTTPS termination and you want payloads to be decrypted only by applications possessing the encryption key. As an example, this could help prevent sensitive or GDPR-regulated information from being logged in systems not designed to handle such data (there might be more cases for your specific situation).
- Alternative to Encryption: As an alternative to encryption, consider disabling the payload in webhooks by not setting
include_payloadin your webhook configuration. - Regular Review: Periodically check your webhook subscriptions and adjust as needed to match your application’s requirements.
Webhook Example
Example of webhook request body configured to include the payload by setting"include_payload": "true" in POST /webhooks request body.
If the payroll data comes from uploading a payslip the account_id
whould be null but document_external_id and document_filename would be populated
is related to uploading a payslip.