> ## Documentation Index
> Fetch the complete documentation index at: https://docs.glider.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# tRPC System IP Detection API

> Manual country detection for the request IP

The manual IP detection procedure is available on the tRPC base endpoint:

* Base endpoint: `POST /v1/trpc`
* Procedure: `system.ipDetection`
* Auth: public
* Rate tier: `Tier2`

## Response Notes

`system.ipDetection` performs an async country lookup for the request IP using
`country.is`.

* `countryCode`: manually detected ISO-2 country code
* `requestCountryCode`: Cloudflare-derived request country code from the incoming
  request
* `provider`: always `country.is`
* `ipDebug`: raw IP-related request headers plus the derived client IP, country
  code, and region code used by the backend
* `status`:
  * `detected`
  * `missing_ip`
  * `lookup_failed`
  * `invalid_response`

`ipDebug` is returned specifically for support and debugging so callers can compare
the raw forwarded headers against the derived values the backend used.

## Intended Usage

This procedure is designed to provide an additive country signal for
restriction-aware routes.

1. Call `system.ipDetection`
2. Read `countryCode`
3. Send it back to routes such as `assets.searchForTokens` as
   `manualCountryCode`

The backend evaluates both the Cloudflare request country and the manual country
when both are present, and keeps the stricter restriction result.

## Example Response Shape

```json theme={null}
{
  "countryCode": "RU",
  "requestCountryCode": "SE",
  "provider": "country.is",
  "status": "detected",
  "ipDebug": {
    "rawHeaders": {
      "cf-connecting-ip": "203.0.113.7",
      "x-forwarded-for": "203.0.113.7, 10.0.0.4",
      "x-real-ip": "203.0.113.7",
      "cf-ipcountry": "SE",
      "cf-region-code": "AB",
      "cf-ipcity": "Stockholm",
      "cf-ipcontinent": "EU",
      "cf-iplatitude": "59.3293",
      "cf-iplongitude": "18.0686",
      "cf-region": "Stockholm County",
      "cf-metro-code": null,
      "cf-postal-code": "11122",
      "cf-timezone": "Europe/Stockholm"
    },
    "derivedClientIp": "203.0.113.7",
    "derivedCountryCode": "SE",
    "derivedRegionCode": "AB"
  }
}
```
