Making Requests
What holds for every endpoint of the Shortn API, and how to build a client that keeps working when things go wrong. Each endpoint’s own parameters and errors are in the API reference.
Requests and responses
- Base URL:
https://app.shortn.link/api/v1, over HTTPS only. - Authentication:
Authorization: Bearer <key>on every request except the public endpoints. See API keys. - Bodies: JSON, with
Content-Type: application/json. Field names aresnake_case, as in the reference. Send only the fields an endpoint documents: the conversion endpoints refuse unknown ones (400), so a typo doesn’t pass silently. - Responses: JSON, except QR codes (an image). Successful writes answer
200or201 Created. - Times are RFC 3339 in UTC, such as
2026-11-21T09:30:00Z. Money is an integer in the currency’s minor units (amount_cents: 4900is 49.00) with an ISO 4217currency. - Identifiers: most resources are addressed by their
public_id: links, workspaces, tags, UTM templates and destinations. Teams use theirslug, custom domains theirid. A link’s short code is for people, not for the API:GET /links/abC12x9answers404,GET /links/{public_id}finds it.
New fields and codes
The API grows within v1: responses gain fields, and endpoints gain error codes. Build
your client so that this never breaks it:
- ignore response fields you don’t use, rather than failing on unknown ones;
- branch on an error’s
code, and treat acodeyou don’t know by its HTTP status.
Pagination
The two lists that can grow long, links and
conversion events, take limit (1 to 100, default 50) and
offset, and say whether there is more:
{
"data": [ ... ],
"pagination": {
"limit": 50,
"offset": 0,
"count": 50,
"has_more": true,
"next_offset": 50
}
}count is how many items this page holds. Request again with offset set to
next_offset until has_more is false. Other lists, such as workspaces, tags and
teams, come back whole.
Errors
Every error has the same shape:
{
"code": "api_key_scope_not_allowed",
"error": "API key scope is not allowed",
"hint": "Create or update an API key with the required scope.",
"details": { "required_scope": "links:write" }
}code is stable and meant for your code; error and hint are for people and may change.
details.field names the request field at fault. What to do by status:
| Status | Meaning | What to do |
|---|---|---|
400, 422 | The request is invalid. | Fix it; sending it again won’t help. |
401 | No key, or a key that no longer works. | Check the key; alert someone. |
403 | The key, or the plan, doesn’t allow it. | Check permissions, data access or plan limits. |
404 | Not found, or not visible to this key. | Check the identifier and the key’s workspace. |
409 | A conflict with the current state. | Read the code; the reference says what it needs. |
429 | Too many requests. | Wait Retry-After seconds, then retry. |
500, 502, 503, 504 | A problem on Shortn’s side. | Retry with backoff (see below). |
The endpoints that receive leads, sales and refunds also return a request_id, the same as
the Shortn-Request-Id header. Log it: it finds the call in the
event log.
Rate limits
Each plan allows a number of requests per minute, shared by all of its keys, with a lower limit for analytics and conversion reads (the numbers). Every response says where you stand:
X-RateLimit-Limit: 600
X-RateLimit-Remaining: 597
X-RateLimit-Window: 60
X-RateLimit-Policy: default- Watch
X-RateLimit-Remainingin batch jobs and slow down before it reaches zero. - On
429, wait theRetry-Afterseconds, then continue. - Spread imports and syncs over time instead of sending everything at once.
Retries and idempotency
Networks fail, and a request can time out after Shortn has already done it. Retry only what is safe to send twice:
| Request | Safe to retry? |
|---|---|
GET | Always. |
PUT, PATCH, DELETE | Yes: sending the same change again gives the same result. |
Leads, sales and refunds (POST /conversions/...) | Yes, with their identifier: idempotency_key for a lead, invoice_id or idempotency_key for a sale, refund_id for a refund. A repeat answers the event already recorded, with "duplicate": true. |
Other POSTs, such as creating a link, tag or team | Not blindly: a retry after a timeout can create a second one. List first, or match on something you set (a title, a name), before trying again. |
When you retry:
- wait between attempts and wait longer each time (for example 0.5 s, 1 s, 2 s), with a little randomness, and give up after a few attempts;
- retry on
429,503, other5xxanswers and network errors, not on other4xx; - make identifiers stable values from your own system, such as your order or sign-up ID, never a random value made per attempt, or a retry counts as a new event.
Set a timeout on every request. Most answers take well under a second, but conversion reporting reads can take a few seconds.
The SDKs follow these rules for you.
Test mode
Conversion events can be sent as tests, kept out of your live reports: add
"test_mode": true and read them back with environment=test. Test events are never
deduplicated, and a test refund names a live sale without changing its totals; see
conversions. Links, tags and the other resources have no test
mode: try them in a separate workspace, with a workspace key.
Before you go live
- Each integration has its own key, with only the permissions it uses, stored in a secret manager or environment variable, never in frontend code.
-
401and403answers alert someone: they mean a key was revoked, expired or lost a permission. - Batch jobs respect
429andRetry-After. - Only safe requests are retried, with backoff and a limit.
- Leads, sales and refunds carry stable identifiers from your system.
- Conversion
request_ids are logged. - Unknown response fields and error codes don’t break the client.
- Every request has a timeout.
-
test_modeis off in production.