Skip to content

URL Endpoints

URL endpoints are grouped under:

/api/v1/urls

There are two modes:

  1. Public shortening (no auth required)
  2. Private URL management (auth required via Bearer token or X-API-Key)

Create a short URL anonymously (or linked to user if authenticated).

{
"originalUrl": "https://example.com/some/long/path"
}
{
"message": "URL shortened successfully",
"shortUrl": "https://korta.click/abc12",
"shortId": "abc12"
}

Create a private short URL for the authenticated user.

{
"originalUrl": "https://example.com/some/long/path",
"shortId": "abc12"
}

Notes:

  • shortId is optional.
  • Max length for custom shortId: 5 chars.
{
"id": 1,
"originalUrl": "https://example.com/some/long/path",
"shortId": "abc12",
"clicks": 0,
"userId": 1,
"createdAt": "2026-02-15T10:00:00.000Z",
"updatedAt": "2026-02-15T10:00:00.000Z"
}

Return all links for the authenticated user.

[
{
"id": 1,
"originalUrl": "https://example.com",
"shortId": "abc12",
"clicks": 7,
"userId": 1,
"createdAt": "2026-02-15T10:00:00.000Z",
"updatedAt": "2026-02-15T10:20:00.000Z"
}
]

PATCH /urls/:shortId (protected, owner only)

Section titled “PATCH /urls/:shortId (protected, owner only)”

Update an existing short URL.

{
"newShortId": "xyz99",
"originalUrl": "https://example.com/new-target"
}

Notes:

  • At least one field is required: newShortId or originalUrl.
  • You can update one field or both in a single request.
{
"id": 1,
"originalUrl": "https://example.com/new-target",
"shortId": "xyz99",
"clicks": 7,
"userId": 1,
"createdAt": "2026-02-15T10:00:00.000Z",
"updatedAt": "2026-02-15T10:30:00.000Z"
}

Empty body ({}) is rejected:

{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed"
}

DELETE /urls/:shortId (protected, owner only)

Section titled “DELETE /urls/:shortId (protected, owner only)”

Delete a short URL.

{
"message": "URL deleted successfully"
}
  • GET /:shortId (server root route) redirects to original URL and increments click count.
  • There is also GET /api/v1/urls/redirect/:shortId.