Log GPS Event
POST
/locations/{location_id}/gps_events
Log a GPS event.
Roles
Users with the following roles may access this endoint:
Driver
ThirdPartyDriver
Breaking Changes
No breaking changes.
Request
- Sample Request
- Sample Response
POST /locations/{location_id}/gps_events/
Authorization: Bearer {your-auth-token}
Content-Type: application/json
x-tenant-id: {your-tenant-id}
{
"location": {
"activity": {
"confidence": 100,
"type": "unknown"
},
"battery": {
"is_charging": false,
"level": -1
},
"coords": {
"accuracy": 5,
"altitude": 0,
"altitude_accuracy": -1,
"floor": 0,
"heading": 184.57,
"latitude": 37.33517518,
"longitude": -122.03255055,
"speed": 2.41
},
"extras": {},
"is_moving": true,
"odometer": 77163.9,
"timestamp": "2019-02-07T00:12:19.354Z",
"uuid": "81223611-D5FF-4C7E-9BCF-59595D1720AB"
}
}
Access-Control-Allow-Headers: Authorization, Accept, X-TENANT-ID, Content-Type
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: *
Allow: POST
Content-Length: 207
Content-Type: application/json
Date: Sat, 20 Aug 2022 01:39:44 GMT
Server: WSGIServer/0.2 CPython/3.9.5
X-API-VERSION: 2019/02/08
X-REQUEST-ID: a72092e1-8536-4b9d-8819-39b62f4b6bb9
{
"bearing": 184.57,
"created_on": "2019-02-07T00:12:19.354000",
"device_name": "n/a",
"driver_id": 100027,
"id": 1185,
"latitude": 37.33517518,
"longitude": -122.03255055,
"truck_id": null,
"velocity": 2.41
}
Path Parameters
location_id
Integer, Required
Location identifier.
Query Parameters
No query parameters.
Request Headers
Refer to StandardRequestHeadersModel for more details.
authorization
String, Required
Authorization header (bearer with access token). See the Authentication Guide to get started.
- Matches ^bearer [a-z0-9-_=]+.[a-z0-9-_=]+.?[a-z0-9-_.+/=]*$
- No longer than 256 characters.
- At least 1 characters long.
Content-Type
String, Optional
Default Value: application/json
One of the following MIME types:
- "application/json" Refer to the JSON Spec.
x-api-version
String, Optional
Request identifier.
- At least 1 and no more than 64 characters.
- Must be a valid API version string (2019/02/08, 2021/04/07, 2021/05/07, 2021/08/02, 2021/11/04, 2023/04/19).
x-tenant-id
Integer, Required
Tenant identifier. Contact CRO Software for more info if you don't already have this id. See list tenant ids for info on listing the tenants you have access to.
Request Body
Refer to GpsEventProfileModel for more details.
location
Object, Required
Response
Response Headers
Refer to StandardResponseHeadersModel for more details.
Content-Type
String, Optional
Default Value: application/json
One of the following MIME types:
- "application/json" Refer to the JSON Spec.
x-api-version
String
Request identifier.
- At least 1 and no more than 64 characters.
- Must be a valid API version string (2019/02/08, 2021/04/07, 2021/05/07, 2021/08/02, 2021/11/04, 2023/04/19).
x-request-id
String
Request identifier.
- Valid UUID.
Response Body
Refer to GpsStopModel for more details.
bearing
Float
Direction of travel at time of measurement.
- Less than 360.
- Greater than or equal to 0.
created_on
String
Timestamp of creation (must be in past).
- Date occurring in the past in an ISO 8601 compatible format.
device_name
String, Conditional
Name (free text).
- At least 1 and no more than 64 characters.
driver_id
String
Driver identifier.
id
Integer
Resource identifier.
latitude
Float
Latitude.
- Less than or equal to 90.
- Greater than or equal to -90.
longitude
Float
longitude.
- Less than or equal to 180.
- Greater than or equal to -180.
truck_id
Integer
Truck identifier.
velocity
Float
Rate of travel at time of measurement.
- Greater than or equal to 0.
Code Samples
- cURL
- Python
- CSharp 2.0
curl --request POST --include \
--header "Authorization: Bearer {your-auth-token}" \
--header "Content-Type: application/json" \
--header "x-tenant-id: {your-tenant-id}" \
--data '{"location": {"activity": {"confidence": 100, "type": "unknown"}, "battery": {"is_charging": false, "level": -1}, "coords": {"accuracy": 5, "altitude": 0, "altitude_accuracy": -1, "floor": 0, "heading": 184.57, "latitude": 37.33517518, "longitude": -122.03255055, "speed": 2.41}, "extras": {}, "is_moving": true, "odometer": 77163.9, "timestamp": "2019-02-07T00:12:19.354Z", "uuid": "81223611-D5FF-4C7E-9BCF-59595D1720AB"}}' \
127.0.0.1:8003/locations/{location_id}/gps_events
import requests, json
body = '''
{
"location": {
"activity": {
"confidence": 100,
"type": "unknown"
},
"battery": {
"is_charging": false,
"level": -1
},
"coords": {
"accuracy": 5,
"altitude": 0,
"altitude_accuracy": -1,
"floor": 0,
"heading": 184.57,
"latitude": 37.33517518,
"longitude": -122.03255055,
"speed": 2.41
},
"extras": {},
"is_moving": true,
"odometer": 77163.9,
"timestamp": "2019-02-07T00:12:19.354Z",
"uuid": "81223611-D5FF-4C7E-9BCF-59595D1720AB"
}
}
'''
response = requests.post(
'http://localhost:8003/locations/{location_id}/gps_events',
headers={
'Authorization': 'Bearer {your-auth-token}',
'Content-Type': 'application/json',
'x-tenant-id': '{your-tenant-id}'
},
params={
},
data=body
)
results = json.loads(response.text)
print(results)
using System;
using System.Net;
using System.Collections.Specialized;
namespace CROSoftware
{
public class DemoClient
{
static public void Main ()
{
WebClient client = new WebClient();
// URL
String url = "/locations/{location_id}/gps_events";
// Headers
client.Headers.Add("Authorization", "Bearer {your-auth-token}");
client.Headers.Add("Content-Type", "application/json");
client.Headers.Add("x-tenant-id", "{your-tenant-id}");
// Body
String body = "{\"location\": {\"activity\": {\"confidence\": 100, \"type\": \"unknown\"}, \"battery\": {\"is_charging\": false, \"level\": -1}, \"coords\": {\"accuracy\": 5, \"altitude\": 0, \"altitude_accuracy\": -1, \"floor\": 0, \"heading\": 184.57, \"latitude\": 37.33517518, \"longitude\": -122.03255055, \"speed\": 2.41}, \"extras\": {}, \"is_moving\": true, \"odometer\": 77163.9, \"timestamp\": \"2019-02-07T00:12:19.354Z\", \"uuid\": \"81223611-D5FF-4C7E-9BCF-59595D1720AB\"}}";
String json = client.UploadString(url, "post", body);
Console.WriteLine(json);
}
}
}