API reference
Location history
The locations a device reported over time, newest first.
WeGuard records history only while the device’s policy has location tracking turned on. History is kept for about 65 days on Android and 60 days on Apple devices. Windows history does not expire automatically. On Windows, you get only the points recorded since the device’s current enrollment, not points from an earlier enrollment, even one in your own account. On Android, history follows the physical device within your account, so it can include points from an earlier enrollment of the same device, within the retention period.
If you only need the most recent position, use Retrieve a device’s location.
The location point object
One reported position, in WGS 84 decimal degrees. Optional measurements are null when the device did not report them or reported an invalid value. Points without valid coordinates are never returned.
idstring- Unique id of the location point.
objectstring- Always
location_point. latitudenumber- Latitude in decimal degrees.
longitudenumber- Longitude in decimal degrees.
accuracyMetersnumbernullable- Horizontal accuracy radius in meters.
altitudeMetersnumbernullable- Altitude in meters, as reported by the device. Android and Windows devices report
0when the altitude is unknown. speedMetersPerSecondnumbernullable- Ground speed in meters per second. Android and Windows devices report
0when the speed is unknown. headingDegreesnumbernullable- Direction of travel in degrees (0 to 360), clockwise from true north. Reported by Apple devices only. Always
nullon Android and Windows. recordedAttimestamp- When the device captured the location.
{
"id": "6701c2e5f1a2b3c4d5e6f789",
"object": "location_point",
"latitude": 17.4474,
"longitude": 78.3762,
"accuracyMeters": 12.4,
"altitudeMeters": 512.3,
"speedMetersPerSecond": 0.3,
"headingDegrees": null,
"recordedAt": "2026-10-07T09:20:00Z"
}List a device’s location history
/ v1/ devices/ {deviceId}/ locationsReturns the locations the device reported between since and until, newest first, as a paginated list. If you omit both since and until, you get the last 24 hours. See Time ranges.
Location history is personal data about the people who use your devices. Grant locations:read only to integrations that need it, request only the window you need, and handle the data according to your privacy obligations.
Path parameters
deviceIdstringrequired- Id of the device. Case-insensitive.
Query parameters
sincetimestampoptionaldefault 24 hours before until- Start of the time range (inclusive), as an ISO-8601 timestamp with a UTC offset, for example
2026-10-01T00:00:00Z. Must be earlier thanuntil. The range can span at most 31 days. See Time ranges. untiltimestampoptionaldefault now- End of the time range (exclusive), as an ISO-8601 timestamp with a UTC offset. If you omit it, the first page fixes “now” and every
nextCursorcarries that value, so all pages cover the same window. In that case the maximum span of 31 days allows 5 minutes of clock tolerance. limitintegeroptionaldefault 100- Maximum number of items to return, from
1to1000. cursorstringoptional- The
nextCursorfrom the previous page. Send it unchanged, together with the same filters. See Pagination. includeTotalbooleanoptionaldefault false- Set to
trueto also returntotalCount. It runs an extra count, so request it only when you need it.
Example request
curl "https://api-gw.weguard.ai/core/v1/devices/6523f1c2a7b9d40012345678/locations?since=2026-10-07T00:00:00Z&until=2026-10-08T00:00:00Z&limit=2" \
-H "Authorization: Bearer $WEGUARD_API_KEY"const response = await fetch("https://api-gw.weguard.ai/core/v1/devices/6523f1c2a7b9d40012345678/locations?since=2026-10-07T00:00:00Z&until=2026-10-08T00:00:00Z&limit=2", {
headers: { Authorization: `Bearer ${process.env.WEGUARD_API_KEY}` },
});
const body = await response.json();
if (!response.ok) {
throw new Error(`${body.code}: ${body.detail} (requestId ${body.requestId})`);
}
console.log(body);import os
import requests
response = requests.get(
"https://api-gw.weguard.ai/core/v1/devices/6523f1c2a7b9d40012345678/locations",
params={
"since": "2026-10-07T00:00:00Z",
"until": "2026-10-08T00:00:00Z",
"limit": 2,
},
headers={"Authorization": f"Bearer {os.environ['WEGUARD_API_KEY']}"},
timeout=30,
)
response.raise_for_status()
print(response.json())Response
A list object whose data holds location point objects, newest first. An empty list with hasMore: false means there is no history in the window. The API skips points without valid coordinates. As a result, a page can hold fewer than limit points while hasMore is true, and totalCount (with includeTotal=true) can be higher than the number of points you receive across all pages.
{
"object": "list",
"data": [
{
"id": "6701c2e5f1a2b3c4d5e6f789",
"object": "location_point",
"latitude": 17.4474,
"longitude": 78.3762,
"accuracyMeters": 12.4,
"altitudeMeters": 512.3,
"speedMetersPerSecond": 0.3,
"headingDegrees": null,
"recordedAt": "2026-10-07T09:20:00Z"
},
{
"id": "6701c2b1f1a2b3c4d5e6f701",
"object": "location_point",
"latitude": 17.4452,
"longitude": 78.3791,
"accuracyMeters": 18.5,
"altitudeMeters": 498.7,
"speedMetersPerSecond": 1.4,
"headingDegrees": null,
"recordedAt": "2026-10-07T09:05:00Z"
}
],
"hasMore": true,
"nextCursor": "dDE6MTc5MTQxNDAwMDAwMDo2NzAxYzJlNWYxYTJiM2M0ZDVlNmY3ODk"
}Errors
No device with this id exists in your account.
sinceoruntilis not an ISO-8601 timestamp with an offset, or is outside the range 1970-01-01T00:00:00Z to 9999-12-31T23:59:59.999Z;sinceis not earlier thanuntil; the range is longer than 31 days;limitorincludeTotalis invalid; or a parameter was sent twice.The request includes a query parameter this endpoint does not accept.
The cursor is malformed, or was issued for a different listing: another path, other filters, or another
since/until.The key lacks
locations:read.
Common errors
Besides the errors listed for each endpoint, any request can fail authentication, exceed the rate limit, ask for a format other than JSON, or fail with a server error. See Errors for the response format and retry guidance.
The request has no
Authorizationheader.The
Authorizationheader does not use theBearerscheme, or has no key after it. TheWWW-Authenticateheader carrieserror="invalid_request".The key is malformed, does not exist, or its secret does not match. The
WWW-Authenticateheader carrieserror="invalid_token".The key is past its
expiresAt.An account admin revoked the key. Revocation takes effect immediately and cannot be undone.
The WeGuard account that owns the key has been deleted or disabled.
The
Acceptheader excludes JSON.The key has used up its request budget. See Rate limits.
An unexpected error occurred on our side.
A service WeGuard depends on is temporarily unavailable, or reading the data took longer than the time WeGuard allows for it. This can also happen while your key is being checked, so it can be returned before authentication completes. The response carries
Retry-After.