Smart Routing Rules
Smart routing lets you send different visitors to different destinations based on conditions like country, device type, time of day, or traffic percentage.
Creating a Link with Routing Rules
curl -X POST https://xqr.co/api/v1/links \ -H "Authorization: Bearer $XQR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "url": "https://example.com/default", "custom_slug": "global-promo", "routing_rules": [ { "destination": "https://example.de/promo", "priority": 1, "conditions": { "countries": ["DE", "AT", "CH"], "country_mode": "include" } }, { "destination": "https://m.example.com/promo", "priority": 2, "conditions": { "device_types": ["mobile"] } }, { "destination": "https://example.com/night-offer", "priority": 3, "conditions": { "hours": { "start": 20, "end": 6 } } } ] }'Rule Evaluation
Rules are evaluated in priority order (lowest number first). The first matching rule wins. If no rules match, the default url is used.
Available Conditions
| Condition | Description |
|---|---|
countries + country_mode | Filter by ISO country codes. include = only these countries; exclude = all except these |
device_types | Array of mobile, tablet, desktop |
hours | Time range (start and end in 24h format). Wraps around midnight. |
percentage | Send a percentage of traffic to this destination (A/B testing) |
expires_at | Rule is active until this ISO datetime |
A/B Testing Example
Split traffic 50/50 between two landing pages:
{ "url": "https://example.com/page-a", "routing_rules": [ { "destination": "https://example.com/page-b", "priority": 1, "conditions": { "percentage": 50 } } ]}Then use analytics to compare performance.
Was this page helpful?
Thanks for your feedback!