Links API
Create short links, edit their title, description and expiry, move them between folders and delete them with the TrimLink API.
A link's destination is set when you create it and can't be changed. To send people somewhere else, create a new link. Links made with an API key land in your personal workspace.
The API can't list or read links yet. Use the dashboard to see them, and the Analytics API for click stats. Create tags with the Tags API.
/api/v1/linksCreate a short link. /api/v1/shorten takes the same body, ignores tagIds and returns the same shape without tags. Send an Idempotency-Key header to make retries safe: the same key within an hour returns the first link instead of a new one (POST /api/v1/links only).
links:writeParameters
| Name | Type | Required | Description |
|---|---|---|---|
destinationUrl | string | Yes | The URL to shorten. It must use https and a public hostname, 10 to 2,048 characters. It is fixed once the link exists. |
customCode | string | No | Your own short code: 3 to 20 letters, numbers, hyphens or underscores, not starting with an underscore. Reserved words are refused. Omit it for a random code. Custom codes count toward a monthly allowance on your plan. |
customDomain | string | No | A verified custom domain in your personal workspace, such as go.example.com. Omit it to use trimlink.co. |
title | string | No | Up to 200 characters. |
description | string | No | Up to 500 characters. |
expiresAt | string | No | ISO 8601 date in the future, at most 1 year out. Omit it and the link never expires. |
generateQR | boolean | No | true also makes a QR code for the link and returns it as qrCode. If your monthly QR limit is already used up, the request fails with 403 and no link is made. If the QR code fails for another reason, such as a color or logo your plan does not include, the link is still created and the response has qrCodeError. |
qrColor | string | No | Hex color for the QR code. Default #000000. |
qrLogo | string | No | none (default), trimlink, wifi, globe, cart, restaurant or custom. |
tagIds | string[] | No | Up to 10 tag IDs from the Tags API. POST /api/v1/links only. |
Request
curl -X POST https://trimlink.co/api/v1/links \
-H "Authorization: Bearer tk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"destinationUrl": "https://example.com/spring",
"customCode": "spring-sale",
"title": "Spring sale",
"tagIds": ["7a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d"]
}'Response
{
"success": true,
"data": {
"id": "9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c",
"shortCode": "spring-sale",
"originalUrl": "https://example.com/spring",
"shortUrl": "https://trimlink.co/spring-sale",
"createdAt": "2026-11-19T12:00:00.000Z",
"tags": [{ "id": "7a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d", "name": "spring-launch" }]
}
}/api/v1/links/:idEdit a link's title, description or expiry. Send only the fields you want to change. The destination can't be edited. Each call counts toward your plan's monthly link edits.
links:writeParameters
| Name | Type | Required | Description |
|---|---|---|---|
title | string | null | No | Up to 200 characters. |
description | string | null | No | Up to 500 characters. |
expiresAt | string | null | No | ISO 8601 date in the future, at most 1 year out. null removes it. |
Request
curl -X PATCH https://trimlink.co/api/v1/links/9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c \
-H "Authorization: Bearer tk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{ "title": "Spring sale (email)", "expiresAt": "2027-03-31T23:59:59Z" }'Response
{
"success": true,
"data": {
"id": "9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c",
"shortCode": "spring-sale",
"title": "Spring sale (email)",
"description": null,
"expiresAt": "2027-03-31T23:59:59.000Z",
"updatedAt": "2026-11-19T12:05:00.000Z",
"tags": [{ "id": "7a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d", "name": "spring-launch" }]
}
}/api/v1/links/:id/movePut a link in a folder, or send null to take it out of its folder.
links:writeParameters
| Name | Type | Required | Description |
|---|---|---|---|
folderId | string | null | Yes | A folder ID from the Folders API, or null. |
Request
curl -X PATCH https://trimlink.co/api/v1/links/9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c/move \
-H "Authorization: Bearer tk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{ "folderId": "3f2e1d0c-9b8a-4765-8432-10fedcba9876" }'Response
{
"success": true,
"link": { "id": "9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c", "folderId": "3f2e1d0c-9b8a-4765-8432-10fedcba9876" }
}/api/v1/links/:idDelete a link. It stops redirecting. The response has no body.
links:writeRequest
curl -X DELETE https://trimlink.co/api/v1/links/9c8b7a6d-5e4f-4a3b-8291-0d1e2f3a4b5c \
-H "Authorization: Bearer tk_live_your_api_key"Response
Errors
Errors return { "error": "message" } with one of these statuses.
| Status | When |
|---|---|
400 | Invalid body, for example a missing destinationUrl, an http:// URL or a bad customCode. |
401 | Missing, invalid, expired or revoked API key. |
403 | The key lacks links:write, your plan has no API access, or a plan limit is reached. Limit errors add tier, limit, current and limitKey (links, customSlugs, qrCodes, linkEdits, clicksPerMonth). |
404 | The link or folder does not exist in your workspace. |
409 | The customCode is already taken. |
429 | Daily API request limit reached. |
See errors and rate limits for the full bodies.