Purpose
Webhooks allow you to receive real-time updates about events related to your loan applications. This can help you keep your system in sync with Covered’s platform and provide a better experience for your users. Webhooks events are sparse and for security reasons do not contain any PII or sensitive data. This means you will need to make a separate request to the API to get the full details of the event. For example, if you receive apolicy.bound event, you will need to make a request to the
GET /v1/policies/{id} endpoint to get the details of the policy.
Registration
Reach out to Covered support to register for webhooks. You will need to provide a URL to receive the webhook events and optionally provide basic auth credentials to accompany the request to your endpoint.Handling
When you receive a webhook event, you should respond with a HTTP status code in the range of 200-299(inclusive) to acknowledge receipt of the event. Any other status code will be treated as a failure and Covered will retry the request 6 times a day for the next 14 days.Authentication & Handling
Headers
Optional. The username and password registered with Covered support for your webhook
endpoint, presented as Basic Authorization header. You can use this to verify the
request is coming from Covered.
Optional. A signature of the request body using HMAC SHA-256 with a client secret provided
by Covered support. This can be used to verify the integrity of the request and ensure
it has not been tampered with in transit.
The signature is calculated as follows:
The ID from Covered of the partner that shopped the loan
Optional. The ID provided as
externalId when the loan application was createdHMAC Verification
Load your client secret
Load the client secret provided by Covered support. This is the same secret you use for
authenticating API requests.
Create a signature
Create a HMAC SHA-256 signature of the request body using the client secret as the key.
The signature should be in hexadecimal format.
Compare signatures
Compare the signature in the
X-Covered-Signature-1 header with the signature you created.
To prevent timing attacks, use a constant-time comparison function like timingSafeEqual in Node.js.
If they match, the request is valid and you can process the webhook event.
If they do not match, reject the request as it may have been tampered with.Example Code
Example Signature
However you implement your signature function, when you run it with:- content:
'Hello, from Covered!' - client secret:
'Open Sesame'the resulting signature should be:
Schema
All webhook events follow the same common schema at the top level. Differences between events are in thedata object. The following fields are common to all events:
The ID of the webhook event. This can be used to deduplicate events.
The type of the webhook event, which describes what the type of change that happened.
The subject of the webhook event, which describes what object the change happened to.
The date and time the event occurred in ISO 8601 format. This can be used to prevent
replaying old events by rejecting events that are older than our maximum delivery window,
which is currently 14 days.
The specific data needed to process and make followup calls for this event,
usually consisting of the IDs needed to make the followup calls for additional
details.