Webhooks
Have Finic send each event to your HTTPS endpoint as it happens, signed with Standard Webhooks, with retries and a delivery log.
A webhook sends each Finic event to your HTTPS endpoint as it happens, so you don't have to poll. Webhooks and events belong to your whole organization, not to one product. Today the events come from KYB: business records, screenings, verifications and monitoring. Scores, ask and Identify don't send events yet.
Add an endpoint
Add an endpoint with an API key an admin created. url must be public and https. event_types takes types, groups such as screening.*, or *:
curl https://api.finic.ai/v1/webhook_endpoints \
-H "Authorization: Bearer $FINIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "url": "https://example.com/webhooks/finic", "event_types": ["screening.*", "verification.completed", "business.status_changed"] }'The response has the signing secret, whsec_…, shown only this once. Keep it. An organization has at most 20 endpoints. You can also manage endpoints in the Finic app, under Settings → Webhooks.
Each delivery is a POST of the event, as GET /v1/events shows it.
Verify the signature
Deliveries are signed by the Standard Webhooks specification, with three headers: webhook-id (the event's id), webhook-timestamp (Unix seconds) and webhook-signature. The signature is v1, and the base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<body>, keyed with the secret's bytes after whsec_, base64-decoded. The Standard Webhooks libraries check it for you (pip install standardwebhooks):
from standardwebhooks.webhooks import Webhook
wh = Webhook(FINIC_WEBHOOK_SECRET) # "whsec_..."
def handle(request):
event = wh.verify(request.body, request.headers) # raises if the signature is wrong
...Check the signature on the raw body, before parsing it. Refuse a timestamp that's minutes old.
After you rotate the secret (POST /v1/webhook_endpoints/{id}/rotate_secret), deliveries are signed with the old secret too, for 24 hours, so webhook-signature can hold two signatures, separated by a space.
Delivery and retries
- Answer with a
2xxwithin 10 seconds. Do the work after you answer. - Otherwise Finic tries again after 5 seconds, 5 minutes, 30 minutes, and 2, 5, 10 and 14 hours. After that, the delivery is
failed. - Redirects aren't followed.
- Delivery is at least once, and in no set order. Use
webhook-idto skip an event you've had, andseqto put events in order. - An endpoint that answers
410, or fails for 5 days with no delivery taken, is disabled (webhook_endpoint.disabled), and what it has yet to get is cancelled. Events while it's disabled aren't sent later: read them fromGET /v1/events, then turn the endpoint on again withPATCHand"status": "enabled".
GET /v1/webhook_deliveries lists deliveries, with each one's status, attempts and the HTTP status your endpoint answered with. Send one again with POST /v1/webhook_deliveries/{id}/retry, and a test event with POST /v1/webhook_endpoints/{id}/test. Finished deliveries are kept for 30 days.