This section provides a guide on creating, editing, and retrieving geofences using the Pulsetracker HTTP API.
Get user all geofences
GET https://www.pulsestracker.com/api/gefences
Query parameters :
page : int , Default 1
app_id: ?int
Example request
const url = 'https://www.pulsestracker.com/api/geofences';
const options = {
method: 'GET',
headers: {Accept: 'application/json', Authorization: 'Bearer 123'}
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Example response
{
"data": [
{
"id": 0,
"name": "string",
"user_id" : 0,
"app_id" : 0,
"webhook_url" : "string OR null",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
0,
0
],
[
1,
1
]
// ...
]
]
},
"updated_at": "2019-08-24T14:15:22Z",
"created_at": "2019-08-24T14:15:22Z"
}
],
"meta": {
"current_page": 0,
"from": 0,
"last_page": 0,
"links": [
{
"url": "string",
"label": "string",
"active": true
}
],
"path": "string",
"per_page": 0,
"to": 0,
"total": 0
},
"links": {
"first": "string",
"last": "string",
"prev": "string",
"next": "string"
}
}
Or by geofence id :
const url = 'https://www.pulsestracker.com/api/geofences/{id}';
const options = {
method: 'GET',
headers: {Accept: 'application/json', Authorization: 'Bearer 123'}
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Creating new geofence
POST https://www.pulsestracker.com/api/geofences
This endpoint allows you to create a new geofence for a app. Ensure that your request contains the required fields and valid values. Authentication is mandatory, and your Authorization
header must include a valid Bearer Token.
Quota Limit: If you exceed the maximum number of geofences allowed for your account, the server will return a 403 Forbidden error.
Validation Errors: If any required fields are missing or invalid (like polygon invalid), the server will return a 422 Unprocessable Entity error.
Example request
const url = "https://www.pulsestracker.com/api/geofences";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer 123",
},
body: JSON.stringify({
name: "string",
app_id: 0,
webhook_url: "https://mywebsite.com",
geometry: JSON.stringify({
type: "Polygon",
coordinates: [[[1, 1], [1, 2], [2, 2], [2, 1], [1, 1]]],
}),
}),
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}
Example response
{
"data": {
"name": "My fence",
"user_id": 0,
"webhook_url": "https://mywebsite.com",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
1,
1
],
[
1,
2
],
[
2,
2
],
[
2,
1
],
[
1,
1
]
]
]
},
"app_id": 0,
"updated_at": "2025-01-31T15:38:37.000000Z",
"created_at": "2025-01-31T15:38:37.000000Z",
"id": 0
}
}
Update geofence
PUT https://www.pulsestracker.com/api/geofences/{id}
-
app_id int required
-
name ?string
-
geometry ?string
-
webhook_url ?string
Example request
const url = "https://www.pulsestracker.com/api/geofences";
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: "Bearer 123",
},
body: JSON.stringify({
name: "string",
app_id: 0,
webhook_url: "https://mynewwebsite.com",
geometry: JSON.stringify({
type: "Polygon",
coordinates: [[[0, 0], [1, 2], [2, 2], [2, 1], [0, 0]]],
}),
}),
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log(data);
} catch (error) {
console.error(error);
}