Hi
Product
Features
Security
Difference
Limits
FAQ
Pricing
Doc & Api
Get started free
NEXT-GEN LINK INFRASTRUCTURE

Stop guessing.
Start improving.

Deploy custom domains, ISO country routing, A/B split testing, PathLock™ PIN gates, and deterministic revenue attribution in under two minutes.

Get startedAccess our plans
Platform
  • Country & Device Routing
  • Weighted A/B Testing
  • Revenue Attribution (EPC)
  • Dynamic QR Studio
Security & Access
  • PathLock™ PIN Protection
  • Branded URL Masking
  • Click Limits & Expiration
  • Custom OpenGraph Cards
Developers
  • REST API & SDK Quickstart
  • Real-Time Click Telemetry
  • Signed Webhooks & Events
  • Full Documentation Hub
Legal & Trust
  • Privacy Policy (GDPR)
  • Terms of Service
  • No-Refund Policy
  • Dashboard Overview
LShorter Logo
LShorter© 2026 LShorter Inc.
Built on Cloudflare Edge Network
All 310+ Cloudflare Edge PoPs Operational
Privacy•Terms•Refunds
LShorter Logo
LShorter
HiHiProductProductFeaturesFeaturesSecuritySecurityDifferenceDifferenceLimitsLimitsFAQFAQPricingPricing
Doc & ApiDoc & Api
SDK & API Reference
Endpoints REST, clés Bearer et SDK TypeScript
Routage intelligent & Géo
Ciblage pays, OS mobile et redirection Edge
PathLock™ & Sécurité
Protection par code PIN, expiration et masquage
Télémétrie & Analytics
Flux de clics en direct, attribution et webhooks
RESSOURCESDocumentation

Documentation

Get started
LShorter Logo
LShorter
All guides & documentation

Dynamic Routing & Edge Geolocation

Redirect visitors to contextual URLs based on their origin country or continent with ultra-low latency.

4 min read•Official Edge Documentation
Dynamic Routing & Edge Geolocation

Overview & Architecture

Geographic routing optimizes user experience and conversion rates by serving localized content (language, currency, catalog) by country or continent from a single shared link.

Rules evaluation happens directly at Cloudflare Edge nodes during DNS resolution and TLS handshake, ensuring average redirection times under 15 milliseconds without backend server round-trips.

Dynamic routing and geo targeting are exclusive to paid plans (Pro, Business, and Enterprise). Free tier links redirect unconditionally to the primary destination URL.

Key Principles

Core architectural pillars ensuring high performance, isolation, and security.

01Closest-to-User Resolution
The visitor's country and continent are detected from the CF-IPCountry Edge header with zero extra proxy latency.
02Permanent Fallback URL
If the visitor's country or continent does not match any specific rule, they are automatically routed to the default fallback URL.
03Country & Continent Targeting
Define rules for any 2-letter country code (e.g., US, UK, FR, DE, JP, CA, AU) or continent region.
SDK Integration

Implementation & SDK Examples

Ready-to-use TypeScript code snippets and configuration examples for your integrations.

1. Configuring Routing via SDK

Attach country-based redirection rules to an existing link:

set-geo-routing.ts
typescript
1234567891011
import { lshorter } from "@/lib/lshorter";
await lshorter.links.updateRouting("global-promo", {
fallbackUrl: "https://store.com/global",
rules: [
{ country: "US", targetUrl: "https://store.com/us/fall-sale" },
{ country: "GB", targetUrl: "https://store.com/uk/autumn-sale" },
{ country: "DE", targetUrl: "https://store.com/de/herbst-angebote" },
{ country: "FR", targetUrl: "https://store.com/fr/offres-automne" },
],
});
REST API Specification

API Endpoints & Reference

Direct HTTP request methods, parameters schema, authentication, and responses.

PATCH

Update Geographic Routing Rules

Bearer <API_KEY>60 to 1,400 req/min (by plan)
https://lsho.cc/api/v1/links/:id/routing

Configures or updates country-specific destination rules and global fallback URL for a given short link.

Path Parameters

ParameterTypeRequiredDescriptionExample
idstringRequiredThe short link ID or slug alias.global-promo

Request Body Parameters

ParameterTypeRequiredDescriptionExample
fallbackUrlstring (url)RequiredDefault URL used when visitor origin country has no matching rule.https://store.com/global
rulesobject[]RequiredArray of country mapping rules.[{"country": "US", "targetUrl": "https://store.com/us"}, {"country": "DE", "targetUrl": "https://store.com/de"}]
rules[].countrystring (ISO 3166-1 alpha-2)RequiredTwo-letter uppercase country code.US
rules[].targetUrlstring (url)RequiredTarget URL for visitors from this country.https://store.com/us/fall-sale

Request Examples

bash
123456789101112
curl -X PATCH "https://lsho.cc/api/v1/links/global-promo/routing" \
-H "Authorization: Bearer $LSHORTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fallbackUrl": "https://store.com/global",
"rules": [
{ "country": "US", "targetUrl": "https://store.com/us/fall-sale" },
{ "country": "GB", "targetUrl": "https://store.com/uk/autumn-sale" },
{ "country": "DE", "targetUrl": "https://store.com/de/herbst-angebote" },
{ "country": "FR", "targetUrl": "https://store.com/fr/offres-automne" }
]
}'

Response Payload

200 OKRouting configuration deployed immediately to all Edge nodes.
response-200.json
json
12345678
{
"slug": "global-promo",
"routingEnabled": true,
"fallbackUrl": "https://store.com/global",
"rulesCount": 4,
"activeCountries": ["US", "GB", "DE", "FR"],
"updatedAt": "2026-09-17T12:15:00.000Z"
}

Possible Error Responses

HTTP StatusError CodeDescription
400INVALID_COUNTRY_CODECountry code must be a valid 2-letter uppercase ISO 3166-1 alpha-2 string.
403PLAN_UPGRADE_REQUIREDDynamic routing and geo targeting require an active paid subscription (Pro, Business, or Enterprise).
404LINK_NOT_FOUNDNo link found matching the provided slug or ID.

Applied Rules Confirmation

Structure returned after updating geographic routing rules:

response.json
json
12345678
{
"slug": "global-promo",
"routingEnabled": true,
"fallbackUrl": "https://store.com/global",
"rulesCount": 4,
"activeCountries": ["US", "GB", "DE", "FR"],
"updatedAt": "2026-09-17T12:15:00.000Z"
}

Recommended Best Practices

Expert tips to maximize performance, resilience, and link security.

Recommendation 01

Ensure your fallback URL is always functional and globally accessible.

Recommendation 02

To test your rules in staging without a VPN, pass the X-Override-Country: US HTTP header in your test requests.

Recommendation 03

Regularly review your unrouted countries in the real-time telemetry dashboard to add high-converting regions.

Previous guideQuickstart & REST API ReferenceNext guideAdvanced Security & PIN Code Protection

Related Guides & APIs

Quickstart & REST API Reference
Quickstart & REST API Reference
Integrate intelligent edge link shortening, real-time analytics, and conversion tracking with our high-performance REST API and TypeScript SDK.
Read guide & API
Advanced Security & PIN Code Protection
Advanced Security & PIN Code Protection
Protect confidential documents, pitch decks, and private links with a 4-digit PIN code verified on the fly.
Read guide & API