URL Slug API Documentation
Integrate intelligent URL slug generation and custom short links into your applications. RESTful API with comprehensive endpoints for automated link management.
Getting Started
The URLcut.ai API enables you to programmatically create short URLs with custom slugs, generate SEO-friendly slugs, and track link analytics. Our RESTful API uses standard HTTP methods and returns JSON responses.
Base URL
https://api.urlcut.ai/v1Quick Start
- Sign up for a URLcut.ai account at our pricing page
- Generate an API key from your dashboard settings
- Make your first request using the examples below
Authentication
All API requests require authentication using an API key. Include your API key in the
Authorization header with every request.
Authorization: Bearer YOUR_API_KEYExample Request with Authentication
curl -X GET "https://api.urlcut.ai/v1/links" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"API Endpoints
/links
Create Short URLCreate a new short URL with an optional custom slug. If no slug is provided, our AI will generate an intelligent, SEO-friendly slug based on the destination URL.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | The destination URL to shorten |
slug |
string | No | Custom slug (3-50 characters, alphanumeric and hyphens) |
title |
string | No | Title for the link (used for AI slug generation) |
expires_at |
string | No | ISO 8601 expiration date |
tags |
array | No | Array of tags for organization |
Example Request
curl -X POST "https://api.urlcut.ai/v1/links" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://example.com/blog/ultimate-guide-to-seo",
"slug": "seo-guide",
"title": "Ultimate SEO Guide",
"tags": ["marketing", "seo"]
}'Response
{
"success": true,
"data": {
"id": "lnk_abc123",
"short_url": "https://urlcut.ai/seo-guide",
"original_url": "https://example.com/blog/ultimate-guide-to-seo",
"slug": "seo-guide",
"title": "Ultimate SEO Guide",
"created_at": "2025-01-15T10:30:00Z",
"expires_at": null,
"clicks": 0,
"tags": ["marketing", "seo"]
}
}/slugs/generate
Generate SlugGenerate an SEO-friendly slug from text without creating a short URL. Useful for content management systems and blog platforms.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
text |
string | Yes | The text to convert to a slug |
separator |
string | No | Character to use as separator (default: "-") |
max_length |
integer | No | Maximum slug length (default: 50) |
lowercase |
boolean | No | Convert to lowercase (default: true) |
remove_stop_words |
boolean | No | Remove common stop words (default: false) |
Example Request
curl -X POST "https://api.urlcut.ai/v1/slugs/generate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "How to Create SEO-Friendly URLs in 2025",
"remove_stop_words": true,
"max_length": 40
}'Response
{
"success": true,
"data": {
"original_text": "How to Create SEO-Friendly URLs in 2025",
"slug": "create-seo-friendly-urls-2025",
"length": 29,
"suggestions": [
"seo-friendly-urls-2025",
"create-seo-urls-guide",
"seo-url-creation-2025"
]
}
}/links/{id}/stats
Get Link StatisticsRetrieve detailed analytics for a specific short link including clicks, geographic data, referrers, and device information.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string | The link ID or slug |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
period |
string | Time period: 24h, 7d, 30d, 90d, all (default: 30d) |
Example Response
{
"success": true,
"data": {
"link_id": "lnk_abc123",
"total_clicks": 1247,
"unique_clicks": 892,
"period": "30d",
"clicks_by_day": [...],
"top_countries": [
{"country": "US", "clicks": 523},
{"country": "UK", "clicks": 187}
],
"top_referrers": [
{"referrer": "twitter.com", "clicks": 312},
{"referrer": "linkedin.com", "clicks": 198}
],
"devices": {
"mobile": 654,
"desktop": 512,
"tablet": 81
}
}
}/links/{id}
Update LinkUpdate an existing short link's properties such as destination URL, expiration date, or tags. The slug cannot be changed after creation.
Request Body
| Parameter | Type | Description |
|---|---|---|
url |
string | New destination URL |
title |
string | Updated title |
expires_at |
string | New expiration date (ISO 8601) or null to remove |
tags |
array | Updated tags array |
active |
boolean | Enable/disable the link |
/links/{id}
Delete LinkPermanently delete a short link. This action cannot be undone. The slug will become available for reuse after deletion.
Example Request
curl -X DELETE "https://api.urlcut.ai/v1/links/lnk_abc123" \
-H "Authorization: Bearer YOUR_API_KEY"Response
{
"success": true,
"message": "Link deleted successfully"
}Code Examples
Complete examples in popular programming languages to help you integrate quickly.
import requests
API_KEY = "your_api_key"
BASE_URL = "https://api.urlcut.ai/v1"
def create_short_url(url, slug=None, title=None):
"""Create a short URL with optional custom slug."""
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
payload = {"url": url}
if slug:
payload["slug"] = slug
if title:
payload["title"] = title
response = requests.post(
f"{BASE_URL}/links",
headers=headers,
json=payload
)
return response.json()
# Usage
result = create_short_url(
url="https://example.com/my-long-article",
slug="my-article",
title="My Article Title"
)
print(result["data"]["short_url"])
# Output: https://urlcut.ai/my-articleconst axios = require('axios');
const API_KEY = 'your_api_key';
const BASE_URL = 'https://api.urlcut.ai/v1';
async function createShortUrl(url, options = {}) {
try {
const response = await axios.post(
`${BASE_URL}/links`,
{
url,
slug: options.slug,
title: options.title,
tags: options.tags
},
{
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
}
);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
throw error;
}
}
// Usage
createShortUrl('https://example.com/blog/post', {
slug: 'blog-post',
title: 'My Blog Post',
tags: ['blog', 'tech']
}).then(result => {
console.log(result.data.short_url);
});<?php
$apiKey = 'your_api_key';
$baseUrl = 'https://api.urlcut.ai/v1';
function createShortUrl($url, $slug = null, $title = null) {
global $apiKey, $baseUrl;
$payload = ['url' => $url];
if ($slug) $payload['slug'] = $slug;
if ($title) $payload['title'] = $title;
$ch = curl_init("$baseUrl/links");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
],
CURLOPT_POSTFIELDS => json_encode($payload)
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
// Usage
$result = createShortUrl(
'https://example.com/product/12345',
'cool-product',
'Cool Product'
);
echo $result['data']['short_url'];
// Output: https://urlcut.ai/cool-product
?>Error Handling
The API returns consistent error responses with HTTP status codes and detailed error messages.
Error Response Format
{
"success": false,
"error": {
"code": "SLUG_TAKEN",
"message": "The slug 'my-slug' is already in use",
"field": "slug"
}
}Common Error Codes
| HTTP Status | Error Code | Description |
|---|---|---|
400 |
INVALID_URL | The provided URL is not valid |
400 |
INVALID_SLUG | Slug contains invalid characters or length |
401 |
UNAUTHORIZED | Missing or invalid API key |
403 |
FORBIDDEN | API key lacks required permissions |
404 |
NOT_FOUND | The requested resource does not exist |
409 |
SLUG_TAKEN | The custom slug is already in use |
429 |
RATE_LIMITED | Too many requests, slow down |
500 |
INTERNAL_ERROR | Server error, please try again |
Rate Limits
API rate limits vary by plan. Rate limit information is included in response headers.
Rate Limit Headers
| Header | Description |
|---|---|
X-RateLimit-Limit |
Maximum requests allowed per hour |
X-RateLimit-Remaining |
Requests remaining in current window |
X-RateLimit-Reset |
Unix timestamp when the limit resets |
Rate Limits by Plan
Free
100
requests/hour
Pro
1,000
requests/hour
Enterprise
10,000+
requests/hour
SDKs & Libraries
Official and community SDKs to accelerate your integration.
Python SDK
Official Python library with async support.
pip install urlcutNode.js SDK
Official Node.js library with TypeScript support.
npm install @urlcut/sdkPHP SDK
Official PHP library via Composer.
composer require urlcut/urlcut-phpRuby Gem
Community-maintained Ruby gem.
gem install urlcutFrequently Asked Questions
Ready to Get Started?
Create your free API key and start building with URLcut.ai today.
View API Plans Contact Sales