Country rules

After this page, a link sends people in the countries you choose to their own web page, while opening the app and sending people to the store work as before.

On this page 6
  1. 1. Add a rule
  2. 2. Or do it with the API
  3. 3. Test it as a visitor from another country
  4. Where the country comes from
  5. Common errors
  6. Next steps
Time
About 5 minutes
You need
A link, in the dashboard or created with a secret key, and an https page for each country group
Works on
Dashboard, or any server through the REST API

One link on a global campaign can send India to your Indian store page and Bangladesh to its own page, without separate links.

Country rules only change web and fallback destinations: where someone lands in a browser. That is the computer destination, the per-platform fallbacks, the link's destination when it opens as a web page, and your workspace fallback. Opening your app on the right screen, and sending people to Google Play or the App Store, are unchanged, so deep links and deferred deep links behave exactly as before.

1. Add a rule

In Dashboard → Links, open the link's edit panel, find Country rules and press Add a country rule. Fill in:

  • Countries: 2-letter country codes separated by commas, like IN, BD.
  • Web page: the https page for people in those countries.

A link can have up to 5 rules, each with up to 50 countries. The first rule that lists the visitor's country wins. Save the link.

You should see: the rule saved on the link, and "Rule 1" with your countries and page when you open the panel again.

2. Or do it with the API

POST /v1/links, POST /v1/links/batch and PATCH /v1/links/{slug} accept countryRules, a list of { countries, url }. A PATCH replaces all of a link's rules; null or [] removes them.

Terminal
curl -X PATCH https://strait.link/v1/links/summer \
  -H "Authorization: Bearer $SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "countryRules": [
      { "countries": ["IN"], "url": "https://shop.example.com/in/summer" },
      { "countries": ["BD", "NP"], "url": "https://shop.example.com/south-asia/summer" }
    ]
  }'

Country codes are trimmed and upper-cased for you. Every rule's page passes the same phishing and malware check as the link's destination.

You should see: 200 with the link, its countryRules listing both rules.

3. Test it as a visitor from another country

In the dashboard Playground, type a code in Visitor's country (optional). Or ask GET /v1/simulate, which records nothing:

Terminal
curl "https://strait.link/v1/simulate?url=https://hilltop.strait.link/summer&ua=desktop&country=IN" \
  -H "Authorization: Bearer $SECRET_KEY"

You should see: "countryRule": true and location set to your India page for IN, and the usual destination for a country without a rule. On a phone with your app installed, the decision is still to open the app.

Where the country comes from

The country is the one Cloudflare gives the request, from the visitor's network address. It makes this decision, and since 5 November 2026 it is also stored with the tap as its 2-letter code, so analytics can split taps by country (GET /v1/analytics?group=country). Never a city or a precise location. When the country can't be told, no rule applies and the usual destination is used.

Common errors

  • 400 "countryRules[0].countries: "IND" is not a 2-letter country code". Use ISO 3166-1 two-letter codes: IN, not IND or India.
  • 400 "countryRules allows at most 5 rules". Combine countries that share a page into one rule.
  • A rule doesn't change where the app opens. That is by design: rules only replace web and fallback destinations. To send a country to a different screen in the app, use a separate link.

Next steps