API Reference
Links API
Create and manage short links programmatically
The Links API allows you to create, retrieve, update, and delete short links. All endpoints require authentication.
Create a Link
Create a new short link.
POST /v1/links
{
"url": "https://example.com/my-long-url",
"alias": "my-custom-alias", // optional
"title": "My Link Title", // optional
"expires_at": "2024-12-31T23:59:59Z", // optional
"password": "secret123", // optional
"utm_source": "api", // optional
"utm_medium": "integration", // optional
"utm_campaign": "launch" // optional
}Response
{
"id": "link_abc123",
"short_url": "https://shrtylnk.co/my-custom-alias",
"original_url": "https://example.com/my-long-url",
"alias": "my-custom-alias",
"title": "My Link Title",
"clicks": 0,
"created_at": "2024-01-15T10:30:00Z",
"expires_at": "2024-12-31T23:59:59Z"
}Get a Link
Retrieve details about a specific link.
GET /v1/links/{id}Response
{
"id": "link_abc123",
"short_url": "https://shrtylnk.co/my-custom-alias",
"original_url": "https://example.com/my-long-url",
"alias": "my-custom-alias",
"title": "My Link Title",
"clicks": 142,
"unique_clicks": 89,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T15:45:00Z",
"expires_at": "2024-12-31T23:59:59Z",
"has_password": true
}List Links
Retrieve all links for the authenticated user.
GET /v1/links?page=1&limit=20&search=marketingQuery Parameters
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
limit | integer | Items per page (default: 20, max: 100) |
search | string | Search by title, alias, or URL |
sort | string | Sort field (created_at, clicks) |
order | string | Sort order (asc, desc) |
Response
{
"data": [
{
"id": "link_abc123",
"short_url": "https://shrtylnk.co/abc123",
"original_url": "https://example.com/page",
"clicks": 142
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 45,
"total_pages": 3
}
}Update a Link
Update an existing link's properties.
PATCH /v1/links/{id}
{
"url": "https://example.com/new-destination",
"title": "Updated Title",
"expires_at": null // Remove expiration
}Response
Returns the updated link object.
Delete a Link
Permanently delete a link.
DELETE /v1/links/{id}Response
{
"success": true,
"message": "Link deleted successfully"
}Error Responses
| Status | Error | Description |
|---|---|---|
| 400 | invalid_url | URL format is invalid |
| 400 | alias_taken | Custom alias already in use |
| 404 | not_found | Link does not exist |
| 429 | rate_limited | Too many requests |