API reference / Risk & Location

IP geo-fencing

Whether an IP resolves inside the expected country (ISO code) and optional state, with its location.

POST/v1/risk/geo-fence
Authentication
Bearer token
Scope
kyc:verify

Request body

FieldTypeRequiredDescription
ipstringYesIPv4 or IPv6 address to locate.
countrystringYesCountry you expect, as a two-letter ISO code such as IN. Case is ignored.
statestringNoState you expect, as a code of 1 to 3 letters or digits such as MH. Case is ignored.

Sample code

Set your key in the GRAPPI_API_KEY environment variable. Sample values are placeholders.

curl -sS -X POST 'https://grappi.ai/v1/risk/geo-fence' \
  -H "Authorization: Bearer $GRAPPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "ip": "203.0.113.10",
  "country": "IN",
  "state": "MH"
}'

Sample response

{
  "request_id": "req_01HZY3K8M2",
  "result": {
    "valid_user": true,
    "ip": "203.0.113.10",
    "country": "India",
    "country_code": "IN",
    "state": "Maharashtra",
    "state_code": "MH",
    "city": "Pune",
    "zip_code": "411001",
    "timezone": "Asia/Kolkata",
    "latitude": 18.52,
    "longitude": 73.85,
    "asn": "64500",
    "riskip": false
  }
}

Response fields

FieldTypeDescription
valid_userbooleanTrue when the address is inside the country, and state if given, you expected.
ipstringThe address that was checked.
countrystringCountry the address is in.
country_codestringTwo-letter country code.
statestringState the address is in.
state_codestringState code.
citystringCity.
zip_codestringPincode.
timezonestringTime zone.
latitudenumberApproximate latitude.
longitudenumberApproximate longitude.
asnstringAutonomous system number.
riskipbooleanTrue when the address is flagged as risky.

Errors

Every failure has the same shape. A call that fails on our side or at the data source is refunded to your wallet; a "no record found" answer is charged. See the error reference.