Link Pack API Documentation
Everything you need to integrate Link Pack into your application. Create short links, manage traffic routing, and track analytics with our comprehensive API.
Getting Started
1. Create Account & Subscribe
Sign up with email and password to start your 14-day free trial. After the trial, activate the $9 USD/month plan to unlock unlimited short links, advanced analytics, traffic routing, and full API access.
2. Generate API Key
In the dashboard, open the API Key card and click "Generate" or "Rotate". Store the key securely—you'll use it as a Bearer token for every API request.
Rate Limit: 10 requests/second per API key
API Reference
/api/v1/shorten
Create a new short link. Returns the link ID, short code, and full short URL.
curl -X POST https://linkpack.cc/api/v1/shorten \
-H "Authorization: Bearer lp_yourKey" \
-H "Content-Type: application/json" \
-d '{"longUrl":"https://example.com/launch"}'Response:
{
"id": "uuid",
"shortCode": "abc123",
"shortUrl": "https://linkpack.cc/abc123",
"longUrl": "https://example.com/launch"
}/api/v1/link/:id
Update an existing link with advanced features like UTM parameters, traffic routing, and retargeting scripts.
curl -X PATCH https://linkpack.cc/api/v1/link/<id> \
-H "Authorization: Bearer lp_yourKey" \
-H "Content-Type: application/json" \
-d '{
"long_url": "https://example.com/destination",
"utm_source": "newsletter",
"utm_medium": "email",
"utm_campaign": "summer_sale",
"traffic_routing": [
{
"id": "geo-us",
"condition": "geo",
"value": "US,CA",
"destination": "https://example.com/us-version"
}
]
}'/api/v1/stats/:shortCode
Get comprehensive analytics for a short link. Supports optional date range filtering via query parameters.
# All-time stats
curl https://linkpack.cc/api/v1/stats/abc123 \
-H "Authorization: Bearer lp_yourKey"
# Filtered by date range
curl "https://linkpack.cc/api/v1/stats/abc123?startDate=2024-01-01&endDate=2024-01-07" \
-H "Authorization: Bearer lp_yourKey"Query Parameters:
startDate- Filter from date (YYYY-MM-DD)endDate- Filter to date (YYYY-MM-DD)
/api/v1/link/:id
Delete a link and clear its cache. Use the id returned from the shorten call.
curl -X DELETE https://linkpack.cc/api/v1/link/<id> \
-H "Authorization: Bearer lp_yourKey"Traffic Routing
Traffic routing lets you redirect users to different URLs based on conditions. Rules are evaluated in order, and the first match wins.
Geographic (geo)
Redirect based on country codes.
Format: "US,CA,GB" (comma-separated 2-letter ISO codes)
Device (device)
Redirect based on device type.
Values: "Mobile", "Tablet", or "Desktop"
Referrer (referer)
Redirect based on referring domain.
Example: "google.com"
Time (time)
Redirect based on time of day.
Format: "09:00-17:00" (24-hour format, start-end)
Percentage (percentage)
A/B testing with percentage splits.
Requires: percentage field (0-100). Total across all percentage routes must not exceed 100%.
Analytics
The analytics API returns comprehensive data about link performance, including daily trends, geographic distribution, device types, and referrer sources.
Response Structure
{
"link": {
"id": "uuid",
"longUrl": "https://example.com",
"shortCode": "abc123"
},
"totalClicks": 150,
"dateRange": {
"startDate": "2024-01-01",
"endDate": "2024-01-07",
"filtered": true
},
"daily": [
{ "date": "2024-01-01", "clicks": 20 },
{ "date": "2024-01-02", "clicks": 25 }
],
"countries": [
{ "country": "US", "clicks": 80 },
{ "country": "CA", "clicks": 30 }
],
"devices": [
{ "device": "Mobile", "clicks": 90 },
{ "device": "Desktop", "clicks": 60 }
],
"referers": [
{ "referer": "google.com", "clicks": 50 },
{ "referer": "Direct", "clicks": 40 }
]
}Advanced Features
UTM Parameters
UTM parameters are automatically appended to destination URLs for analytics tracking. All five standard parameters are supported:
utm_source- Traffic source (e.g., "google", "newsletter")utm_medium- Marketing medium (e.g., "email", "cpc", "social")utm_campaign- Campaign name (e.g., "summer_sale")utm_term- Search term (for paid search)utm_content- Content identifier (e.g., "logolink", "textlink")
Retargeting Scripts
Inject tracking pixels and marketing scripts before redirecting users. Scripts can be placed in <head> or <body> sections.
Supported formats: Full HTML script tags, URLs (automatically wrapped), or inline JavaScript code.
Redirect Behavior
When a user visits a short link, Link Pack:
- Evaluates traffic routing rules (first match wins)
- Appends UTM parameters to the destination URL
- Injects retargeting scripts if configured (serves HTML page)
- Otherwise performs a 307 redirect
- Logs click with IP, country, device, browser, and referrer data
Error Handling
All API endpoints return appropriate HTTP status codes with descriptive error messages.
Success
Request completed successfully
Bad Request
Validation errors or invalid input
Unauthorized
Invalid or missing API key
Not Found
Link doesn't exist or doesn't belong to user
Rate Limit Exceeded
Too many requests (limit: 10 req/s)
Internal Server Error
Server-side error occurred
Error responses include a descriptive error field and optional details for validation errors.