# SHORTLINKS

shortlinks endpoints.

**Base URL:** `https://api.trustpager.com/functions/v1/api/v1`

## Endpoints

### POST /shortlinks/bulk

Create up to 100 short links in one call. Each item is checked on its own: the answer lists created links and, for any that failed, its index, what was wrong and how to fix it.

**Scopes:** `shortlinks:write` — [full detail](./shortlinks/post-shortlinks-bulk.md)

### GET /shortlinks/availability

Check whether a short link name is free before using it. Returns available (true or false), reason (available, invalid, taken, or yours when one of your own links already has it), a plain message such as "Taken. Try roof-repair-2.", and up to 3 free suggestions. Lower case letters, numbers and hyphens, 3 to 40 characters, no hyphen at the start or end and no two hyphens in a row. Case is ignored (Roof-Repair is saved as roof-repair). Names on trustpager.link are first come first served across every TrustPager workspace. Reserved words (admin, api, app, login, help, www and similar) and anything that looks like TrustPager itself (trustpager, support, billing, security) are refused.

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks-availability.md)

### POST /shortlinks

Create a TrustPager Shortlink: https://trustpager.link/<name> sends people to destination_url (a temporary redirect, so later edits take effect). Choose the name or leave it out for a random one. Links to TrustPager forms, booking pages and this workspace's TrustPager websites record which link brought each lead, for 30 days after the click; links anywhere else count clicks only (tracks_leads in the answer says which). At most 300 new links per workspace per hour.

**Scopes:** `shortlinks:write` — [full detail](./shortlinks/post-shortlinks.md)

### DELETE /shortlinks/:shortlink_id

Delete a short link and its click history. The address stops working within about a minute and visitors see "This link no longer works". The name stays reserved for this workspace. To stop a link but keep its results, use disable_shortlink instead.

**Scopes:** `shortlinks:delete` — [full detail](./shortlinks/delete-shortlinks-shortlink-id.md)

### POST /shortlinks/:shortlink_id/disable

Turn a short link off. Visitors see "This link has been turned off" within about a minute. Its clicks and leads are kept; enable_shortlink turns it back on.

**Scopes:** `shortlinks:write` — [full detail](./shortlinks/post-shortlinks-shortlink-id-disable.md)

### POST /shortlinks/:shortlink_id/enable

Turn a disabled short link back on.

**Scopes:** `shortlinks:write` — [full detail](./shortlinks/post-shortlinks-shortlink-id-enable.md)

### GET /shortlinks/:shortlink_id

Get one short link with its status, all-time clicks, and previous_names (names it had before a rename, each redirecting here for 30 days after the rename).

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks-shortlink-id.md)

### GET /shortlinks/:shortlink_id/stats

Results for one short link over a period: clicks, bot_clicks, leads and opportunities it brought in, clicks by day, top referring sites, top countries and devices.

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks-shortlink-id-stats.md)

### GET /shortlinks/stats

Results for all of this workspace's short links over a period: clicks (people), bot_clicks (link previews and crawlers, kept apart), leads and opportunities the links brought in, clicks by day, top referring sites, top countries, devices, and the 10 most-clicked links of all time.

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks-stats.md)

### GET /shortlinks/:shortlink_id/leads

The contacts and opportunities this short link brought in, newest first: contact_id, deal_id (the opportunity), captured_via (form, booking, chat or website) and when the click happened.

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks-shortlink-id-leads.md)

### GET /shortlinks

List this workspace's TrustPager Shortlinks (trustpager.link/<name>), newest first, each with its short_url, destination, status (active, disabled, expired, taken_down), all-time clicks and whether it records leads (tracks_leads). Filter by label, campaign, active, source_type or source_id, or search across name, label, destination and campaign.

**Scopes:** `shortlinks:read` — [full detail](./shortlinks/get-shortlinks.md)

### POST /shortlinks/admin/takedown

TrustPager platform administrators only: turn off one short link in any workspace (abuse takedown), or turn it back on with restore. Visitors see "This link has been turned off". The workspace cannot turn it back on itself.

**Scopes:** `admin` — [full detail](./shortlinks/post-shortlinks-admin-takedown.md)

### POST /shortlinks/admin/workspace-takedown

TrustPager platform administrators only: turn off every short link of one workspace and stop it creating new ones, or undo that with restore.

**Scopes:** `admin` — [full detail](./shortlinks/post-shortlinks-admin-workspace-takedown.md)

### PATCH /shortlinks/:shortlink_id

Change a short link. Send only the fields to change; null clears an optional field. Changing destination_url takes effect within about a minute. Renaming (name): printed or posted copies of the old name keep working for 30 days, then stop; the old name stays reserved for this workspace and is never given to anyone else. Check a new name first with check_shortlink_name.

**Scopes:** `shortlinks:write` — [full detail](./shortlinks/patch-shortlinks-shortlink-id.md)
