URL Shortener

POST a long http(s) url to get a short code stored in Cloudflare KV. Optional custom code and ttlDays. GET /api/v1/short/:code returns JSON. GET /api/v1/short/:code/go redirects. Same url twice returns the existing code.

View Docs

Parameters

url string Required

http or https url in the JSON body.

Example: https://example.com/some/long/path

code string

Optional custom slug, 3-32 chars. Letters, numbers, _ or -.

Example: lunch

ttlDays number

Optional expiry in days, 1 to 365.

Example: 30

Responses

200 OK Success
{
  "ok": true,
  "code": "lunch",
  "url": "https://example.com/some/long/path",
  "shortPath": "/api/v1/short/lunch/go",
  "infoPath": "/api/v1/short/lunch",
  "createdAt": "2026-10-04T04:00:00.000Z",
  "expiresAt": null,
  "existing": false
}
400 BAD_REQUEST url has to be http or https
404 NOT_FOUND unknown code
409 CONFLICT code is already taken