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
| Field | Type | Required | Description |
|---|---|---|---|
ip | string | Yes | IPv4 or IPv6 address to locate. |
country | string | Yes | Country you expect, as a two-letter ISO code such as IN. Case is ignored. |
state | string | No | State 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
| Field | Type | Description |
|---|---|---|
valid_user | boolean | True when the address is inside the country, and state if given, you expected. |
ip | string | The address that was checked. |
country | string | Country the address is in. |
country_code | string | Two-letter country code. |
state | string | State the address is in. |
state_code | string | State code. |
city | string | City. |
zip_code | string | Pincode. |
timezone | string | Time zone. |
latitude | number | Approximate latitude. |
longitude | number | Approximate longitude. |
asn | string | Autonomous system number. |
riskip | boolean | True 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.