> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trimyourl.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Base URL, workspace API keys, and how requests are scoped.

The TrimYourl API is REST over HTTPS on the same host as the app. There is no separate `api.` subdomain.

## Base URL

```bash theme={null}
https://trimyourl.com
```

## Authentication

Link, analytics, domain, and QR endpoints require a Bearer token. Create a key under **Settings → API**. It starts with `tyl_` and is shown once.

```bash theme={null}
Authorization: Bearer tyl_YOUR_KEY
```

The key belongs to **one workspace**. You do not pass a workspace id. Switch workspace in the app, then create another key if you need a different client.

> [!WARNING]
>
> Treat the secret like a password. TrimYourl stores only a hash. If you lose it, create a new key.

`POST /api/v1/convert` is public (CORS `*`). It is meant for the tracking snippet or your server, not for the `tyl_` key.

## Endpoints

| Method | Path | Auth | Purpose |
| - | - | - | - |
| `POST` | `/api/v1/links` | Bearer | Create a short link |
| `GET` | `/api/v1/links` | Bearer | List links (`?q=`, `?limit=`, `?offset=`) |
| `GET` | `/api/v1/links/{id}` | Bearer | Get one link |
| `PATCH` | `/api/v1/links/{id}` | Bearer | Update a link (rename keeps the old slug live) |
| `DELETE` | `/api/v1/links/{id}` | Bearer | Delete a link and stop the short URL |
| `GET` | `/api/v1/links/{id}/analytics` | Bearer | Click breakdown for one link |
| `GET` | `/api/v1/analytics` | Bearer | Workspace click breakdown |
| `GET` | `/api/v1/domains` | Bearer | Active domains in the workspace |
| `GET` | `/api/v1/qr` | Bearer | PNG for a link id |
| `POST` | `/api/v1/convert` | None | Credit a conversion to a click |

Use the playground pages in this tab to send requests. Conversion webhooks are documented under [Webhooks](https://docs.trimyourl.com/api-reference/webhooks.md).

## Errors

| Code | Meaning |
| - | - |
| `200` | Success. Conversion may still return `{ ok: false, reason: "window" }`. |
| `400` | Invalid body, missing `destination` / `kid`, or the link could not be created. |
| `401` | Missing or unknown API key. |
| `403` | Conversion `client` did not match the workspace tracking key. |
| `404` | Link or click not found (or the click was a bot). |

JSON errors look like `{ "error": "destination is required" }`. Conversion errors use `{ "ok": false, "reason": "kid" }` and similar.

Creating links is limited to 60 per hour per user. Trial workspaces can hold 50 links.

## Example

```bash theme={null}
curl -X POST https://trimyourl.com/api/v1/links \
  -H "Authorization: Bearer tyl_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"destination":"https://northwind.com/spring","title":"Spring launch"}'
```

```json theme={null}
{
  "id": "8f3c1a2b-4d5e-6789-abcd-ef0123456789",
  "shortUrl": "https://go.northwind.com/spring-launch",
  "slug": "spring-launch",
  "title": "Spring launch",
  "destination": "https://northwind.com/spring",
  "domain": "go.northwind.com",
  "tags": [],
  "humanClicks": 0,
  "health": "unknown"
}
```

The Chrome extension sends this request for the current tab. See [Chrome extension](https://docs.trimyourl.com/extension/install.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.