Shortly

API Reference

Integrate Shortly programmatically into your own applications using our REST API.

Shortly provides a robust, low-latency REST API that allows you to generate short links programmatically. This is perfect for integrating link shortening directly into your product, automated SMS campaigns, or custom internal tools.

Authentication

To use the API, you must first generate an API key from the API Keys section of your Dashboard.

All API requests must be authenticated using a standard Bearer token in the Authorization header.

Authorization: Bearer <YOUR_API_KEY>

Security Note: Keep your API keys secure. Do not expose them in client-side code (like frontend JavaScript). If a key is compromised, you can revoke it immediately from the dashboard.


POST /api/shorten

Creates a new short link.

Request Body (JSON)

FieldTypeRequiredDescription
urlstringYesThe original, long destination URL you want to shorten.
aliasstringNoA custom alias for the link. If omitted, a random 7-character string is generated.
domainstringNoYour verified custom domain. Defaults to short.ly.
expiresAtstring (ISO 8601)NoA date and time when the link should automatically expire and stop redirecting.

Example Request

curl -X POST https://short.ly/api/shorten \
  -H "Authorization: Bearer sk_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://www.verylongdomain.com/marketing/campaign-2026",
    "alias": "summer26",
    "domain": "go.yourbrand.com"
  }'

Successful Response (201 Created)

{
  "id": "clkj123450000abcde",
  "shortUrl": "https://go.yourbrand.com/summer26",
  "originalUrl": "https://www.verylongdomain.com/marketing/campaign-2026",
  "alias": "summer26",
  "createdAt": "2026-06-05T12:00:00.000Z",
  "expiresAt": null
}

Error Responses

  • 400 Bad Request: Missing required url field, or invalid domain provided.
  • 401 Unauthorized: Missing or invalid API key.
  • 409 Conflict: The requested alias is already in use.
  • 500 Internal Server Error: Something went wrong on our end.

On this page