GeoNest - Location-Based Services
Overview
GeoNest is a REST API–based geofencing system. The mobile app talks to three GeoNest APIs and uses the device's native Android/iOS location and geofencing capabilities to detect movement.
Base URL
https://www.leadnest.ai
API Key Example-
gnk_live_7f3a9c2e1b8d4f6a
To get your API key, go to All Apps from the menu, find your app, and copy the API Key shown in the app list.
Integration Flow
Mobile App
│
├── 1. Register Device → POST /register
├── 2. Get Geofences → GET /geofences
│
▼
Native Android/iOS Geofencing
│
│ detects ENTER / DWELL / EXIT
▼
3. Send Geofence Event → POST /geofence/event
│
▼
GeoNest Backend → Campaign Processing → Email / SMS / Push / WhatsApp
API 1 — Register Device
Registers the device with GeoNest. Call this on app start / when device info changes.
Endpoint: POST /register
Request Body
{
"app_api_key": "gnk_live_7f3a9c2e1b8d4f6a",
"device_id": "30b43ehjmed21a89970",
"device_timezone": "Asia/Kolkata",
"email": "user@example.com",
"fcm_token": "FCM_DEVICE_TOKEN",
"latitude": 17.4231737,
"longitude": 78.4624177,
"phone": "",
"platform": "android/ios"
}
| Parameter | Required | Description |
|---|---|---|
app_api_key | Yes | API key assigned to the app |
device_id | Yes | Unique device identifier |
device_timezone | No | Device timezone |
email | No | User email |
fcm_token | Yes | Push notification token |
latitude | No | Current latitude |
longitude | No | Current longitude |
phone | No | User phone number |
platform | Yes | android or ios |
Response
{ "success": true, "message": "Device registered successfully." }
API 2 — Get Geofences
Fetches all geofences and campaign rules configured for the app.
Endpoint: GET /geofences?app_api_key=gnk_live_7f3a9c2e1b8d4f6a
Response
{
"success": true,
"count": 2,
"data": [
{
"campaign_id": 1,
"geofence_id": 1,
"name": "Madhapur Store",
"shape": "circle",
"lat": 17.4483,
"lng": 78.3915,
"radius_m": 200,
"polygon_geojson": null,
"event_type": "dwell",
"dwell_minutes": 5,
"cooldown_minutes": 720,
"start_date": "2026-07-28",
"end_date": "2026-08-06",
"active_hours_start": "09:00:00",
"active_hours_end": "21:00:00",
"timezone": null,
"updated_at": "2026-07-28 09:43:10"
},
{
"campaign_id": 2,
"geofence_id": 5,
"name": "Bizonic tech",
"shape": "polygon",
"lat": 17.4202825,
"lng": 78.4596698,
"radius_m": 105,
"polygon_geojson": [
{ "lat": 17.420617722, "lng": 78.459492729 },
{ "lat": 17.41996257, "lng": 78.458843635 },
{ "lat": 17.419737361, "lng": 78.45985751 },
{ "lat": 17.420146832, "lng": 78.460495875 },
{ "lat": 17.420827575, "lng": 78.460211561 }
],
"event_type": "enter",
"dwell_minutes": 0,
"cooldown_minutes": 360,
"start_date": "2026-07-28",
"end_date": "2026-08-06",
"active_hours_start": "09:00:00",
"active_hours_end": "02:00:00",
"timezone": null,
"updated_at": "2026-07-28 09:45:52"
}
]
}
For a circle fence, lat/lng is the center and radius_m is the monitoring radius — use these directly with native geofencing.
For a polygon fence, lat/lng/radius_m is the auto-computed bounding circle (used to register the OS-level wake-up region), and polygon_geojson is the precise shape — use it for an in-app point-in-polygon check once the OS wake-up fires, since the circle is only an approximation.
Key Fields
| Field | Meaning |
|---|---|
geofence_id | Unique fence ID — must be sent back when reporting an event |
campaign_id | Campaign linked to this geofence |
shape | circle or polygon |
lat / lng | Circle center, or bounding-circle center for a polygon fence |
radius_m | Radius in meters — direct radius for circle, auto-computed wake-up radius for polygon |
polygon_geojson | Precise polygon vertices (only present when shape = polygon) |
event_type | enter, dwell, or exit |
dwell_minutes | Dwell duration when event_type = dwell; always 0 for enter/exit |
cooldown_minutes | Minimum gap (in minutes) between repeat triggers |
start_date / end_date | Campaign validity window |
active_hours_start / active_hours_end | Time-of-day window for triggering |
The API only returns fences that are currently active, so the app can register everything it receives directly with the native geofencing APIs (GeofencingClient on Android, CLLocationManager/CLCircularRegion on iOS) — the backend still re-validates status when an event comes in.
API 3 — Send Geofence Event
Call this when the native OS detects an ENTER, DWELL, or EXIT event.
Endpoint: POST /geofence/event
Request Body
{
"app_api_key": "gnk_live_7f3a9c2e1b8d4f6a",
"device_id": "30b43ehjmed21a89970",
"geofence_id": 1,
"event": "dwell",
"latitude": 17.4230194,
"longitude": 78.462362,
"occurred_at": "2026-08-01T10:30:00+05:30"
}
| Parameter | Required | Description |
|---|---|---|
app_api_key | Yes | App API key |
device_id | Yes | Same ID used at registration |
geofence_id | Yes | ID returned by /geofences |
event | Yes | enter, dwell, or exit |
latitude / longitude | Yes | Device location at event time |
occurred_at | No | ISO-8601 timestamp with timezone |
Response
{
"success": true,
"message": "Geofence event processed successfully.",
"data": { "event_id": 1, "campaign_id": 1 }
}
Supported Events
- enter — device enters the geofence
- dwell — device stays inside for the configured
dwell_minutes - exit — device leaves the geofence
Recommended Mobile App Flow
App Start
│
▼
Request Location Permission
│
▼
POST /register
│
▼
GET /geofences
│
▼
Register active fences with native
Android/iOS geofencing
│
▼
Wait for ENTER / EXIT / DWELL
│
▼
POST /geofence/event
│
▼
GeoNest processes campaign
Backend processing on event received:
Validate API key → Validate device → Validate geofence
→ Check campaign status → Check date/active hours
→ Check cooldown → Dispatch channel (Email/SMS/Push/WhatsApp)
Implementation Rules
- Never hardcode geofences. Always fetch from
GET /geofencesso fences can be updated from the dashboard without an app release. - Reuse the same
device_idfrom registration when sending events. - Use the exact
geofence_idreturned by/geofences— don't generate your own. - Only register active fences (
status = active,geofence_status = active). The backend re-validates on event receipt regardless. - Send the real event timestamp in
occurred_at(ISO-8601, with timezone). - Retry failed events. If the device is offline when an event fires, queue it locally and retry once connectivity returns.
API Summary
| API | Method | Purpose |
|---|---|---|
/register | POST | Register device |
/geofences | GET | Fetch geofences + campaign config |
/geofence/event | POST | Report enter/dwell/exit event |
Base URL
https://www.leadnest.ai/api
Architecture
┌─────────────────────────────┐
│ Android / iOS App │
│ Native Location/Geofencing │
└──────────────┬───────────────┘
│ REST API
▼
┌─────────────────────────────┐
│ GeoNest API Layer │
│ POST /register │
│ GET /geofences │
│ POST /geofence/event │
└──────────────┬───────────────┘
▼
┌─────────────────────────────┐
│ GeoNest Campaign Engine │
│ Campaign · Geofence · Event │
│ Cooldown · Active Hours │
└──────────────┬───────────────┘
▼
Email / SMS / Push / WhatsApp
See GeoNest in Action
Once your app is integrated, head over to GeoNest in your dashboard to create your first geofence and campaign. Watch the walkthrough below to see the full setup and how it works end to end.
Coming Soon Features
We're constantly working on new features to help you scale your communications. Here's what's currently in development:
Need Help Getting Started?
Book a personalized demo with our team and discover how LeadNest can transform your communication strategy.