link.click webhook event
Flyn sends link.click to your webhook URL each time a person opens one of your short links. The delivery is a signed JSON POST with the link, the destination that was served, and the visitor's country, city, device and referrer.
Plan needed
Creating a webhook needs Pro, Lifetime or Team. Pro is $12 a month, or $9 a month billed annually, and Lifetime is $249 once. Team means a teammate in a paying owner's workspace, with any role but viewer. On Free, POST /api/webhooks answers 403 with the code UPGRADE_REQUIRED. See pricing.
When link.click fires
- A visitor opens one of your short links and Flyn sends them on to a destination. This covers plain links and links that use device rules, country rules, A/B testing or rotation.
- A visitor opens a link that has reached its click limit and is sent to the fallback URL.
- A visitor opens a
mailto:,tel:orsms:short link. - A visitor enters the right password on a password-protected link.
It does not fire when:
- The request comes from a known bot, crawler, link-preview fetcher or HTTP library, or sends no user agent. Flyn counts those as filtered bots, not clicks. The password unlock is the one path that is not filtered.
- The link is expired, archived or disabled, or has reached its click limit and has no fallback URL. The visitor sees a dead-link page and no click is recorded.
- A visitor only opens the password page. The event is sent when the password is accepted.
Who receives it
The webhooks of the user who created the link, when they are active and subscribed to link.click. Flyn does not send it to teammates' webhooks.
Payload
The body is JSON with three keys: event, timestamp and data.
{
"event": "link.click",
"timestamp": 1790157600000,
"data": {
"linkId": "3f0c2a9e-7b1d-4c55-9a0e-2d8f1b6c4e11",
"slug": "summer-sale",
"destinationUrl": "https://shop.example.com/sale",
"country": "US",
"city": "Austin",
"device": "mobile",
"referrer": "https://www.instagram.com/",
"variant": "B"
}
}| Field | Type | Description |
|---|---|---|
| event | string | The event name, the same value as the X-Flyn-Event header. |
| timestamp | number | Unix time in milliseconds when Flyn built the delivery. The same value as t in the X-Flyn-Signature header. |
| data | object | The event data. Its shape depends on the event. |
| data.linkId | string | The link id (UUID). |
| data.slug | string | The short link slug. |
| data.destinationUrl | string | Where the visitor was sent after device, country, A/B and rotation rules, before any query parameters the visitor added are passed through. When the link has reached its click limit, this is the fallback URL. For password-protected, mailto:, tel: and sms: links, it is the link's stored destination. |
| data.country | string | Two-letter country code, or "Unknown". |
| data.city | string | null | City name, or null when unknown. |
| data.device | string | "mobile", "desktop" or "tablet". |
| data.referrer | string | The referring URL the browser sent, or "Direct" when there is none. A referrer on flyn.to or on the link's own short domain is also reported as "Direct". For a password-protected link, this is the raw Referer header of the password form request. |
| data.variant | string | Only present when the link uses A/B testing ("A" or "B") or rotation (the id of the destination that was served). Left out for password-protected, mailto:, tel: and sms: links and for click-limit fallbacks. |
The payload has no IP address, browser, operating system or user agent. Browser and operating system are in Click Analytics (GET /api/links/:id/clicks).
Headers
Every delivery is an HTTP POST with these four headers:
| Field | Type | Description |
|---|---|---|
| Content-Type | string | Always "application/json". |
| X-Flyn-Event | string | The event name. For this event: "link.click". |
| X-Flyn-Signature | string | t=<Unix time in milliseconds>,v1=<hex HMAC-SHA256>. See Verify the signature. |
| User-Agent | string | Always "Flyn-Webhook/1.0". |
Verify the signature
Flyn signs every delivery. v1 is the HMAC-SHA256, in hex, of the t value, a dot and the raw request body, keyed with your full webhook secret, including its whsec_ prefix. t is Unix time in milliseconds and equals timestamp in the body.
import { createHmac, timingSafeEqual } from 'node:crypto';
// rawBody: the request body exactly as it arrived (a Buffer or a string).
// header: the X-Flyn-Signature value, "t=<milliseconds>,v1=<hex>".
// secret: your full webhook secret, including the "whsec_" prefix.
export function isFromFlyn(rawBody, header, secret) {
const parts = Object.fromEntries((header || '').split(',').map((p) => p.trim().split('=')));
if (!/^\d+$/.test(parts.t || '') || !parts.v1) return false;
// t is Unix time in MILLISECONDS. Reject a delivery older than 5 minutes.
if (Math.abs(Date.now() - Number(parts.t)) > 5 * 60 * 1000) return false;
const expected = createHmac('sha256', secret).update(parts.t + '.').update(rawBody).digest();
const received = Buffer.from(parts.v1, 'hex');
return received.length === expected.length && timingSafeEqual(received, expected);
}Sign the raw body bytes, not a parsed and re-serialized copy. POST /api/webhooks returns the secret once, and the person who created the webhook can copy it in Settings, Webhooks. A complete Express handler is in the webhooks reference.
Delivery rules
- One attempt. Flyn sends each event once to every webhook that is active and subscribed to it. It does not retry.
- 10 second timeout for the whole request. Flyn follows up to 5 redirects inside that time.
- Success is any 2xx response. It resets the failure count to 0.
- Anything else is a failure and adds 1 to the failure count: a response outside 2xx, a timeout, a connection error, a redirect Flyn refuses to follow, or a URL that no longer resolves to a public address.
- 10 failures in a row switch the webhook off. Its status becomes
inactive, Flyn stops sending to it and emails the person who created it. That email can be skipped when several deliveries fail at the same moment, so checkstatuswithGET /api/webhooksas well. - Missed events are not sent again, and Flyn keeps no log of single deliveries. Settings, Webhooks shows the failures in a row and the time of the last successful delivery.
- Switch it back on with
PATCH /api/webhooks/:idand{"status": "active"}, or with Activate in Settings, Webhooks. Both reset the failure count. - Sent after the redirect. Flyn redirects the visitor first and sends the webhook afterwards, so a slow endpoint never delays a click. Each click is its own POST; clicks are not batched.
- To catch up after an outage, read the clicks back with
GET /api/links/:id/clicks. Each click has a timestamp and they come newest first, up to 1000 a page.
Common questions
Is link.click sent for bots and link previews?
No. A request whose user agent matches Flyn's list of bots, crawlers, link-preview fetchers and HTTP libraries, or that sends no user agent, is filtered before a click is recorded and sends no webhook. The one exception is the password unlock on a protected link, which is not filtered.
Does Flyn retry a failed link.click delivery?
No. Flyn sends each link.click once, with a 10 second timeout, and does not send it again. To catch up, read the clicks back with GET /api/links/:id/clicks.
Does link.click include the visitor's IP address, browser or operating system?
No. The payload has the link id, the slug, the destination, the country, the city, the device and the referrer, plus the variant on A/B and rotation links. Browser and operating system are in Click Analytics. The IP address is in neither.
Are clicks batched into one delivery?
No. Each click is its own POST. Flyn sends it right after the redirect response, so the webhook never delays the visitor.
All webhook events
Flyn sends five events. Each has its own page with the payload and the rules for when it fires.
| Event | Sent when |
|---|---|
| link.click | A person opens one of your short links. This page. |
| link.create | A link is created with POST /api/links or in the dashboard. |
| link.update | A link is changed with PATCH /api/links/:id or in the dashboard. |
| link.delete | A link is deleted with DELETE /api/links/:id or in the dashboard. |
| webhook.test | You send a test ping. You cannot subscribe to it. |
Start with the API quick start, or read the webhooks reference for the endpoints that create, list, update, test and delete webhooks.
Was this page helpful? Spotted something wrong?