Skip to main content

Errors

An error comes back with an HTTP status code and a JSON body. The body always has a detail key. Most of the time detail is a plain string:

404 Not Found
{ "detail": "Link not found" }

Three kinds of error carry more data: plan errors, usage-limit errors and validation errors. They are described below.

Status codes​

StatusMeaningExample detail
400The request is wrong in a way the server checks itself."Alias must be 3–32 chars (letters, numbers, - or _)."
401No valid API key or session."Invalid API key", "Not authenticated"
402Your plan doesn't include the feature, or you hit a usage limit.See below
403Signed in, but not allowed: the key lacks a scope, or your team role is too low."API key lacks permission: links:write"
404Not found, or not in your workspace."Link not found"
409Conflict with existing data."Alias already taken"
413The upload is too large."CSV too large (max 1MB)"
422The body or query failed validation, or the destination is unsafe.See below
429Rate limited."API key rate limit exceeded (100/min)"
5xxServer error. Safe to retry with backoff.

402: plan required​

A feature your plan doesn't include returns a 402. detail stays a string, so code that reads it as text keeps working. Extra keys sit beside it:

402 Payment Required
{
"detail": "Requires plan: pro or enterprise",
"error": "plan_required",
"message": "Requires plan: pro or enterprise",
"feature": "routing",
"required_plan": "pro",
"plan": "free"
}
KeyMeaning
errorAlways "plan_required" for this kind of error.
featureThe feature you tried to use, for example routing, pixels, campaigns.
required_planThe cheapest plan that includes the feature.
planYour current plan. A paid plan with an inactive subscription counts as free.

402: usage limit​

When you reach a monthly limit (links, tracked clicks or AI credits), detail is an object:

402 Payment Required
{
"detail": {
"error": "quota_exceeded",
"message": "You've reached your monthly link limit. Upgrade or buy a link pack to create more.",
"dimension": "links",
"used": 50,
"limit": 50,
"plan": "free",
"upgrade_to": "pro"
}
}
KeyMeaning
dimensionWhat ran out: links, clicks or ai_credits.
used, limitYour usage and your limit this month. limit includes packs you bought.
upgrade_toThe next plan up, or null on Enterprise.

AI endpoints called on a plan with no AI credits return the same nested shape with "error": "ai_requires_paid_plan".

Tell the two 402s apart

Check typeof body.detail. A string means a plan error. An object means a usage limit.

422: validation error​

A body or query that doesn't match the schema returns FastAPI's standard 422. Here detail is a list, one item per problem:

422 Unprocessable Entity
{
"detail": [
{
"type": "missing",
"loc": ["body", "url"],
"msg": "Field required",
"input": {}
}
]
}

loc points at the field. A destination flagged as phishing or malware also returns 422, but with a string detail.

Handle errors in code​

const res = await fetch("https://api.linklane.io/api/links", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LINKLANE_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ url: "https://example.com" }),
});

if (!res.ok) {
const { detail } = await res.json();
if (Array.isArray(detail)) {
// 422: one entry per invalid field
console.error(detail.map((d) => `${d.loc.join(".")}: ${d.msg}`).join("\n"));
} else if (typeof detail === "object") {
// 402 usage limit
console.error(`${detail.dimension}: ${detail.used}/${detail.limit}`);
} else {
console.error(res.status, detail);
}
}