In a nutshell: Webhooks allow you to set up a notification system that can be used to receive updates on certain requests made to the Adhere API.
Why use Webhooks?
Generally, when you make a request to an API endpoint, you expect to get a near-immediate response. However, some requests may take a long time to process. In order to prevent a timeout error, a pending response is returned. Since your records need to be updated with the final state of the request, you need to either:- Polling: Make a request for an update at regular intervals.
- Webhooks: Listen to events by using a webhook URL.
Setup & Integration
To start receiving webhook notifications, follow these steps to configure your environment:Configure Webhook URL
Provide the endpoint on your server where Adhere will send
POST requests. This should be a publicly accessible URL.Set Hash Key
A secret key used to sign the webhook payload. You must keep this secure and use it to verify that requests are coming from Adhere.
Security & Verification
All webhook requests from Adhere include aX-Hub-Signature header. This header contains the HMAC SHA256 signature of the request body, signed with your Hash Key.
Verifying Signatures
To ensure that a webhook request is genuinely from Adhere, you should verify the signature before processing the payload.Event Payload Structure
All webhooks follow a consistent JSON structure:| Parameter | Type | Description |
|---|---|---|
success | boolean | Indicates if the event was processed successfully. |
module | string | The Adhere module that triggered the event (e.g., transaction_monitoring, kyc). |
event | string | The specific event type. |
data | object | The actual payload data (e.g., transaction details, KYC results). |
Supported Events
Transaction Monitoring
- Module:
transaction_monitoring - Events:
-
suspicious_transaction: Triggered when a transaction is processed and deemed suspicious.
-
Testing Locally
Before deploying to production, we recommend testing your webhook implementation locally.- Use ngrok: Use ngrok to create a secure tunnel to your local server.
- Set Webhook URL: Update your Adhere dashboard with the ngrok URL (e.g.,
https://your-subdomain.ngrok-free.app/webhooks). - Inspect Requests: Use the ngrok dashboard or Webhook.site to inspect the payloads and headers sent by Adhere.
Best Practices
- Acknowledge Immediately: Your server should return a
200 OKresponse as quickly as possible. Heavy processing should be handled asynchronously using a task queue. - Handle Retries: Adhere will retry failed webhook deliveries (non-2xx responses) up to 3 times with an exponential backoff.
- Use Idempotency: Ensure your system can handle the same webhook multiple times safely. Use the event’s unique ID to track processed events.
If your server does not return a 2xx response, Adhere will consider the delivery as failed and will attempt to retry.