REST API
REST API: getting started
The SafarTrak API gives your ERP, TMS, BI and in-house tools secure access to your fleet data over HTTPS, with JSON responses.
Overview
- Style: REST over HTTPS, JSON responses.
- Authentication: API key ID and secret in request headers, or HTTP Basic.
- Scope: each key sees only your company's fleet data and can be revoked at any time.
- Coverage: vehicles and live location, route history, temperature, alerts, analytics, utilisation, trip schedules and reference data. See the endpoint reference.
1. Create credentials
In the SafarTrak portal, open API Credentials and create an API key. You receive a key ID and a secret. The secret is shown once, so store it safely, for example in your server's secret manager.
2. Base URL
All endpoint paths are relative to this base URL.
https://safartrack-backend.safartrak.com/api/v1/external3. Authentication
Send the key ID and secret as headers on every request. HTTP Basic authentication, with the key ID as the username and the secret as the password, is also accepted.
X-API-Key: <your API key ID>
X-API-Password: <your API secret>Examples
List the vehicles that are moving right now, then fetch yesterday's route for one vehicle.
curl "https://safartrack-backend.safartrak.com/api/v1/external/vehicles?status=moving&page=1&limit=50" \
-H "X-API-Key: $SAFARTRAK_API_KEY" \
-H "X-API-Password: $SAFARTRAK_API_SECRET"curl "https://safartrack-backend.safartrak.com/api/v1/external/vehicles/VEHICLE_ID/route-history?period=yesterday" \
-H "X-API-Key: $SAFARTRAK_API_KEY" \
-H "X-API-Password: $SAFARTRAK_API_SECRET"const headers = {
"X-API-Key": process.env.SAFARTRAK_API_KEY,
"X-API-Password": process.env.SAFARTRAK_API_SECRET,
};
const moving = await fetch("https://safartrack-backend.safartrak.com/api/v1/external/vehicles?status=moving&page=1&limit=50", { headers });
console.log(await moving.json());
const route = await fetch("https://safartrack-backend.safartrak.com/api/v1/external/vehicles/VEHICLE_ID/route-history?period=yesterday", { headers });
const { success, data } = await route.json();import os, requests
BASE = "https://safartrack-backend.safartrak.com/api/v1/external"
headers = {
"X-API-Key": os.environ["SAFARTRAK_API_KEY"],
"X-API-Password": os.environ["SAFARTRAK_API_SECRET"],
}
moving = requests.get(f"{BASE}/vehicles", params={"status": "moving", "page": 1, "limit": 50}, headers=headers, timeout=30)
print(moving.json())
route = requests.get(f"{BASE}/vehicles/VEHICLE_ID/route-history", params={"period": "yesterday"}, headers=headers, timeout=30)
print(route.json())Replace VEHICLE_ID with the vehicle's uniqueId from the /vehicles response.
Conventions
- Every successful response includes
success: true; errors returnsuccess: falsewith amessage. - List endpoints accept
pageandlimit. - Date-based endpoints accept
fromandto; route history also accepts aperiodsuch astodayoryesterday. - Vehicles are identified by
uniqueId(the device ID). Search by registration number with/vehicles?search=.
See responses and errors for status codes.
Keeping keys safe
Questions about the API or MCP? Email support@safartrak.com (24/7) or contact the team.