URL shortener API quick start
With Flyn's URL shortener API you create a short link, read its clicks and receive a signed webhook, in four steps and under 20 lines of curl.
Before you begin
You need a Flyn account on Pro, Lifetime or Team. Creating an API key in the dashboard and creating a webhook are paid features: Pro is $12 a month, or $9 a month billed annually, and Lifetime is $249 once (see pricing). On Free, an AI assistant can still create and manage your links through the MCP server, by signing in, with no API key.
The base URL is https://www.flyn.to, with the www. Every path starts with /api, and requests and responses are JSON. The same endpoints are described in the OpenAPI spec.
Step 1. Create an API key
- Sign in to Flyn and open Settings, then the API Keys tab.
- Click Create Key, give the key a name and copy it. A key starts with
flyn_sk_live_and is shown only once. - Keep it in an environment variable, never in client-side code:
export FLYN_API_KEY="flyn_sk_live_..."
You can create up to 5 active keys. In a team workspace a viewer cannot create one. More in Authentication.
Step 2. Create a short link
curl -X POST https://www.flyn.to/api/links \
-H "Authorization: Bearer $FLYN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/launch"}'Flyn answers 201 with the link object. shortUrl is the link to share, and you need id for the next step.
{
"id": "3f0c2a9e-7b1d-4c55-9a0e-2d8f1b6c4e11",
"slug": "k3J9xQ",
"url": "https://example.com/launch",
"shortUrl": "https://flyn.co/k3J9xQ",
"domain": "flyn.co",
"title": "example.com",
"clicks": 0,
"status": "active",
"createdAt": "2026-09-23T10:00:00.123456+00:00"
}With no slug in the request, Flyn picks a random 6 character slug. Send "slug": "launch" to choose your own; a slug that is already taken on the domain answers 409. Every field is listed in Links.
Step 3. Read the link's clicks
curl "https://www.flyn.to/api/links/LINK_ID/clicks?limit=10" \ -H "Authorization: Bearer $FLYN_API_KEY"
Replace LINK_ID with the id from step 2. Clicks come newest first, up to 1000 a page (limit, default 100).
{
"clicks": [
{
"id": "9b1f6c0e-4a2d-4f6b-8c3e-7d5a1b2c3d4e",
"timestamp": "2026-09-23T10:05:12.482913+00:00",
"country": "US",
"city": "Austin",
"device": "mobile",
"os": "iOS",
"browser": "Safari",
"referrer": "https://www.instagram.com/"
}
],
"pagination": { "page": 1, "limit": 10, "total": 1, "totalPages": 1, "hasMore": false },
"planLimits": { "advancedAnalytics": true, "retentionDays": null }
}Flyn filters known bots, crawlers and link-preview fetchers out of redirects before it records a click. More in Click Analytics.
Step 4. Add a webhook
curl -X POST https://www.flyn.to/api/webhooks \
-H "Authorization: Bearer $FLYN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://api.yoursite.com/webhooks/flyn", "events": ["link.click"]}'Flyn answers 201 with the webhook and its signing secret. Save secret now: this is the only API response that returns it in full.
{
"webhook": {
"id": "8b3c1f6e-2a4d-4f0b-9c1e-5d7a2b9e0c11",
"url": "https://api.yoursite.com/webhooks/flyn",
"events": ["link.click"],
"secret": "whsec_3f9a0c7d1e2b4a5c6d7e8f901a2b3c4d5e6f7a8b9c0d1e2f",
"status": "active",
"createdAt": 1790157600000,
"failureCount": 0
}
}Send yourself a test delivery before real clicks arrive. Replace WEBHOOK_ID with the id you just got:
curl -X POST https://www.flyn.to/api/webhooks/WEBHOOK_ID \ -H "Authorization: Bearer $FLYN_API_KEY"
Then open your short link in a browser. Flyn redirects you, and right after that it sends this to your endpoint:
POST /webhooks/flyn HTTP/1.1
Content-Type: application/json
User-Agent: Flyn-Webhook/1.0
X-Flyn-Event: link.click
X-Flyn-Signature: t=1790157600000,v1=<64 hex characters>
{
"event": "link.click",
"timestamp": 1790157600000,
"data": {
"linkId": "3f0c2a9e-7b1d-4c55-9a0e-2d8f1b6c4e11",
"slug": "k3J9xQ",
"destinationUrl": "https://example.com/launch",
"country": "US",
"city": "Austin",
"device": "mobile",
"referrer": "https://www.instagram.com/"
}
}The body is indented here for reading. Flyn sends the same JSON without the extra spaces.
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.
What to know before you ship
- One header for auth. Send
Authorization: Bearer flyn_sk_live_...on every request. - Rate limits are per IP address and per endpoint. Creating or updating a link: 10 a minute. Listing links or reading clicks: 30 a minute. Reading or deleting one link: 60 a minute. A
429from these endpoints carries aRetry-Afterheader in seconds. See Rate Limits. - Errors are JSON. The body is
{"error": "..."}, sometimes with acodesuch asUPGRADE_REQUIRED. See Errors. - Webhooks are sent once. One attempt per event, a 10 second timeout, no retries. 10 failures in a row switch the webhook off. The full rules are on each event page below.
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. |
| 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.
Next steps
- Links: every field you can set on a link, plus update and delete.
- Click Analytics: the click object and paging.
- Webhooks: list, update, test and delete webhooks.
- OpenAPI spec: generate a client or import the API into a tool.
- MCP server: let an AI assistant manage links, on every Flyn plan, Free included.
Common questions
Does Flyn have a URL shortener API with webhooks?
Yes. Flyn has a REST API that creates, lists, reads, updates and deletes short links and reads their clicks, described by an OpenAPI 3.1 spec. It sends webhooks for four events, link.click, link.create, link.update and link.delete, and signs every delivery with HMAC-SHA256 in the X-Flyn-Signature header.
Which Flyn plan includes the API and webhooks?
Pro, Lifetime and Team. Pro is $12 a month, or $9 a month billed annually. Lifetime is $249 once. On Free, an AI assistant can create and manage links through the MCP server by signing in, with no API key.
Does Flyn retry failed webhook deliveries?
No. Flyn sends each event once, with a 10 second timeout, and does not send it again. After 10 failures in a row it switches the webhook off and emails the person who created it. To catch up after an outage, read clicks back with GET /api/links/:id/clicks and links with GET /api/links.
Is there a Flyn SDK?
Yes. The flyn-sdk package for TypeScript wraps the link endpoints: create, list, get, update, delete and clicks. Install it with npm install flyn-sdk. Webhooks are managed with the REST endpoints shown on this page.
Was this page helpful? Spotted something wrong?