A URL shortener API lets you create, manage, and track short links programmatically — without logging into a dashboard for every link. In 2026, URL shortener APIs have become standard infrastructure for email campaigns, QR codes, referral programs, and attribution tracking. This guide covers how URL shortener APIs work, what to look for when choosing one, and how to use CDNZero's URL shortener API to create branded links at scale.
Why Use a URL Shortener API Instead of a Dashboard?
Manual link creation works for occasional use. When you're generating hundreds or thousands of links — unique per-recipient referral links, campaign UTM variants, A/B tested landing page links, or time-expiring promotion codes — a URL shortener API is the only practical approach. APIs also enable automation: links created on order confirmation, personalized URLs in email sequences, or links generated dynamically based on user attributes.
The technical case for an edge-cached URL shortener API is stronger than it sounds. Redirect latency directly affects user experience: a 200ms redirect before reaching your landing page is noticeable, especially on mobile. CDNZero resolves redirects at the nearest edge node (under 10ms), meaning the shortener adds essentially no perceivable delay between click and landing page.
Key Features to Evaluate in a URL Shortener API
Not all URL shortener APIs are equal. The features that matter for production use: custom domain support (yoursite.co/link vs generic short domain), analytics per link (clicks, geography, device, referrer), bulk creation endpoint (create hundreds of links in one request), link expiration (set TTL for time-limited offers), geo-targeted redirects (send users to different URLs based on country), and rate limits that match your volume requirements.
Bitly's API starts at $35/month for 500 branded links. Short.io's API starts at $19/month. CDNZero includes the URL shortener API on its Starter plan ($5/month) with custom domains, full analytics, geo-targeting, and no link creation caps — or on the free plan with the `cdnz.to` default domain.
CDNZero URL Shortener API: Authentication
CDNZero's URL shortener API uses Bearer token authentication. Generate your API key in the dashboard under Settings > API Keys. Include it in all requests as an Authorization header.
Creating a Short Link via API (curl, JavaScript, Python)
The core endpoint is POST /api/v1/links. Required fields: `destination` (the long URL). Optional fields: `slug` (custom path, e.g. 'summer-sale'), `domain` (your custom domain), `expires_at` (ISO 8601 datetime), `password` (protect the link), `geo_rules` (array of country/URL pairs for geo-targeted redirects), and `tags` (for organizing links by campaign). Example with curl: ``` curl -X POST https://api.cdnzero.com/v1/links \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"destination":"https://yoursite.com/summer-sale","slug":"summer26","domain":"go.yoursite.com"}' ``` Response: `{ "short_url": "https://go.yoursite.com/summer26", "id": "lnk_abc123", "clicks": 0 }` JavaScript (fetch): ```javascript const res = await fetch('https://api.cdnzero.com/v1/links', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ destination: 'https://yoursite.com/page', slug: 'launch' }) }); const link = await res.json(); console.log(link.short_url); // https://cdnz.to/launch ```
Bulk Link Creation for Campaigns
For email campaigns requiring unique-per-recipient links, use the bulk endpoint: POST /api/v1/links/bulk. Send an array of link objects — up to 1,000 per request. CDNZero processes them in parallel and returns all created links in a single response. Each link can have a unique slug, destination, expiration, and tag for attribution. A practical use case: an e-commerce team sending 5,000 personalised reactivation emails, each with a unique discount link that expires in 72 hours. The bulk API creates all 5,000 links in under 2 seconds. When a recipient clicks their link, CDNZero registers the click with full attribution (geographic location, device, referral), then redirects to their personalised landing page — all resolved at the edge in under 10ms.
Retrieving Analytics via API
Link analytics are available at GET /api/v1/links/{id}/analytics. Query parameters: `start` and `end` (ISO 8601 date range), `granularity` (hour, day, week), and `dimensions` (country, device, browser, referrer). The response includes a time-series of clicks, top countries, device breakdown, and referral sources. For building custom dashboards, the analytics API supports pagination and can be polled on a schedule. Enterprise plans include webhook delivery of analytics events, removing the need for polling entirely.
Geo-Targeted Redirects
The `geo_rules` field accepts an array of country-code/URL pairs. When a user clicks the short link, CDNZero detects their country at the edge (from IP geolocation, resolved in under 1ms) and redirects to the matching URL. If no rule matches, the default `destination` URL is used. Example: a mobile app with separate App Store and Google Play listings for different regions. Set `destination` to the App Store link, then add a `geo_rules` entry sending Android-majority markets (ID, IN, PK, BD) to the Play Store URL. One short link handles both audiences correctly with no server-side logic required.
Link Expiration and Password Protection via API
Set `expires_at` to an ISO 8601 datetime to create time-limited links. After the expiration, the short link returns a 410 Gone response. This is useful for flash sales, limited-time offers, and event registration links. `password` accepts a plain-text string. CDNZero hashes and stores it securely. When a recipient clicks the link, they're shown a password entry page. Password-protected links work well for private sharing scenarios: client deliverables, internal resources, and beta access links that shouldn't be forwarded.
Rate Limits and Scaling
CDNZero's URL shortener API rate limits by plan: Free (cdnz.to domain, 100 link creations/day), Starter (1,000/day, custom domain), Growth (10,000/day), Pro (100,000/day), Enterprise (unlimited with dedicated rate limit negotiation). For bulk campaigns, the bulk endpoint counts as one request regardless of how many links are in the array — so a batch of 500 links uses one API call against your rate limit quota.
The redirect infrastructure itself has no rate limit — redirects are served from edge cache and can handle millions of clicks per second without throttling. The rate limit applies only to the management API (creating, updating, deleting links), not to the redirect serving layer.
Getting Started: Free URL Shortener API
CDNZero's free plan includes API access on the Starter tier and above ($5/month), with the default `cdnz.to` domain available for testing on the free plan. To get started: sign up at app.cdnzero.com, navigate to Settings > API Keys, generate a key, and make your first POST /api/v1/links request. Full API documentation is available at cdnzero.com/docs. For teams evaluating options, CDNZero's URL shortener API provides the best combination of redirect speed (edge-cached), analytics depth, custom domain support, and pricing among current providers.