POST to your server when something happens in End Close, such as a record being reconciled. Each delivery is a signed JSON event, so your systems can react without polling the API.
Webhooks are a premium feature. To turn them on, contact End Close.
Set up a webhook endpoint
1
Build a handler
Add an HTTPS route to your app that accepts
POST requests with a JSON body. Keep access to the raw request body, because you need the exact bytes to verify the signature.2
Request access
Email founders@endclose.com with your endpoint URL and the events you want. End Close sets up the endpoint for you.
3
Store the signing secret
End Close gives you a signing secret for the endpoint. It’s shown once, so store it in a secrets manager or environment variable straight away.
4
Verify every delivery
Check the
End-Close-Signature header on each request before you trust the payload, as described below.Event payload
Every delivery has the same envelope. Thedata object holds the resource the event is about.
record.reconciled
Verify the signature
End Close signs every delivery with your endpoint’s signing secret and puts the result in theEnd-Close-Signature header:
Header
tis the time the delivery was signed, in Unix seconds.v1is the hex-encoded HMAC-SHA256 of the string<t>.<raw request body>, keyed with your signing secret.
- Split the header on
,and read thetandv1values. - Reject the request if
tis more than 5 minutes from your server’s current time. This stops an attacker replaying an old delivery. - Build the signed string: the
tvalue, a period, then the raw request body exactly as received. - Compute HMAC-SHA256 of that string with your signing secret and hex-encode it.
- Compare your result with
v1using a constant-time comparison. Reject the request if they differ.
Respond quickly
Return a2xx status as soon as you’ve verified and stored the event. Do slow work, such as updating your ledger or calling other APIs, in a background job after you respond.
Retries and duplicate deliveries
When a delivery fails, End Close retries it with exponential backoff. Because of retries, your endpoint can receive the same event more than once. Make your handler idempotent: record each event’sid when you process it, and skip any event whose id you’ve already handled.
FAQ
How do I get webhooks turned on?
How do I get webhooks turned on?
Webhooks are a premium feature. Email founders@endclose.com with your endpoint URL and the events you want, and End Close sets up the endpoint and sends you its signing secret.
Why does my signature check fail?
Why does my signature check fail?
The most common cause is signing a re-serialized body instead of the raw bytes. Also check that you’re using the secret for this endpoint, that you include the
t value and the period in the signed string, and that your server clock is accurate to within 5 minutes.Can the same event arrive twice?
Can the same event arrive twice?
Yes. Retries mean a delivery can repeat. Deduplicate on the event
id.Related
Webhook events
Every event End Close sends, with example payloads.
Records
The record object that record events carry.