API v1

Build on Linktain.

Three endpoints. Make a locked link, list what you have, read what each one earned. JSON goes in, JSON comes out, and one bearer key opens all of it.

Base https://linktain.com/api/v1No SDK neededFree on every account

Make a key in Settings, paste it into this, and you have a live locked link in one request. Everything else on this page is detail.

curl -X POST https://linktain.com/api/v1/links \
  -H "Authorization: Bearer lt_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"title":"My download","destinationUrl":"https://example.com/file"}'

The shortUrl that comes back is the thing you share. It starts counting the moment somebody opens it.

One header on every request. Keys begin with lt_ and are made in Dashboard, Settings.

Authorization: Bearer lt_your_api_key_here
Shown once

We store a hash, never the key itself. Lose it and there is nothing to look up: revoke it and make another.

Revoked means immediately

The next request with a revoked key gets a 401. There is no grace period and nothing is cached.

One key, your whole account

A key can see and change everything you can. Anything done with it is done by you, so keep it off the client side.

No published rate limit

A few requests a second and you will never hear from us. We would rather tell you the truth than invent a number.

Every amount in this API is an integer number of mills. A mill is a thousandth of a dollar, so 1000 mills is $1.00 and 6420 mills is $6.42.

Integers, because money in a float is money that eventually does not add up. Divide by 1000 at the moment you print it and never before.

const usd = (mills) => (mills / 1000).toFixed(2);

usd(6420);  // "6.42"

Recent days can still move. A partner reversing a conversion takes it back off the balance it landed on, sometimes weeks later, so treat the last few days as provisional rather than final.

GET/e.js

One tag on a site you own turns every outbound link on it into a locker. You do not rewrite any hrefs and you do not create the links: the first time somebody clicks one we make it, and every click after that uses the same one.

<script src="https://linktain.com/e.js" data-key="pk_your_site_key"></script>

Register the site in Dashboard, Links to get the key. It is public on purpose, because it sits in your page source where anybody can read it. What stops somebody else using it is the hostname you registered against it: a request from any other site is refused.

Never touched

Links to your own pages, anchors, mailto: and tel:, downloads, middle clicks and ctrl-clicks.

Fails open

If we are slow or down, the click goes straight through to where it was already going. Your site does not break because ours did.

Opting a link out, or narrowing it to your own selector
<a href="https://example.com/sponsor" data-linktain="off">never locked</a>

<script src="https://linktain.com/e.js"
        data-key="pk_your_site_key"
        data-selector="a.paid"></script>

Every failure is the same shape, { "error": "..." }, with the status carrying the category and the string saying what to fix.

400
The body was not JSON, or a field failed validation.
The message names the field, e.g. "destinationUrl: must use http:// or https://". Fix it and send again.
401
No Authorization header, or the key is wrong, or you revoked it.
Check the header reads Bearer lt_… and that the key is still listed in Settings.
403
The account cannot use the API: awaiting approval, suspended, or banned.
The message says which. Approval is the usual one and it is a person, not a queue you can retry past.
404
No link with that id on your account.
Check the id came from your own list. Somebody else's id answers 404 too.
500
We broke.
Retry once. If it keeps happening, tell us on Telegram and include roughly when.
503
Could not allocate a short code, which takes an unlucky run of collisions.
Retry. It is transient and it clears immediately.

Get a key and make the first call.

Keys live in Settings. If something here is wrong or missing, say so on Telegram at @LinksWithAndrew and it gets fixed, usually the same day.

Create an API key