Drivers API¶
Summary¶
| Resource | Operation | Description |
|---|---|---|
| Drivers | GET /dcs/(dc_id)/drivers/(driver_id)/driver_bulk_info | Get driver metadata and location. |
| PATCH /dcs/(dc_id)/drivers/(driver_id)/finish-routes | Finish all active routes assigned to this driver | |
| PUT /dcs/(dc_id)/drivers/(driver_id)/finish-routes | ||
| GET /dcs/(dc_id)/drivers/(driver_id)/active-routes | Get all active routes assigned to this driver | |
| GET /dcs/(dc_id)/drivers/(driver_id)/location | Get the latest known location of this driver | |
| GET /dcs/(dc_id)/drivers/(driver_id) | Get a driver | |
| PATCH /dcs/(dc_id)/drivers/(driver_id) | Update a driver | |
| DELETE /dcs/(dc_id)/drivers/(driver_id) | Delete a driver | |
| POST /dcs/(dc_id)/drivers | Create a driver | |
| GET /dcs/(dc_id)/drivers | Get all drivers for the dc |
Details¶
-
GET/dcs/(dc_id)/drivers/(driver_id)/driver_bulk_info¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK –
ref: The latest known location of this driver is returned. - 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example response
{ "status": "success", "data": { "driver": { "id": "the driver's id", "login_token": "secret-login-token", "name": "the driver's name" } "driver_location": { "timestamp": 1567702800000, "location": { "latitude": 37.7749, "longitude": -122.4194 } } } }
Please note that if the driver exists but has not reported any locations to Foxtrot, the driver_location object may be null.
-
PATCH/dcs/(dc_id)/drivers/(driver_id)/finish-routes¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK – Routes were finalized.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
-
PUT/dcs/(dc_id)/drivers/(driver_id)/finish-routes¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK – Routes were finalized.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
-
GET/dcs/(dc_id)/drivers/(driver_id)/active-routes¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK –
ref: List of active routes for driver is returned. - 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example response
{ "status": "success", "data": { "active_routes": [{ "planned_start_time": 1567702800000, "route_id": "route id", }, { "planned_start_time": 1567731600000, "route_id": "route id 2", }] } }
-
GET/dcs/(dc_id)/drivers/(driver_id)/location¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK –
ref: The latest known location of this driver is returned. - 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example response
{ "status": "success", "data": { "driver_location": { "timestamp": 1567702800000, "location": { "latitude": 37.7749, "longitude": -122.4194 } } } }
Please note that if the driver exists but has not reported any locations to Foxtrot, the driver_location object may be null.
-
GET/dcs/(dc_id)/drivers/(driver_id)¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK – Driver object is returned.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example response
{ "status": "success", "data": { "driver": { "id": "the driver's id", "login_token": "secret-login-token", "name": "the driver's name" } } }
-
PATCH/dcs/(dc_id)/drivers/(driver_id)¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Request JSON Object: - driver_name (string) – The driver’s new name
Status Codes: - 200 OK – Driver was updated.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example request
{ "driver_name": "John's new name" }
-
DELETE/dcs/(dc_id)/drivers/(driver_id)¶ Parameters: - dc_id (string) – The dc id
- driver_id (string) – The driver’s id
Status Codes: - 200 OK – Driver was deleted.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
-
POST/dcs/(dc_id)/drivers¶ Parameters: - dc_id (string) – The dc id
Request JSON Object: - driver_name (string) – The driver’s name
- driver_id (string) – The driver’s id
Status Codes: - 200 OK – Driver was created.
- 400 Bad Request – Check error code within the response.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
Error Code Description 2000 Driver with that id already exists. Example request
{ "driver_name": "John", "login_token": "secret-login-token", "driver_id": "John's id" }
-
GET/dcs/(dc_id)/drivers¶ Parameters: - dc_id (string) – The dc id
Status Codes: - 200 OK – Driver objects are returned.
- 401 Unauthorized – API key is invalid.
- 403 Forbidden – DC does not exist or user does not have permission to access it.
- 404 Not Found – Driver does not exist.
Example response
{ "status": "success", "data": { "drivers": [{ "id": "the driver's id", "login_token": "secret-login-token", "name": "the driver's name" }, { "id": "the driver's id 2", "login_token": "secret-login-token", "name": "the driver's name 2" }] } }