# API Reference

Source: https://developers.leonai.io/docs/api-reference/

The complete, always-current API reference is generated from the API's **OpenAPI 3.1**
specification and served directly by the API.

## Interactive Swagger UI

Browse and try every endpoint — with request/response schemas, auth, and examples — in
the hosted Swagger UI:

```
https://api.short.leonai.io/api/v1/docs
```

[Open the full API Reference (Swagger UI) →](https://api.short.leonai.io/api/v1/docs)

## Machine-readable spec

The canonical OpenAPI document lives at:

```
https://api.short.leonai.io/api/v1/openapi.json
```

Use it to generate clients, run contract tests, or import into Postman / Insomnia:

```bash
# Download the spec
curl -o leonai-openapi.json https://api.short.leonai.io/api/v1/openapi.json

# Example: generate a client with openapi-generator
npx @openapitools/openapi-generator-cli generate \
  -i https://api.short.leonai.io/api/v1/openapi.json \
  -g typescript-fetch \
  -o ./leonai-client
```

:::tip[SDKs]
TypeScript and Python [SDKs](https://developers.leonai.io/docs/sdks/) with retries, rate-limit parsing, auto-pagination
and typed errors are on the way. Until they are published, a client generated from the
spec is the typed option.
:::

## Base URL & versioning

All versioned endpoints live under the `/api/v1` prefix on the API host. Short links
and public QR images are served from the redirect host at the root (`/:shortCode`,
`/:shortCode/qr`).

| Environment       | Base URL                      |
| ----------------- | ----------------------------- |
| Production        | `https://api.short.leonai.io` |
| Local development | `http://localhost:8080`       |

## Endpoint tags

The reference is organized by tag:

| Tag             | What's inside                                                                   |
| --------------- | ------------------------------------------------------------------------------- |
| **Links**       | Create, list, get, update, delete, bulk import, export, and per-link stats      |
| **Folders**     | Nested folders and link-to-folder assignment                                    |
| **Analytics**   | Link/account analytics, real-time stats, CSV exports, and conversion reports    |
| **Conversions** | Record conversions for revenue attribution (Business+, API key only)            |
| **Shares**      | Public, PII-free shareable analytics tokens                                     |
| **Pixels**      | Retargeting pixels and per-link attachment (Business+)                          |
| **Branding**    | White-label branding for public pages (Enterprise)                              |
| **Imports**     | One-click Bitly import                                                          |
| **Domains**     | Custom domains — manual DNS verification and one-click Cloudflare auto-connect  |
| **Routing**     | Smart routing rules (geo / device / time / A/B) per link (Business+)            |
| **Webhooks**    | Webhook endpoints, HMAC-signed deliveries, and delivery logs                    |
| **Bio Pages**   | Link-in-bio pages, items, publishing, and public resolution                     |
| **QR Codes**    | Public QR image generation for short links                                      |
| **AI**          | Slug suggestions, link insights (Business+), anomaly detection, provider status |
| **Public**      | Unauthenticated endpoints: redirects, link previews, public bio pages           |
| **Auth**        | Signup, login, tokens, email verification, password reset                       |
| **2FA**         | TOTP two-factor: setup, enable, disable, verify, status                         |
| **Users**       | Account data export, deletion, and consent (GDPR/CCPA)                          |
| **API Keys**    | Programmatic access keys and scopes                                             |
| **Billing**     | Subscription, checkout, invoices, and portal — **Sumit (OfficeGuy)**, USD       |
| **Teams**       | Team collaboration, members, invites, and RBAC roles                            |

:::note[Billing provider]
Billing runs on **Sumit / OfficeGuy** (US dollars, VAT invoices). The legacy
Stripe integration has been removed. See the [Billing guide](https://developers.leonai.io/docs/guides/billing/).
:::

See [Authentication](https://developers.leonai.io/docs/authentication/) for headers, [Errors](https://developers.leonai.io/docs/errors/) for the
error envelope, and the [coverage map](https://developers.leonai.io/docs/coverage/) for a checklist of every endpoint
and webhook event documented here.
