REST API quickstart

Everything the slim.to dashboard does is backed by a JSON API at https://slim.to. The full OpenAPI spec is served at https://slim.to/docs/api (Swagger UI).

Auth

Create a personal API key and send it as X-API-Key:

export SLIMTO_API_KEY=slim_your_key_here

Shorten a URL

curl -s -X POST https://slim.to/api/v1/links \
  -H "X-API-Key: $SLIMTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"target_url": "https://example.com/pitch", "title": "Pitch deck"}'

Response (trimmed):

{
  "id": "52cab9d5-…",
  "slug": "x0b31u",
  "short_url": "https://slim.to/x0b31u",
  "type": "redirect",
  "is_active": true
}

Optional body fields: slug (custom slug), password, expires_at (ISO 8601), max_views, domain (a verified custom domain), tags.

Upload a file → hosted link

Multipart upload; returns the file record and the hosted link in one call:

curl -s -X POST https://slim.to/api/v1/files \
  -H "X-API-Key: $SLIMTO_API_KEY" \
  -F "file=@report.pdf" \
  -F "title=Q3 Report"

Optional form fields: slug, password, domain.

Allowed types: pdf, png, jpg, jpeg, gif, html, zip, mp4. Max 100 MB.

Files over 30 MB must use the two-step flow (the single-request path is capped by the hosting platform):

# 1. Get a signed upload URL
curl -s -X POST https://slim.to/api/v1/files/upload-url \
  -H "X-API-Key: $SLIMTO_API_KEY" -H "Content-Type: application/json" \
  -d '{"filename": "demo.mp4"}'
# → {"storage_key": "...", "upload_url": "...", "content_type": "video/mp4"}

# 2. PUT the file to upload_url
curl -s -X PUT "<upload_url>" -H "Content-Type: video/mp4" --data-binary @demo.mp4

# 3. Confirm — creates the File + Link records
curl -s -X POST https://slim.to/api/v1/files/confirm \
  -H "X-API-Key: $SLIMTO_API_KEY" -H "Content-Type: application/json" \
  -d '{"storage_key": "<storage_key>", "filename": "demo.mp4", "title": "Demo video"}'

List your links

curl -s "https://slim.to/api/v1/links?q=report&page=1&per_page=20" \
  -H "X-API-Key: $SLIMTO_API_KEY"

Returns {"links": [...], "total": n, "page": 1, "per_page": 20, "pages": n}. q searches slug, title, and target URL.

Analytics for a link

curl -s https://slim.to/api/v1/analytics/links/<link_id> \
  -H "X-API-Key: $SLIMTO_API_KEY"

Returns totals (total_views, unique_viewers, total_time_spent_seconds, last_viewed_at), breakdowns (device_breakdown, country_breakdown, referrer_breakdown, per-page page_breakdown for PDFs), and per-session detail. Add /export to the path for CSV.

Other useful endpoints

Method Path
GET /api/v1/links/<id> Full link detail
PATCH /api/v1/links/<id> Update title, password, expiry, routing rules…
DELETE /api/v1/links/<id> Delete a link
GET /api/v1/links/<id>/qr QR code PNG for the link
GET /api/v1/domains Your verified custom domains

Errors are JSON: {"error": "message"} with a conventional status code (401 bad key, 403 plan limit, 404, 409 slug taken, 429 rate limit).