Webhooks
Have links.et call your server when a verification finishes, with a signed request and retries.
Send webhookUrl with POST /api/verify and links.et calls that address when the verification finishes. You do not have to hold the request open, poll or keep a stream connected.
Ask for one
A call with webhookUrl returns 202 at once with a requestId, the same as the async flows. Add waitMs if you also want the answer in the response when it is quick. The webhook is sent either way, so your handler is the one place that always hears the result.
webhookUrl must be a public https:// address, at most 2,048 characters, with no username or password in it. Anything else is a 400 invalid_request that says why. The address is per request, so each order or environment can use its own.
What you receive
One POST with a JSON body:
| Field | Description |
|---|---|
id | The event id. The same on every retry of this event. Use it to ignore an event you have already handled. |
type | verification.completed when the receipt verified, verification.failed when it did not. For screenshots, see below. |
createdAt | When the verification finished. |
data | The same envelope GET /api/verify/:requestId returns for this request. |
On verification.failed, data.ok is false, data.receipt is null and data.error says why. There is one event per request.
If the request sent expect, data.receiverCheck says whether the payment went to you and data.amountCheck whether it was the right amount.
These headers come with it:
| Header | Value |
|---|---|
Links-Event | The event type, same as type in the body. |
Links-Event-Id | The event id, same as id in the body. |
Links-Attempt | Which attempt this is, from 1. |
Links-Signature | t=<unix seconds>,v1=<signature>. See the next part. |
Screenshots
POST /api/verify-image takes webhookUrl too. That call still answers in its own response, since reading a screenshot is done while you wait. The webhook is sent as well, with the same body under data, so your server hears the result even when the connection dropped during a slow read.
type | When |
|---|---|
image.completed | The screenshot was read. data is the 200 response body. |
image.failed | The reader failed (detection_failed). data is the 502 response body. |
image.completed means the read finished, not that the bank confirmed a payment: read data.upstream for that, the way you would on the response. The response also carries webhook: { id, url }, the id of the event that was queued. Calls refused up front (a bad body, a spent allowance) send no webhook.
Check the signature
Anyone can post to your address, so check that a request came from links.et before you trust it. Each API key has a signing secret. It is on the Webhooks page of your dashboard, or ask for it with the key:
The signature is HMAC-SHA256, keyed with that secret, over the timestamp, a dot, and the raw request body. Compute it over the bytes you received, before you parse the JSON:
Refusing a timestamp more than 5 minutes old stops someone replaying a request they captured. Each retry is signed again with a fresh timestamp, so a late retry still passes.
To replace the secret, use Replace on the dashboard page or POST /api/webhooks/secret. The old one stops working at once, including for events already waiting to be retried.
Answer and retries
Answer with any 2xx within 10 seconds. Do the real work after you answer if it is slow.
Anything else counts as a failure and is tried again: another status, a timeout, a connection error. A redirect is a failure too; links.et does not follow it.
| Attempt | When |
|---|---|
| 1 | As the verification finishes |
| 2 | 1 minute later |
| 3 | 5 minutes after that |
| 4 | 30 minutes after that |
| 5 | 2 hours after that |
| 6 | 6 hours after that |
After the sixth failure the event is dropped. Retries leave on a one-minute timer, so each can be up to a minute later than the table says.
Delivery is at least once. You can get the same event twice, for example when your 2xx was lost on the way back. Keep the id of each event you handle and skip one you have seen.
See what happened
The Webhooks page of your dashboard lists the last 50 webhooks on your account: where each went, how many attempts it took and what your server answered.
From code, GET /api/verify/:requestId carries a webhook object for a request that asked for one:
status is scheduled while the verification is still running, pending while there are attempts left, delivered once you answered 2xx, and failed when links.et gave up. The result itself stays readable there for 30 days whether or not the webhook got through.
Good to know
- An address that resolves to a private network is refused.
localhost,10.x,192.168.xand the like never get a request. To test from your laptop, put a public tunnel in front of your handler. - With an
Idempotency-Key, the first call decides. A replay with the same key does not start a second verification or a second webhook, and a differentwebhookUrlon the replay is ignored. - A webhook costs nothing extra. The verification counts toward your plan the way it would without one.