Polyfence documentation
You’re building a product that needs geofencing. We’re the geofence layer — same zones run on your mobile app, your IoT device, and your server. Define once. Evaluate anywhere.
- Open hardware — nRF52, ESP32, STM32. Same C library, no chip lock-in.
- Privacy-first — positions never leave the device by default. Only zone events.
- One platform — SDK install + firmware + API are surfaces of the same model, with the same brand and the same developer experience.
Quickstart
Three peer surfaces — Mobile SDK, Embedded library, Server API. Pick your platform below: install, add a zone, start detecting.
Install the plugin:
$ flutter pub add polyfenceInitialize, add a zone, start tracking:
import 'package:polyfence/polyfence.dart';
await Polyfence.instance.initialize();
final zone = Zone.circle(
id: 'office',
name: 'London Office',
center: PolyfenceLocation(latitude: 51.5074, longitude: -0.1278),
radius: 200,
);
await Polyfence.instance.addZone(zone);
await Polyfence.instance.startTracking();
// Listen for enter/exit events
Polyfence.instance.onGeofenceEvent((event) {
print('${event.type} zone: ${event.zone.name}');
});Source on GitHub: polyfence-core · polyfence-embedded
API reference
Try endpoints with your API key, see request/response schemas, test authentication.
OpenAPI 3.1. Import into Postman, generate typed clients, build custom integrations.
Every HTTP status, error message, cause, and remedy — for retry logic and error handling.
Key concepts
- Zones
- A geographic area (circle or polygon) that triggers events when a device enters or exits. Create via the dashboard, import as GeoJSON, or use the API. No limit on zone count during early access.
- On-device detection
- On mobile, all geofencing runs on-device using the native Kotlin/Swift engine (polyfence-core). On IoT hardware, the polyfence-embedded C library evaluates coordinates locally. Both paths fire events on the device with no positions sent to Polyfence — use these when you need a strict on-device guarantee. The server-side evaluate API below is the alternative for devices that can’t run the C library.
- SmartGPSMobile
- The mobile SDK adapts GPS polling based on user activity (walking, driving, stationary) and proximity to zones. Saves battery while keeping detection latency under 50ms.
- Embedded / IoTNew
- Run geofence checks on ESP32, STM32, Raspberry Pi, or any device with a C11 toolchain. The polyfence-embedded library is under 100KB compiled with zero external dependencies. Sync zones via REST API, evaluate coordinates locally.
- Evaluate APIIoT
- Server-side point-in-polygon checks for IoT devices that don’t run the C library. Send a device ID and coordinates, get back zone events and current zone membership. Positions are discarded by default, retained only when you opt in to hosted history via the per-account retention toggle (
GET /v1/account/retention/PATCH /v1/account/retention). The setting is echoed on everyGET /v1/devices/{deviceId}row so your code can mirror it. - API keys
- Authenticate REST API calls with an
x-api-keyheader. Keys are scoped (zones:read,zones:write,zones:delete) and stored as SHA-256 hashes.
Privacy posture
Polyfence applies different defaults to different data classes — that’s the posture, not an inconsistency.
- Positions
- Positions are evaluated and discarded — not stored. Hosted history is opt-in per device when you need it (
PATCH /v1/account/retention). - Anonymous telemetry
- Anonymous platform metrics — never identifiers, never coordinates. One line of code disables it.
- Your account info
- Standard B2B SaaS PII — email, billing. Identical to what Stripe or Vercel hold about you.
Polyfence collects zero PII and zero identifiable data about your end users. Full breakdown on the privacy page.
Platform support
Ready to start building?
Create your first zone and start integrating Polyfence. Free during early access.