Geo & A/B routing
One path, several destinations: country/city overrides and weighted A/B arms.
Both are sub-resources of a link, with the same scope ladder as links
themselves — read takes links:read, write takes links:write, delete takes
links:delete.
Geo rules
One country override: visitors from this country resolve to a different
destination. country_code is an uppercase ISO-2 code, normalized
server-side. city narrows the row to one metro (the CDN's label, e.g.
Berlin); empty means the whole country. The redirect prefers the city row
over the country row. Country rows need the GeoRouting feature; city rows
need CityAnalytics.
# List
curl https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/geo-rules \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN"
# { "rules": [{ "country_code": "DE", "city": "", "destination_url": "https://example.com/de-sale" }] }
# Set a country row
curl -X POST https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/geo-rules \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"country_code": "DE", "destination_url": "https://example.com/de-sale"}'
# 201 { "rule": { "country_code": "DE", "city": "", "destination_url": "https://example.com/de-sale" } }
# Narrow one city inside it
curl -X POST https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/geo-rules \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"country_code": "DE", "city": "Berlin", "destination_url": "https://example.com/de-berlin"}'
# Delete the country row — or ?city=Berlin to delete just the city row
curl -i -X DELETE "https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/geo-rules/DE?city=Berlin" \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN"
# 204, no body
GET on geo rules is not paginated, and does not need to be: a link holds
at most 200 geo rules, so the list is always complete. At the bound,
re-posting a country/city that already has a row re-points it, and posting a
new one is 400 / validation_failed — the server never silently drops a
rule you asked for.
A/B variants
Weighted destination arms. weight is a relative share among the variants
matching a visitor, not a percentage — 60 and 40 split 60/40, and so do
600 and 400. Targeting columns are all-or-nothing per row: empty means
"any", so "iOS visitors in France" is one row, and a narrower matching row
automatically wins over a broader one. starts_at / ends_at bound the
window an arm serves in; unset on either side means unbounded.
# List
curl https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/variants \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN"
# { "variants": [{ "id": "...", "link_id": "...", "destination_url": "...", "weight": 60, ... }] }
# Add an arm for French iOS traffic, October only
curl -X POST https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/variants \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"destination_url": "https://example.com/spring-b",
"weight": 40,
"country_code": "FR",
"os": "iOS",
"starts_at": "2026-10-01T00:00:00Z",
"ends_at": "2026-10-31T23:59:59Z"
}'
# 201 { "variant": { "id": "...", "link_id": "...", "destination_url": "...", "weight": 40,
# "country_code": "FR", "device": "", "os": "iOS", "browser": "",
# "language": "", "starts_at": "...", "ends_at": "..." } }
# Remove it
curl -i -X DELETE https://lsg.bio/api/v1/links/6cb5cd5b-a2c8-4238-b548-b25991bc0559/variants/a3bb1893-5c9e-4f1c-9b2d-7e6f5a4b3c2d \
-H "Authorization: Bearer lsgbio_YOUR_TOKEN"
# 204, no body
The full request body accepts destination_url, weight, country_code,
device, os, browser, language, starts_at, and ends_at; the
response echoes the stored variant with its id and link_id.
GET on variants is not paginated, and does not need to be: a link holds at
most 50 variants, so the list is always complete. At the bound, adding a
further arm is 400 / validation_failed; delete one first.