Webhooks
Receive event notifications
Receive Event Notifications With Webhooks
Appruve uses webhooks to notify your application when an event happens in your account. Webhooks are particularly useful for asynchronous events like when a verification is completed or cancelled by a customer.
Begin using webhooks with your Appruve integration in just two steps:
Build a webhook endpoint
The first step to adding webhooks to your Appruve integration is to build your own custom endpoint. This endpoint would be a standard POST endpoint that accepts external requests. Appruve signs the webhook events it sends to your endpoints by including a signature in each eventโs Appruve-Signature header. This allows you to verify that the events were sent by Appruve, not by a third party.
Check the webhook signatures
Before you can verify signatures, you need to retrieve your endpointโs secret from your Dashboardโs Webhooks settings. Select an endpoint that you want to obtain the secret for, then click the Click to reveal button
to obtain the secret.
The Appruve-Signature header included in each signed event contains a timestamp and a signature. The timestamp is prefixed by t=, and the signature is prefixed s=.
Appruve generates signatures using a hash-based message authentication code (HMAC) with SHA-256. Follow the steps below to verify the signature.
STEP 1: EXTRACT THE TIMESTAMP AND SIGNATURE FROM THE HEADER
Split the header, using the , character as the separator, to get a list of elements. Then split each element, using the = character as the separator, to get a prefix and value pair. The value for the prefix t corresponds to the timestamp, and s corresponds to the signature.
STEP 2: PREPARE THE SIGNED_PAYLOAD STRING
The signed_payload string is created by concatenating:
The timestamp (as a string)
The character
.
The actual JSON payload (i.e., the request body)
STEP 3: DETERMINE THE EXPECTED SIGNATURE
Compute an HMAC with the SHA256 hash function. Use the endpointโs signing secret as the key, and use the signed_payload string as the message.
STEP 4: COMPARE THE SIGNATURES
Compare the signature in the header to the expected signature. For an equality match, compute the difference between the current timestamp and the received timestamp, then decide if the difference is within your tolerance. To protect against timing attacks, use a constant-time string comparison to compare the expected signature to each of the received signatures.
Checkout an example implementation in Ruby below.
Last updated