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/v1

Quick Start

  1. Sign up for a URLcut.ai account at our pricing page
  2. Generate an API key from your dashboard settings
  3. Make your first request using the examples below
Tip: Start with the free tier to test the API. Upgrade anytime for higher rate limits and advanced features.

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header with every request.

Header Authorization
Authorization: Bearer YOUR_API_KEY

Example Request with Authentication

cURL Authenticated Request
curl -X GET "https://api.urlcut.ai/v1/links" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"
Security: Never expose your API key in client-side code. Always make API calls from your server.

API Endpoints

POST /links Create Short URL

Create 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"]
  }
}
POST /slugs/generate Generate Slug

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

Code Examples

Complete examples in popular programming languages to help you integrate quickly.

Python
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-article
JavaScript (Node.js)
const 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
<?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 urlcut
Node.js SDK

Official Node.js library with TypeScript support.

npm install @urlcut/sdk
PHP SDK

Official PHP library via Composer.

composer require urlcut/urlcut-php
Ruby Gem

Community-maintained Ruby gem.

gem install urlcut

Frequently Asked Questions

Yes, we offer a free tier with 100 requests per hour. This is perfect for testing and small projects. Paid plans offer higher limits and additional features.

Absolutely! The /slugs/generate endpoint allows you to convert any text to an SEO-friendly slug without creating a short URL. This is useful for CMS integrations and content platforms.

Custom slugs can contain lowercase letters (a-z), numbers (0-9), and hyphens (-). They must be between 3 and 50 characters long. Slugs are case-insensitive.

Check the X-RateLimit-Remaining header in each response. When approaching the limit, implement exponential backoff. If you consistently hit limits, consider upgrading your plan.

No, slugs cannot be changed after creation to maintain link integrity. You can update other properties like the destination URL, title, tags, and expiration date. To change a slug, create a new short URL and delete the old one.

Yes, Pro and Enterprise plans include webhook support. You can receive notifications for events like link clicks, expiration, and usage thresholds. Configure webhooks in your dashboard settings.

Ready to Get Started?

Create your free API key and start building with URLcut.ai today.

View API Plans Contact Sales