Route4Me Use Cases: Dynamically Create a Fleet of Drivers

Dynamically Create a Fleet of Drivers

Attention
Please note that the content may be updated late as we expect a new versions of the endpoints that we discuss here.

Please see files for this Use Case on the GitHub here

You can dynamically create a fleet of drivers and allocate them to vehicles and routes, and then track their activity.

Description

Route4Me offers advanced team management features which you can use to effectively handle the way your routes are split among your drivers. User types in Route4Me application allow you to better manage and control your team members' accounts by setting different permissions for each user. The user of a "Driver" type can only view and edit routes assigned to them. Drivers also can synchronize their routes and navigate a route.

Solution

Get Information about Drivers Fleet

Suppose your company is planning routes with multi-driver option. You can split addresses you need to visit between different routes and allocate a driver to each route. First of all you need to know the list of existing fleet drivers. You can get information about drivers that belong to your account.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
query string Text to be searched in some fields (member_first_name, member_last_name, member_email GET


The endpoint: https://www.route4me.com/api.v4/user.php

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/user.php
4 SET apikey=11111111111111111111111111111111
5 
6 :: The example refers to the process of getting the existing sub-users.
7 
8 ECHO ON
9 
10 curl -o member_get_subusers_RESPONSE.json -g -X GET -k "%URL%?api_key=%apikey%&ofset=0&limit=10"
11 
12 timeout /t 30

See sample RESPONSE JSON data here.

Create a Driver in a Route4Me Account

On your Route4Me account page, go to the “Team” tab, then click on “Users”.

All users under your account are arranged in a hierarchical structure. To add a new user, click “Add Sub-User” underneath the appropriate team leader and a new window will open.

When adding a user, be sure to fill in all required fields on the left section. You need to enter user's first and last name, e-mail, set a password for a user and assign a user type. Note that the valid email address is required. The email associated with a user can only be changed under that user's account.

Create a Driver with Route4Me API

You can create a user's account and, in particular, driver's account using Route4Me API.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of a user GET
HIDE_ROUTED_ADDRESSES string Hide routed sddresses, enum('TRUE', 'FALSE') POST
member_phone string A phone number of the user POST
member_zipcode string The 5-7 digit ZIP code (minimum length of 5)) POST
member_email string E-mail address of the user that was used for site registration. POST
HIDE_VISITED_ADDRESSES string Hide visited sddresses, enum('TRUE', 'FALSE') POST
READONLY_USER string Readonly user, enum('TRUE', 'FALSE') POST
member_type string Member type, enum (PRIMARY_ACCOUNT, SUB_ACCOUNT_ADMIN, SUB_ACCOUNT_REGIONAL_MANAGER, SUB_ACCOUNT_DISPATCHER, SUB_ACCOUNT_DRIVER) POST
date_of_birth string Date of birth POST
member_first_name string The first name of the user. POST
member_password string Member Password. POST
HIDE_NONFUTURE_ROUTES string Hide non-future routes, enum('TRUE', 'FALSE').

POST

member_last_name string The last name of the user. POST
SHOW_ALL_VEHICLES string Show all vehicles, enum('TRUE', 'FALSE'). POST
SHOW_ALL_DRIVERS string Show all drivers, enum('TRUE', 'FALSE')

POST


The endpoint: https://www.route4me.com/actions/register_action.php

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/actions/register_action.php
4 SET apikey=11111111111111111111111111111111
5 SET plan=free
6 
7 :: The example refers to a registration new Route4Me account.
8 
9 ECHO ON
10 
11 curl -k -X POST -H "Content-Type: multipart/form-data;" -F "strIndustry=Gifting" -F "strFirstName=Olman" -F "strLastName=Oland" -F "[email protected]" -F "format=json" -F "chkTerms=1" -F "device_type=web" -F "strPassword_1=111111" -F "strPassword_2=111111" "%url%?plan=%plan%&business_member_type=SUB_ACCOUNT_DRIVER"
12 
13 timeout /t 30

See sample RESPONSE JSON data here

Add a Driver to a Route

You can either assing a driver to a route during the optimization problem generation stage, or you can do that later. Suppose you have an already generated optimization problem with optimization_problem_id = 38D4E661BB49089B92C7722F86ED7181 and 5 optimized routes (see link here). Let us select a route with route_id = 43F55835F1E76003FF980547F77338BD and assign to a driver.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
driver_id integer Driver ID POST


The endpoint: http://www.route4me.com/api.v4/route.php

1 @ECHO OFF
2 
3 SET url=http://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=43F55835F1E76003FF980547F77338BD
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -X PUT -H "Content-Type: application/json" -d "@update_route_data.json" "%url%?route_id=%routeid%&api_key=%apikey%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Pay attention to this part of the response:

"driver_id": "45837"
Note
you can change a driver associated with a route by using same endpoint described above - just put another driver_id value.

Change an Owner of a Driver

If a company has a complex TSM system and has several dispatchers, the managers need to have ability to change an owner of a driver. You can do that with Route4Me API.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
member_id integer Driver ID PUT
OWNER_MEMBER_ID integer ID of a driver's owner PUT


The endpoint: https://www.route4me.com/api.v4/user.php

1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/user.php
4 SET apikey=11111111111111111111111111111111
5 
6 :: The example refers to the process of changing a member's owner.
7 
8 ECHO ON
9 
10 curl -o member_edit_RESPONSE.json -g -X PUT -d "@change_member_owner_data.json" -k "%url%?api_key=%apikey%"
11 
12 timeout /t 30

You can expect this RESPONSE:

{
"member_first_name": "Clay",
"member_id": "888888",
"member_last_name": "Abraham",
"member_email": "[email protected]",
"preferred_units": null,
"preferred_language": "en",
"timezone": "America\/New_York",
"member_zipcode": "22102",
"OWNER_MEMBER_ID": "889999",
"member_type": "SUB_ACCOUNT_DRIVER",
"member_phone": "571-259-5939",
"user_reg_state_id": null,
"user_reg_country_id": null,
"date_of_birth": "1995-10-01",
"HIDE_ROUTED_ADDRESSES": "",
"HIDE_VISITED_ADDRESSES": "",
"HIDE_NONFUTURE_ROUTES": "",
"READONLY_USER": "",
"SHOW_ALL_DRIVERS": "",
"SHOW_ALL_VEHICLES": "FALSE",
"member_picture": null,
"api_key": "B60EAC4F65490B0E2222222222222222",
"custom_data": []
}