Enable Dark Mode!

Welcome to CutLink API!

This API allows you to shorten long URLs and redirect users from a short slug to the original URL. Below you'll find details on how to interact with the available endpoints.

API Endpoints:

1. Shorten a URL

POST /shorten

Description: Creates a new short URL for the provided long URL. You can optionally provide a custom slug.

Request Body (JSON):

{
    "long_url": "https://www.example.com/very/long/url/path",
    "custom_slug": "my-short-link" // Optional: provide a desired custom slug
}

Response Body (JSON - Success 200 OK):

{
    "short_url": "YOUR_BASE_URL/s/generated_slug_or_custom_slug"
}

Error Response (JSON):

{
    "error": "Error message details, e.g., Invalid URL provided"
}

2. Redirect Short URL

GET /s/{short_slug}

Description: Redirects to the original long URL associated with the given short slug.

Response: 302 Found (Redirects to the original URL).

Error Response (JSON - 404 Not Found):

{
    "error": "Link not found or expired"
}

3. Health Check

GET /health

Description: Checks the operational status of the API server. Useful for monitoring.

Response: Plain text "OK" (200 OK).

OK