Real Time Tracking - Monitoring

Introduction

Each Mercado Envíos vehicle can have one or more devices that send information related to locations, telemetry, incidents, events or other relevant info. This vehicle is called TRANSPORT. A transport can also be other type of things such as a car, van, drone, motorcycle, bicycle, person or anything with transportation capabilities.

Transport and Device relation

How it works?

Assuming that third-party devices are already installed on transports.

Step 1. Mercado Envíos sends a "Start Tracking Request" informing to the third-party provider the "License Plate" and "Transport ID" corresponding to the transport to be monitored. 3P System must save this information in order to register further devices for that transport.

Step 2. Third-party provider registers the Device in Mercado Envíos RTT providing the "Transport ID" and his own device identifier in the field "external_entity_id". RTT will return a device id which will be the one that needs to be used to send further information.

Step 3. Third-party provider acknowledges the start-tracking by sending a request with the "device_id" or the fields "external_entity_id" and "external_entity_type". Now the device is able to send info to RTT.

Step 4. Third-party provider device starts sending Locations and/or Telemetry data using the provided rtt "device_id" obtained in the step 2.

Step 5. Mercado Envíos sends a "Stop Tracking Request" informing to the third-party provider the "License Plate" and "Transport ID" corresponding to the transport that will no longer be monitored. 3P System must save this information in order to stop tracking the devices associated with that transport.

Step 6. Third-party provider acknowledges the stop-tracking by sending a request with the "device_id" or the fields "external_entity_id" and "external_entity_type". Now the device is disabled to send info to RTT.

Route Planification

Every route that will be monitored must be sent beforehand to the provider so he can verify if all the required configuration is set prior to receiving a start tracking command (ex. License Plate is registered by the AVL and available in the monitoring system). For that purpose the provider should provide a HTTP REST endpoint to allow Mercado Envios to send planned and cancelled routes information.

Important:

Request Format

A message with the following structure will be sent:

bash
1POST https://{PROVIDER_URL}/rtt/commands

Header

NameType of dataDescription
AuthorizationStringAccess token for the requested resource (Bearer + TOKEN).

The body attributes are explained below:

NameType of dataDescriptionType
planned_routesArrayInformation related to routes.Mandatory
planned_routes[i].route_idNumberRoute identifier.Mandatory
planned_routes[i].rostering_idNumberRostering identifier.Mandatory
planned_routes[i].estimated_start_dateDate (ISO8601)Route start date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
planned_routes[i].estimated_end_dateDate (ISO8601)Route end date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
planned_routes[i].estimated_start_monitoring_dateDate (ISO8601)Monitoring estimated start date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
planned_routes[i].estimated_end_monitoring_dateDate (ISO8601)Monitoring estimated end date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
planned_routes[i].country_idStringID of the country where the route takes place. The Country Id must be taken from this resource.Mandatory
planned_routes[i].carrierNodeInformation related to the carrier that performs the transport.Mandatory
planned_routes[i].carrier.idNumberCarrier identifier.Mandatory
planned_routes[i].carrier.nameStringCarrier name.Mandatory
planned_routes[i].vehiclesArrayInformation related to the vehicles involved in the route.Mandatory
planned_routes[i].vehicles[i].is_tractorBooleanInformation on whether the vehicle is "motorized".Mandatory
planned_routes[i].vehicles[i].typeStringType of vehicle assigned to the route.Mandatory
planned_routes[i].vehicles[i].license_plateStringVehicle license plate.Mandatory
planned_routes[i].stopsArrayInformation about the route itinerary.Mandatory
planned_routes[i].stops[i].orderNumberSegment identifier.Mandatory
planned_routes[i].stops[i].facilityNodeInformation about the facility.Mandatory
planned_routes[i].stops[i].facility.idStringFacility name.Mandatory
planned_routes[i].stops[i].facility.addressNodeFacility address information.Mandatory
planned_routes[i].stops[i].facility.address.country_nameStringCountry name.Mandatory
planned_routes[i].stops[i].facility.address.state_nameStringState name.Mandatory
planned_routes[i].stops[i].facility.address.neighborhood_nameStringNeighborhood name.Mandatory
planned_routes[i].stops[i].facility.address.street_nameStringStreet name.Mandatory
planned_routes[i].stops[i].facility.address.street_numberStringStreet number.Mandatory
planned_routes[i].stops[i].facility.address.zip_codeStringZip code.Mandatory
planned_routes[i].stops[i].facility.address.geolocationNodeInformation about the facility geolocation.Mandatory
planned_routes[i].stops[i].facility.address.geolocation.latitudeNumberLatitude.Mandatory
planned_routes[i].stops[i].facility.address.geolocation.longitudeNumberLongitude.Mandatory
planned_routes[i].stops[i].estimated_time_departureDate (ISO8601)Estimated departure date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
planned_routes[i].stops[i].estimated_time_arrivalDate (ISO8601)Estimated arrival date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
commandStringA string value representing a specific event: ["check_planned_routes"] or ["cancel_planned_routes"].Mandatory
json
1{ 2 "planned_routes": [ 3 { 4 "route_id": "number", 5 "rostering_id": "number", 6 "estimated_start_date": "date", 7 "estimated_end_date": "date", 8 "estimated_start_monitoring_date": "date", 9 "estimated_end_monitoring_date": "date", 10 "country_id": "string", 11 "carrier": { 12 "id": "number", 13 "name": "string" 14 }, 15 "vehicles": [ 16 { 17 "is_tractor": "boolean", 18 "type": "string", 19 "license_plate": "string" 20 } 21 ], 22 "stops": [ 23 { 24 "order": "number", 25 "facility": { 26 "id": "string", 27 "address": { 28 "country_name": "string", 29 "state_name": "string", 30 "neighborhood_name": "string", 31 "street_name": "string", 32 "street_number": "string", 33 "zip_code": "string", 34 "geolocation": { 35 "latitude": "number", 36 "longitude": "number" 37 } 38 } 39 }, 40 "estimated_time_arrival": "date", 41 "estimated_time_departure": "date" 42 } 43 ] 44 } 45 ], 46 "command": "string" 47}

Status Codes

StatusDescriptionAction
200Valid requestIt will not retry.
400Data validation failedDepending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The client does not have permissionIt will not retry.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "planned_routes": [ 3 { 4 "route_id": 2478385, 5 "rostering_id": 18870407, 6 "estimated_start_date": "2022-01-20T18:35:40.235Z", 7 "estimated_end_date": "2022-01-20T23:35:40.235Z", 8 "estimated_start_monitoring_date": "2022-01-20T16:35:40.235Z", 9 "estimated_end_monitoring_date": "2022-01-20T23:35:40.235Z", 10 "country_id": "MX", 11 "carrier": { 12 "id": 213245, 13 "name": "Tracusa" 14 }, 15 "vehicles": [ 16 { 17 "is_tractor": true, 18 "type": "Truck", 19 "license_plate": "ADD1236AR" 20 } 21 ], 22 "stops": [ 23 { 24 "order": 1, 25 "facility": { 26 "id": "AMXMEX", 27 "address": { 28 "country_name": "Mexico", 29 "state_name": "Distrito Federal", 30 "neighborhood_name": "Lic. Benito Juarez", 31 "street_name": "C. Carlos Castillo Breton", 32 "street_number": "12337", 33 "zip_code": "15620", 34 "geolocation": { 35 "latitude": 19.42720919876, 36 "longitude": -99.07522594986 37 } 38 } 39 }, 40 "estimated_time_arrival": "2022-01-20T18:35:40.235Z", 41 "estimated_time_departure": "2022-01-20T18:35:40.235Z" 42 } 43 ] 44 } 45 ], 46 "command": "check_planned_routes" 47}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}

Steps to send real time information

1. Start Tracking

We need to tell you when a device should "Start" sending locations to Shipping RTT. For that purpose the provider should provide a HTTP REST endpoint to allow Mercado Envios to request start and stop tracking of a particular transport.

Important:

  • For security in "Start Tracking", this security protocol will be used.
  • Idempotence: Notice that start tracking requests are expected to be done more than one time given that the origin of those requests could be originated on different sources, so is expected that both requests are comply with idempotence concept.

Request Format

A message with the following structure will be sent:

bash
1POST https://{PROVIDER_URL}/rtt/commands

Header

NameType of dataDescription
AuthorizationStringAccess token for the requested resource (Bearer + TOKEN).

The body attributes are explained below:

NameType of dataDescriptionType
transportNodeInformation about the transport where the device is used.Mandatory
transport.idNumberTransport identifier generated by Mercado Libre. This identifier will be needed when creating a device.Mandatory
transport.license_plateStringLicense plate is the common identifier known to both systems.Mandatory
transport.country_idStringID of the country where the vehicle is registered. The Country Id must be taken from this resource.Mandatory
commandStringA string value representing a specific event: ["start_tracking"].Mandatory
json
1{ 2 "transport": { 3 "id": "number", 4 "license_plate": "string", 5 "country_id": "string" 6 }, 7 "command": "string" 8}

Status Codes

StatusDescriptionAction
200Valid requestIt will not retry.
400Data validation failedDepending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The client does not have permissionIt will not retry.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "transport": { 3 "id": 5266555, 4 "license_plate": "1234ABC", 5 "country_id": "AR" 6 }, 7 "command": "start_tracking" 8}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}

2. Register to Meli

To do api calls against Shipping RTT you will need two identifiers to get access, the first is a Client ID that identified you as a client of Shipping RTT and the second is a ML Token that is your access key. Both of them are required.

3. Register Device

To register a "DEVICE" we need information like brand, type, model of the device and external_entity associated with it, this is any value that could be useful to do queries in the future. Also transport information associated with the device can be sent.

Request Format

A message with the following structure will be sent:

bash
1POST https://api.mercadolibre.com/shipping/rtt/devices?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory

The body attributes are explained below:

NameType of dataDescriptionType
external_entityNodeId and type of an external entity associated to device.Mandatory
external_entity.entity_idStringId of an external entity associated to device.Mandatory
external_entity.entity_typeStringType of an external entity associated to device. We must create a new type for you.Mandatory
transportNodeInformation about the transport where the device is used.Mandatory
transport.idNumberThe "transport_id" was sent at the time of creating the monitoring request (Step 1).Mandatory
device_specsNodeFor stats proposed, we may collect some device data.Optional
device_specs.device_typeStringType of the device. Valid values: MOBILE, GPS, OBD, OTHEROptional
device_specs.brandStringBrand of the device.Optional
device_specs.modelStringModel of the device.Optional
device_specs.equipment_idStringPhysical identifier of the device.Optional
json
1{ 2 "external_entity": { 3 "entity_id": "string", 4 "entity_type": "string" 5 }, 6 "transport": { 7 "id": "number" 8 }, 9 "device_specs": { 10 "device_type": "string", 11 "brand": "string", 12 "model": "string", 13 "equipment_id": "string" 14 } 15}

Status Codes

StatusDescriptionAction
201SuccessIt will not retry.
208If the device is already registered and currently active (matching with external entities values), the API returns 208 with all the entity data and the original device is not modified by this call.It will not retry.
400Data validation failed.Depending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403Invalid token or missing caller.scopeIt will not retry.
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Response Format

FieldsType of DataDescription
idStringUnique identifier created by RTT to track locations.
owner_idStringRepresents the userId that created the Oauth Token.
statusStringpossible values: "active" or "inactive".
external_entityNodeId and type of an external entity associated to device.
external_entity.entity_idStringId of an external entity associated to device.
external_entity.entity_typeStringType of an external entity associated to device.
transportNodeInformation about the transport where the device is used.
transport.idNumberThe "transport_id" was sent at the time of creating the monitoring request (Step 1).
device_specsNodeFor stats proposed, we may collect some device data.
device_specs.typeStringType of the device.
device_specs.brandStringBrand of the device.
device_specs.modelStringModel of the device.
device_specs.equipment_idStringPhysical identifier of the device.
historyNodeDevice history information.
history.date_createdDate (ISO8601)Device creation date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
history.last_updatedDate (ISO8601)Device last update date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
history.last_status_updatedDate (ISO8601)Device status last update date. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
json
1{ 2 "id": "string", 3 "owner_id": "string", 4 "status": "string", 5 "external_entity": { 6 "entity_id": "string", 7 "entity_type": "string" 8 }, 9 "transport": { 10 "id": "number" 11 }, 12 "device_specs": { 13 "type": "string", 14 "brand": "string", 15 "model": "string", 16 "equipment_id": "string" 17 }, 18 "history": { 19 "date_created": "date", 20 "last_updated": "date", 21 "last_status_updated": "date" 22 } 23}

Examples

Request

json
1{ 2 "external_entity": { 3 "entity_id": "demo-1", 4 "entity_type": "DRIVER_ID" 5 }, 6 "transport": { 7 "id": 123456789 8 }, 9 "device_specs": { 10 "device_type": "mobile", 11 "brand": "samsung", 12 "model": "A1", 13 "equipment_id": "example-1" 14 } 15}

Response

json
1{ 2 "id": "1afb3349-9d42-424c-91c0-6756884b0e00", 3 "client_id": 123, 4 "owner_id": "", 5 "status": "ACTIVE", 6 "device_specs": { 7 "type": "mobile", 8 "brand": "samsung", 9 "model": "A1", 10 "equipment_id": "example-1" 11 }, 12 "external_entity": { 13 "entity_id": "demo-1", 14 "entity_type": "DRIVER_ID" 15 }, 16 "transport": { 17 "id": 123456789 18 }, 19 "history": { 20 "date_created": "2022-01-20T23:35:40Z", 21 "last_updated": "2022-01-20T23:35:40Z", 22 "last_status_update": "2022-01-20T23:35:40Z" 23 } 24}

4. Device Start Tracking

To start tracking the device it is necessary to send the following request.

bash
1POST https://api.mercadolibre.com/shipping/rtt/devices/{device_id}/start_tracking?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory
device_idStringPathDevice ID obtained from device registration (Step 3).Mandatory

Status Codes

StatusMessageDescription
200SuccessTracking started successfully
208Already reportedTracking has already been started previously
403ForbiddenThe access_token provided is not valid
404Not foundThe device was not found with the ID or the external entity values provided
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Important: This call is idempotent, so we can receive multiple start tracking events.

5. Sending Locations

To register a location associated to a device, it is required to send the device_id and associated locations information. Also telemetry information associated with the location can be sent in the same request.

A message with the following structure will be sent:

bash
1POST https://api.mercadolibre.com/shipping/rtt/georeceiver/{provider}/locations?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory
providerStringPathProvider name.Mandatory

The body attributes are explained below:

NameType of dataDescriptionType
device_idStringDevice identifier informed device registration process (Step 2).Mandatory
post_timestampIntegerLocal UTC time from the device, at the moment of sending the data, in seconds since epoch (January 1, 1970).Mandatory
locationsArrayArray of locationsMandatory
locations[i].timestampIntegerUTC time of the moment in which the location data was obtained, in seconds since epoch (January 1, 1970).Mandatory
locations[i].country_idStringID of the country where the device that sends locations is operational. The Country Id must be taken from this resource.Mandatory
locations[i].latitudeNumberGPS latitude in degrees.Mandatory
locations[i].longitudeNumberGPS longitude in degrees.Mandatory
locations[i].altitudeNumberGPS altitude (mts above sea level).Optional
locations[i].accuracyNumberEstimated horizontal accuracy of this location, radial, in meters.Optional
locations[i].bearingNumberHorizontal direction of travel of this device, in degrees.Optional
locations[i].bearing_accuracyNumberEstimated bearing accuracy of this location, in degrees.Optional
locations[i].metadataArrayArray of objects "key-value". Any extra info associated with the location like events. Maximum of 20 items.Optional
locations[i].metadata[i].nameStringKey of metadata defined by the client or by Mercado Envíos.Mandatory
locations[i].metadata[i].valueStringValue for corresponding key defined by the client.Mandatory
locations[i].telemetryNodeTelemetry data associated to the location obtained by the device.Optional
locations[i].telemetry.timestampNumberUTC time of the moment in which the telemetry data was obtained, in seconds since epoch (January 1, 1970).Mandatory
locations[i].telemetry.ignitionBooleanIgnition system status.Optional
locations[i].telemetry.odometerNumberOdometer value, in kilometers.Optional
locations[i].telemetry.speedNumberSpeed value, in kilometers/hour.Optional
locations[i].telemetry.speed_accuracyNumberEstimated speed accuracy of this location, in meters per second.Optional
locations[i].telemetry.engine_rpmNumberEngine revolutions/minute.Optional
locations[i].telemetry.engine_temperatureNumberEngine temperature, in degrees celsius.Optional
locations[i].telemetry.air_temperatureNumberEnvironment temperature, in degrees celsius.Optional
locations[i].telemetry.acceleration_longitudinalNumberLongitudinal acceleration, in meters/second².Optional
locations[i].telemetry.acceleration_lateralNumberLateral acceleration, in meters/second².Optional
locations[i].telemetry.directionStringCompass direction.Optional
locations[i].telemetry.fuel_quantityNumberAmount of fuel remaining in the vehicle in Liters.Optional
locations[i].telemetry.fuel_levelNumberFuel level. 0-100%.Optional
locations[i].telemetry.fuel_consumptionNumberEstimated fuel consumption in km/L.Optional
locations[i].telemetry.battery_levelNumberBattery level. 0-100%.Optional
locations[i].telemetry.battery_consumptionNumberEstimated battery consumption in km/KW.Optional
locations[i].telemetry.battery_healthNumberBattery health. 0-100%.Optional
locations[i].telemetry.battery_temperatureNumberBattery temperature, in degrees celsius.Optional
locations[i].telemetry.battery_remainingNumberRemaining amount of battery charge in the vehicle in kWh.Optional
locations[i].telemetry.othersArrayArray of objects "key-value". Any additional non-modeled telemetry information. Maximum of 20 items.Optional
locations[i].telemetry.others[i].nameStringKey of metadata defined by the client.Mandatory
locations[i].telemetry.others[i].valueStringValue for corresponding key defined by the client.Mandatory
json
1{ 2 "device_id": "string", 3 "post_timestamp": "integer", 4 "locations": [ 5 { 6 "timestamp": "integer", 7 "country_id": "string", 8 "latitude": "number", 9 "longitude": "number", 10 "altitude": "number", 11 "accuracy": "number", 12 "bearing": "number", 13 "bearing_accuracy": "number", 14 "metadata": [ 15 { 16 "name": "string", 17 "value": "string" 18 } 19 ], 20 "telemetry": { 21 "timestamp": "number", 22 "ignition": "string", 23 "odometer": "number", 24 "speed": "number", 25 "speed_accuracy": "number", 26 "others": [ 27 { 28 "name": "string", 29 "value": "string" 30 } 31 ], 32 "....": "...." 33 } 34 } 35 ] 36}

Status Codes

StatusDescriptionAction
202valid requestIt will not retry.
400Data validation failed.Depending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The device has not permissionIt will not retry.
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "device_id": "0c709aac-89d3-4acc-aac0-c3d8a7cabc5e", 3 "post_timestamp": 161980863, 4 "locations": [ 5 { 6 "accuracy": 14.389, 7 "altitude": 76.08372940019947, 8 "bearing": 15.5, 9 "bearing_accuracy": 2.3, 10 "latitude": -34.5743988, 11 "longitude": -58.4845495, 12 "timestamp": 161980861, 13 "country_id": "AR", 14 "telemetry": { 15 "....": "...." 16 }, 17 "metadata": [ 18 { 19 "name": "delivered", 20 "value": "ship1" 21 } 22 ] 23 } 24 ] 25}

Response

json
1{ 2 "status": 202, 3 "message": "Accepted" 4}

6. Send Events

To register events associated to a device, it is required to send the device_id and occurred events information.

bash
1POST https://api.mercadolibre.com/shipping/rtt/georeceiver/{provider}/telemetry/events?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory
providerStringPathProvider name.Mandatory

The body attributes are explained below:

NameType of dataDescriptionType
device_idStringDevice identifier informed device registration process (Step 2).Mandatory
post_timestampIntegerLocal UTC time at the moment of sending the data, in seconds since epoch (January 1, 1970).Mandatory
eventsArrayArray of objects with telemetry events information.Mandatory
events[i].nameStringEvent names. Valid values: harsh_braking, harsh_acceleration, unfastened_seatbelt, sharp_turn, speeding_route, speeding_opsMandatory
events[i].start_dateDate (ISO8601)Event start date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
events[i].end_dateDate (ISO8601)Event end date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
events[i].distanceNumberEvent distance, expressed in meters.Optional
events[i].latitudeNumberGPS latitude in degrees.Optional
events[i].longitudeNumberGPS longitude in degrees.Optional
events[i].external_idStringEvent provider identification.Optional
events[i].last_updated_dateDate (ISO8601)Last updated date of the event. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Optional
events[i].statusNumberStatus of the event.Optional
events[i].metadataArrayArray with the description of the event.Optional
events[i].metadata[i].nameStringName of the description.Mandatory
events[i].metadata[i].valueStringValue of the description.Mandatory
json
1{ 2 "device_id": "string", 3 "post_timestamp": "number", 4 "events": [ 5 { 6 "name": "string", 7 "start_date": "date", 8 "end_date": "date", 9 "distance": "number", 10 "latitude": "number", 11 "longitude": "number", 12 "external_id": "number", 13 "last_updated_date": "date", 14 "status": "number", 15 "metadata": [ 16 { 17 "name": "string", 18 "value": "string" 19 } 20 ] 21 } 22 ] 23}

Status Codes

StatusDescriptionAction
202valid requestIt will not retry.
400Data validation failed.Depending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The device has not permissionIt will not retry.
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "device_id": "0c709aac-89d3-4acc-aac0-c3d8a7cabc5e", 3 "post_timestamp": 161980861, 4 "events": [ 5 { 6 "name": "speeding_route", 7 "start_date": "2022-01-20T18:35:40.235Z", 8 "end_date": "2022-01-20T18:50:40.235Z", 9 "distance": 150, 10 "latitude": -34.5743988, 11 "longitude": -58.4845495, 12 "external_id": 122345, 13 "last_updated_date": "2022-01-20T18:35:40.235Z", 14 "status": 1, 15 "metadata": [ 16 { 17 "name": "speeding", 18 "value": "130" 19 } 20 ] 21 } 22 ] 23}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}

7. Stop Tracking

We need to tell you when a device should "Stop" sending locations to Shipping RTT. When we request an stop, upon confirmation new locations associated with it will be rejected.

Important:

  • For security in "Stop Tracking", this security protocol will be used.
  • Idempotence: Notice that stop tracking requests are expected to be done more than one time given that the origin of those requests could be originated on different sources, so is expected that both requests are comply with idempotence concept.

A message with the following structure will be sent:

bash
1POST https://{PROVIDER_URL}/rtt/commands

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

The body attributes are explained below:

NameType of dataDescriptionType
transportNodeInformation about the transport where the device is used.Mandatory
transport.idNumberTransport identifier generated by Mercado Libre. This identifier will be needed when creating a device.Mandatory
transport.license_plateStringLicense plate is the common identifier known to both systems.Mandatory
transport.country_idStringID of the country where the vehicle is registered. The Country Id must be taken from this resource.Mandatory
commandStringA string value representing a specific event: ["stop_tracking"].Mandatory
json
1{ 2 "transport": { 3 "id": "number", 4 "license_plate": "string", 5 "country_id": "string" 6 }, 7 "command": "string" 8}

Status Codes

StatusDescriptionAction
200Valid requestIt will not retry.
400Data validation failedDepending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The client does not have permissionIt will not retry.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "transport": { 3 "id": 5266555, 4 "license_plate": "1234ABC", 5 "country_id": "AR" 6 }, 7 "command": "stop_tracking" 8}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}

8. Device Stop Tracking

To stop tracking the device it is necessary to send the following request.

bash
1POST https://api.mercadolibre.com/shipping/rtt/devices/{device_id}/stop_tracking?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory
device_idStringPathDevice ID obtained from device registration (Step 3).Mandatory

Status Codes

StatusMessageDescription
200SuccessTracking stopped successfully
208Already reportedTracking has already been stopped previously
403ForbiddenThe access_token provided is not valid
404Not foundThe device was not found with the ID or the external entity values provided
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Steps to send summarized information

9. Request processed events

There are some telemetry events that must be processed from the provider side. These are complex telemetry events that involve physical sensors of the vehicle and needs to be calculated within the provider system. For that purpose the provider should provide a HTTP REST endpoint to allow Mercado Envios to request processed telemetry events.

Important:

Request Format

A message with the following structure will be sent:

bash
1POST https://{PROVIDER_URL}/rtt/commands

The body attributes are explained below:

NameType of dataDescriptionType
idStringUnique identifier in Base64.Mandatory
transportNodeInformation about the transport where the device is used.Mandatory
transport.idNumberTransport identifier generated by Mercado Libre. This identifier will be needed when creating a device.Mandatory
transport.license_plateStringLicense plate is the common identifier known to both systems.Mandatory
transport.country_idStringID of the country where the vehicle is registered. The Country Id must be taken from this resource.Mandatory
travelNodeInformation related to the travel.Mandatory
travel.init_dateDate (ISO8601)Date and time of travel start. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
travel.end_dateDate (ISO8601)Date and time of travel end. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
commandStringA string value representing a specific event: ["process_telemetry_events"].Mandatory
json
1{ 2 "id": "string", 3 "transport": { 4 "id": "number", 5 "license_plate": "string", 6 "country_id": "string" 7 }, 8 "travel": { 9 "init_date": "date", 10 "end_date": "date" 11 }, 12 "command": "string" 13}

Status Codes

StatusDescriptionAction
200Valid requestIt will not retry.
400Data validation failedDepending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The client does not have permissionIt will not retry.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "id": "first_mile12358", 3 "transport": { 4 "id": 5666447, 5 "license_plate": "1234ABC", 6 "country_id": "BR" 7 }, 8 "travel": { 9 "init_date": "2022-01-20T18:35:40.235Z", 10 "end_date": "2022-01-20T23:35:40.235Z" 11 }, 12 "command": "process_telemetry_events" 13}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}

10. Send Processed events

Once received the request for sending processed events, the provider must prepare these data and send it back with the following proposed structure:

bash
1POST https://api.mercadolibre.com/shipping/rtt/georeceiver/{provider}/telemetry/events/deferred?country_id={countryId}

Header

NameType of dataDescription
AuthorizationStringAuthorization token for the request. The header value should be the word Bearer plus the generated token. Eg. Authorization: Bearer token.

Params

NameType of dataType of paramDescriptionType
country_idStringQueryID of the country where the device is operational. The Country Id must be taken from this resource.Mandatory
providerStringPathProvider name.Mandatory

The body attributes are explained below:

NameType of dataDescriptionType
idStringUnique identifier in Base64.Mandatory
route_distanceNumberRoute distance, expressed in kilometers.Mandatory
transport_idNumberTransport identifier generated by Mercado Libre. This identifier will be needed when creating a device.Mandatory
post_timestampIntegerLocal UTC time at the moment of sending the data, in seconds since epoch (January 1, 1970).Mandatory
eventsArrayArray of objects with telemetry events information.Mandatory
events[i].nameStringEvent names. Valid values: harsh_braking, harsh_acceleration, unfastened_seatbelt, sharp_turn, speeding_route, speeding_opsMandatory
events[i].start_dateDate (ISO8601)Event start date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
events[i].end_dateDate (ISO8601)Event end date and time. Valid values: UTC 2001-07-04T12:08
.235Z or relative local time 2001-07-04T12:08
.235-07
.
Mandatory
events[i].distanceNumberEvent distance, expressed in meters.Optional
events[i].latitudeNumberGPS latitude in degrees.Optional
events[i].longitudeNumberGPS longitude in degrees.Optional
events[i].metadataArrayArray with the description of the event.Optional
events[i].metadata[i].nameStringName of the description.Mandatory
events[i].metadata[i].valueStringValue of the description.Mandatory
json
1{ 2 "id": "string", 3 "route_distance": "number", 4 "transport_id": "number", 5 "post_timestamp": "number", 6 "events": [ 7 { 8 "name": "string", 9 "start_date": "date", 10 "end_date": "date", 11 "distance": "number", 12 "latitude": "number", 13 "longitude": "number", 14 "metadata": [ 15 { 16 "name": "string", 17 "value": "string" 18 } 19 ] 20 } 21 ] 22}

Status Codes

StatusDescriptionAction
202valid requestIt will not retry.
400Data validation failed.Depending on the nature of the error, attempts will be made to correct the data, before re-processing the request. There should be no periodic retry.
403The device has not permissionIt will not retry.
429Too many requestTry again after five minutes.
500Internal Server ErrorIt will retry indefinitely until a satisfactory response is obtained.

Examples

Request

json
1{ 2 "id": "first_mile12358", 3 "route_distance": 278, 4 "transport_id": 5666447, 5 "post_timestamp": 161980861, 6 "events": [ 7 { 8 "name": "speeding_route", 9 "start_date": "2022-01-20T18:35:40.235Z", 10 "end_date": "2022-01-20T18:50:40.235Z", 11 "distance": 150, 12 "latitude": -34.5743988, 13 "longitude": -58.4845495, 14 "metadata": [ 15 { 16 "name": "speeding", 17 "value": "130" 18 } 19 ] 20 } 21 ] 22}

Response

json
1{ 2 "status": 200, 3 "message": "success" 4}