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.
Create a Short Link
POST /api/shorten
Creates a new short link.
Request Body (JSON)
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | The original, long destination URL you want to shorten. |
alias | string | No | A custom alias for the link. If omitted, a random 7-character string is generated. |
domain | string | No | Your verified custom domain. Defaults to short.ly. |
expiresAt | string (ISO 8601) | No | A 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
urlfield, or invalid domain provided. - 401 Unauthorized: Missing or invalid API key.
- 409 Conflict: The requested
aliasis already in use. - 500 Internal Server Error: Something went wrong on our end.