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 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"
}

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
}

Retrieve all links for the authenticated user.

GET /v1/links?page=1&limit=20&search=marketing

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
limitintegerItems per page (default: 20, max: 100)
searchstringSearch by title, alias, or URL
sortstringSort field (created_at, clicks)
orderstringSort 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 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.


Permanently delete a link.

DELETE /v1/links/{id}

Response

{
  "success": true,
  "message": "Link deleted successfully"
}

Error Responses

StatusErrorDescription
400invalid_urlURL format is invalid
400alias_takenCustom alias already in use
404not_foundLink does not exist
429rate_limitedToo many requests