Re-Assigning an Existing Route to another User

See files for this Use Case on the GitHub here

Description

You can add as many users as you need to your account, as long as you stay within the total number of users permitted with your subscription plan.

You can share the routes with your employees or sub-contractors via e-mail or send them to their mobile device. Usually, if you use a sub-contractor time just once, you can send them a route by e-mail. But if you are sharing a route with a full-time employee, it is better to assign route to him directly.

Assigning routes to drivers can be helpful when splitting up the deliveries of your service. Splitting up the work between drivers is a great way to get the most out of the Route4Me service.

Solution

Optimization Parameters and addresses

Please pay attention to the following parameters, so you can apply correct parameters for this use case:

ParameterTypeDescriptionHTTP method
api_keystringAPI KEY of the userGET
redirectintegerif equal to 1, will be redirected, if 0 - notGET
addressesarrayValid JSON array of Address objects. Click here to see the JSON SchemaPOST
parametersRoute ParametersValid JSON string of RouteParameters object. Click here to see the JSON SchemaPOST

You can see the addresses on a map as:

Create an Optimization

You can create new optimization for this use case example. From the cUrl example bellow you can see that:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 :: Multiple Depot, Multiple Driver with 24 Stops, Time Window
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter2
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 SET route_path_output=Points
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -X POST -k -d "@multi_depot_multi_driver_24stops_tw_data.json" "%URL%?api_key=%apikey%&route_path_output=%route_path_output%"
13 
14 timeout /t 30

You can expect an Optimization problem (see link), which generated 5 routes already.

View the Optimization details

You can get more details from the newly created optimization problem:

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

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 SET url=http://www.route4me.com/api.v4/optimization_problem.php
3 SET apikey=11111111111111111111111111111111
4 SET optprobid=5EFE03905D296A286DC741432C4FE081
5 
6 ECHO ON
7 curl -o file1.txt -g -X GET -k "%URL%?api_key=%apikey%&optimization_problem_id=%optprobid%"
8 
9 timeout /t 30

See sample RESPONSE JSON data here

The system will send a RESPONSE with an array of addresses which belong to 5 generated routes:

"route_id": "3F0F18E21A3A4411027EC277449D2878" - 5 addresses;
"route_id": "4F9A4259F7C80127349ED8BB7F62A9E9" - 5 addresses;
"route_id": "9F019B4481C6566F7E338136DAC0B89E" - 11 addresses;
"route_id": "A1D840B5A4CE2A5D3840CA3C99593A6F" - 5 addresses;
"route_id": "D2F21FAD3F92C55ADA81FC841CCA3A1A" - 5 addresses.

Details of the Optimized Routes

See example for one route below. You can get the details of the remaining routes by using the same method and changing the parameter route_id.

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

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 SET url=https://www.route4me.com/api.v4/route.php
3 SET apikey=11111111111111111111111111111111
4 SET routeid=3F0F18E21A3A4411027EC277449D2878
5 SET rpo=Points
6 
7 ECHO ON
8 
9 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
10 
11 timeout /t 30

See sample RESPONSE JSON data here

Note
In the RESPONSE you can see the array of the fields path_to_next **. Those will be used to draw routes on a map, exactly as they generated by Route4Me API.

You can see a route on the map drawn by the Route4Me API as:

You can see all 5 routes drawn by the Route4Me API as:

Create a Driver with Route4Me API

You can create user account and each driver's acounts using Route4Me API.

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
plan string The plan type that the user selected - ENUM(free, basic, pro, premium, personal) GET
business_member_type string Member type of the user GET
strIndustry string The industry of the user POST
strFirstName string The first name of the user POST
strLastName string The last name of the user POST
strEmail string The email of the user POST
format string Response fromat ENUM [xml, json] POST
chkTerms integer If equal to 1, the user agreed to the terms of the site checkbox POST
device_type string Device type ("web", "iphone", "ipad", etc) POST
strPassword_1 string Password associated with this e-mail address POST
strPassword_2 string Password confirmation field

POST


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

Attention
New user registration process requires user to provide a unique email. You can't register with the email from example below.
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

Assign a Route to a Driver

You can reassign a route to a user (a driver, a sub-contractor). Let's pay attention to the route with route_id=4F9A4259F7C80127349ED8BB7F62A9E9 and to the block of the parameters in the appropriate RESPONSE JSON file (see the file here):

"member_id": 1,
"member_email": "[email protected]",
"member_first_name": "David",
"member_last_name": "Progman"

As you can notice, this route belongs to the user with member_id=1. You can reassign the route to the newly created driver with member_id=315948.

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

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


See sample INPUT JSON data here

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

See sample RESPONSE JSON data here

Pay attention to this parameter in the RESPONSE JSON file:

"driver_id": "315948"

Re-Assigning a Route to an User

You can re-assign a route to a sub-contractor user.

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

HTTP Parameters

Attribute Type Description HTTP
method
api_key string API KEY of the user GET
route_id string Route ID GET
member_id integer Member ID POST
member_email string Member e-mail POST
member_first_name string Member first name POST
member_last_name string Member last name POST


See sample INPUT JSON data here

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

See sample RESPONSE JSON data here

Pay attention to this block of the parameters in the RESPONSE JSON file:

"member_id": 44194,
"member_email": "[email protected]",
"member_first_name": "JC",
"member_last_name": "Valenzuela"