Developer Docs
API Reference
Simple REST API — no authentication required for creating links.
Base URL: https://<your-worker>.workers.dev
Endpoints
POST
/shorten
Creates a permanent short link. Returns the existing code if the URL was already shortened. Supports an optional custom code. Rate limited to 10 requests/minute and 70 requests/hour per IP.
| Field | Type | Notes |
|---|---|---|
| url | string* | Full URL including http:// or https:// |
| custom_code | string | Optional, 3–20 chars, a–z 0–9 - _ |
POST /shorten
Content-Type: application/json
{ "url": "https://example.com/very/long/path", "custom_code": "my-link" }
// 201 — created
{ "success": true, "existing": false, "short_code": "my-link",
"short_url": "https://…/my-link", "permanent": true }
// 200 — already existed
{ "success": true, "existing": true, "short_code": "aB3xYz",
"short_url": "https://…/aB3xYz", "permanent": true }
// 409 — custom code taken
{ "error": "Custom code already exists" }
// 429 — rate limited
{ "error": "Too many requests",
"message": "Too many links created from this address. Please try again later." }
GET
/:code
Redirect
Shows a Cloudflare Turnstile human-verification page. After successful verification, the visitor is redirected to the original URL. Link resolution uses the in-memory cache, edge cache, KV, then the database. Returns a 404 page if the code is not found.
GET
/health
Simple health check. Returns {"ok": true}.