Overview
Pulsetracker’s Geofencing feature allows you to monitor when a device enters or exits a predefined geographic area. You can configure geofences via the dashboard or the HTTP API and receive real-time webhook notifications when events occur.
1. Setting Up Webhook tokens
To validate incoming webhook requests, you need to generate a Webhook token:
-
Go to Dashboard → Tokens & Webhooks.
-
Create a new Webhook token.
-
Copy the generated token and store it securely.
-
Use this token to verify requests from Pulsetracker.
2. Creating a Geofence
Option 1: Using the Dashboard
-
Navigate to Dashboard → Geofencing.
-
Click Add New Geofence.
-
Provide a Name for the geofence.
-
Draw the Polygon on the interactive map.
-
(Optional) Set a Webhook URL to receive event notifications.
-
Select an App that this geofence applies to.
-
Save the geofence.
Option 2: Using the HTTP API
You can also create geofences programmatically via Pulsetracker’s API. Refer to the API documentation for request details.
3. Webhook Events
When a device enters or exits a geofence, Pulsetracker sends a POST request to your webhook URL with the following payload:
Request Body:
{
"event": "inside" | "outside",
"point": { "type": "Point", "coordinates": [longitude, latitude] },
"device_id": 12345,
"geofence_id": 67890,
"location_received_at": 1710000000,
"event_sent_at": 171000003
}
Headers:
p-signature: {signature_string}
4. Validating Webhook Signatures
To ensure the webhook request is from PulsesTracker, you must validate the
p-signature
header. The signature is calculated as follows:
Signature Calculation (Server-Side Example in PHP):
function calculateSignature(string $webhookUrl, array $payload, string $secret): string {
$payloadJson = json_encode($payload);
return hash_hmac('sha256', $payloadJson, $secret);
}
-
$secret
is the Webhook Signature you generated from the dashboard. -
Webhooks will not be sent if a signature is not created.
-
Always compare the received
p-signature
with your locally calculated signature before processing the request.