Skip to main content
GuidesExamples

Add Orders to an Route

Estimated reading time: 25 minutes

Overview

This example demonstrates how to add a list of orders into an existing route's order list at optimal positions determined by the algorithm. The orders will be inserted between existing route orders without rearranging them. If the route is reoptimized, the orders will be rearranged in the best order of visit, and you may not see them inserted at the original optimal positions.

The added orders will also be included in the optimization's order list.

How to Use the Sample

When you run the example application:

  1. The existing route will be updated with new orders.
  2. The orders will be inserted at the best possible positions without altering the current order sequence.
  3. If reoptimization is enabled, the entire route will be rearranged for optimal efficiency.

Step-by-Step Guide

Step 1: Retrieve Customers

To create an order we can use an existing customer to assign the order to, or we can create a new one. In this example we will use two customers already existing in the database. To see how to retrieve customers from the database, you can refer to the Get Cutsomer documentation.

Example:

  • Response Body: (error code 200)
[
{
"id": 1811911,
"alias": "Customer 13",
"firstName": "Customer13",
"lastName": "Customer13",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer13@example.com",
"phoneNumber": "+120255501813",
"location": [
48.868507,
2.359727
],
"customData": ""
},
{
"id": 1811912,
"alias": "Customer 14",
"firstName": "Customer14",
"lastName": "Customer14",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer14@example.com",
"phoneNumber": "+120255501814",
"location": [
48.867329,
2.348105
],
"customData": ""
}
]

Step 2: Create Orders

Initializing and Adding Orders

  1. Initialize Orders: Create two Order objects and associate each with a customer. Populate fields such as time windows, package details, and weights.
  2. Send Request: Call the Add Orders endpoint to save these orders in the system.
  • Method: POST
  • Endpoint: /orders
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-Type: application/json
  • URL: https://fleetmanagement.magiclaneapis.com/v1/orders

Example:

  • Request Body:
[
{
"customerId": 1811911,
"location": [
48.868507,
2.359727
],
"alias": "Customer 13",
"firstName": "Customer13",
"lastName": "Customer13",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501813",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 3.1,
"cube": 0.2,
"revenue": 3.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1811912,
"location": [
48.867329,
2.348105
],
"alias": "Customer 14",
"firstName": "Customer14",
"lastName": "Customer14",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501814",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 4,
"weight": 4.1,
"cube": 0.3,
"revenue": 4.2,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
}
]
  • Response Body: (error code 200)
[
{
"id": 899037,
"customerId": 1811911,
"location": [
48.868507,
2.359727
],
"alias": "Customer 13",
"firstName": "Customer13",
"lastName": "Customer13",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501813",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 3.1,
"cube": 0.2,
"revenue": 3.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 899038,
"customerId": 1811912,
"location": [
48.867329,
2.348105
],
"alias": "Customer 14",
"firstName": "Customer14",
"lastName": "Customer14",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501814",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 4,
"weight": 4.1,
"cube": 0.3,
"revenue": 4.2,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
}
]

Step 4: Retrieve the existing Route

To add orders to an route, you have to retrieve that route by id.

  • Method: GET
  • Endpoint: /routes/{id}
  • Headers:
    • Authorization: YOUR_API_KEY
  • URL: https://fleetmanagement.magiclaneapis.com/v1/routes/{id}
  • Path Parameter:
    • id (integer, *required) - The unique route ID.
  • Query Parameter:
    • encodeShape (integer, optional)
      • 0: The route's shape will not be encoded.
      • 1 (default): The route's shape will be encoded.

Example:

  • Response Body: (error code 200)
{
"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 0,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 1,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Test optimization - DeleteCustomerFromServiceWithOrdersInOptimizationAndService - Part 0"
},
"vehicleConstraints": {
"startDate": 1602633600000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 100000000,
"maxRevenue": 100000000,
"fuelPrice": 1.190000057220459
},
"rideStatus": 1,
"vehicle": {
"length": 0,
"weight": 0,
"width": 0,
"licensePlate": "",
"consumption": 6.5,
"fuelType": 3,
"make": "Kia",
"id": 137533,
"name": "Car vehicle",
"model": "Ceed",
"costPerHour": 0,
"type": 0,
"status": 0,
"maxLoadWeight": 100000000,
"height": 0,
"maxLoadCube": 100000000,
"idDriver": 137533,
"endTime": 3060,
"fixedCost": 0,
"startTime": 1020,
"lastPosition": [
2147483647,
2147483647
]
},
"destination": {
"depotId": 0,
"alias": "departure1",
"address": {
"streetNumber": "34",
"postalCode": "86000",
"streetName": "Boulevard Chasseigne",
"county": "Nouvelle-Aquitaine",
"state": "",
"extra": "",
"city": "Poitiers",
"country": "France"
},
"location": [
48.457382,
-0.054054
],
"matchedLocation": [
48.45707125,
-0.05397125
],
"arrivalTime": 1602806436000,
"traveledDistance": 2549.0986328125
},
"departure": {
"depotId": 0,
"alias": "departure1",
"address": {
"streetNumber": "34",
"postalCode": "86000",
"streetName": "Boulevard Chasseigne",
"county": "Nouvelle-Aquitaine",
"state": "",
"extra": "",
"city": "Poitiers",
"country": "France"
},
"location": [
48.457382,
-0.054054
],
"matchedLocation": [
48.45707125,
-0.05397125
],
"numberOfpackages": 0,
"weight": 0,
"cube": 0,
"departureTime": 1602694800000,
"timeToNext": 10141,
"distanceToNext": 318.5107421875
},
"shape": "sgwfHjpIAm@DYt@_DJw@?]a@kGOaIO{FY{F?}AlFugAxB}d@vAea@JsCB}D_@}[BqAFyAJeAh@oC`@_BfAaDv@qBvA}C`@uATaApA_HXmAT}@f@oArA}CZw@nD_Lr@}An@eArAaBrAqAhF_Gl@}@\\w@`@oAjBiH`@oAv@mBv@iBV]TMTATUH]A_@COBk@VkApAyD~@aDXmAd@aCt@cGj@wFFOj@kIRgERyGJeI?sDGkGIcDyCg{@s@}Nc@gIaAyMsCm[cLcjAi@qEcAgHw@kEwBsIe@cBkTgr@iHwVeAgEeDgNeNwm@k@yCg@{DQ_B[wFGwE?cCRoFXyDd@{Db@aCz@yDf@gBjA",
"creationTimestamp": 1743498523095,
"neededFuel": 165.69140625,
"matrixBuildType": 1,
"price": 197.17279052734375,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 138624,
"orders": [
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514938,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898870,
"location": [
46.199373,
0.069986
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c21@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811757,
"location": [
46.199373,
0.069986
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
46.1988575,
0.0709096875
],
"actualLocation": [
0,
0
],
"indexInRoute": 0,
"indexInOptimization": 2,
"arrivalTime": 1602704941000,
"timeToNextOrder": 14681,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 318.5107421875,
"distanceToNextOrder": 300.998046875,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514874,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898869,
"location": [
45.049782,
2.475759
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c11@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811756,
"location": [
45.049782,
2.475759
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
45.0504703125,
2.4740134375
],
"actualLocation": [
0,
0
],
"indexInRoute": 1,
"indexInOptimization": 1,
"arrivalTime": 1602719622000,
"timeToNextOrder": 5591,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 619.5087890625,
"distanceToNextOrder": 94.72080993652344,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515118,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898873,
"location": [
44.464582,
2.45502
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c51@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811760,
"location": [
44.464582,
2.45502
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
44.4659359375,
2.4531175
],
"actualLocation": [
0,
0
],
"indexInRoute": 2,
"indexInOptimization": 5,
"arrivalTime": 1602725213000,
"timeToNextOrder": 13583,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 714.2296142578125,
"distanceToNextOrder": 317.7894592285156,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515058,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898872,
"location": [
44.346051,
4.694878
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c41@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811759,
"location": [
44.346051,
4.694878
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
44.34524125,
4.6933515625
],
"actualLocation": [
0,
0
],
"indexInRoute": 3,
"indexInOptimization": 4,
"arrivalTime": 1602738796000,
"timeToNextOrder": 14457,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1032.01904296875,
"distanceToNextOrder": 367.3101501464844,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515364,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898877,
"location": [
46.851831,
5.941769
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c91@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811764,
"location": [
46.851831,
5.941769
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
46.8518,
5.9413090625
],
"actualLocation": [
0,
0
],
"indexInRoute": 4,
"indexInOptimization": 9,
"arrivalTime": 1602753253000,
"timeToNextOrder": 10286,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1399.3292236328125,
"distanceToNextOrder": 250.83740234375,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515179,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898874,
"location": [
48.43446,
5.234103
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c61@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811761,
"location": [
48.43446,
5.234103
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.4331953125,
5.2355121875
],
"actualLocation": [
0,
0
],
"indexInRoute": 5,
"indexInOptimization": 6,
"arrivalTime": 1602763539000,
"timeToNextOrder": 8770,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1650.1666259765625,
"distanceToNextOrder": 207.42904663085938,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515487,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898879,
"location": [
48.332842,
3.125077
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c111@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811766,
"location": [
48.332842,
3.125077
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.33309,
3.125410625
],
"actualLocation": [
0,
0
],
"indexInRoute": 6,
"indexInOptimization": 11,
"arrivalTime": 1602772309000,
"timeToNextOrder": 8998,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1857.595703125,
"distanceToNextOrder": 191.96372985839844,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515303,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898876,
"location": [
47.0839,
3.273493
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c81@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811763,
"location": [
47.0839,
3.273493
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
47.083435625,
3.274508125
],
"actualLocation": [
0,
0
],
"indexInRoute": 7,
"indexInOptimization": 8,
"arrivalTime": 1602781307000,
"timeToNextOrder": 6707,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2049.559326171875,
"distanceToNextOrder": 114.37818908691406,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514998,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898871,
"location": [
47.602138,
2.330583
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c31@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811758,
"location": [
47.602138,
2.330583
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
47.6008803125,
2.3348309375
],
"actualLocation": [
0,
0
],
"indexInRoute": 8,
"indexInOptimization": 3,
"arrivalTime": 1602788014000,
"timeToNextOrder": 7391,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2163.9375,
"distanceToNextOrder": 145.3060302734375,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515426,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898878,
"location": [
48.512232,
1.546783
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c101@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811765,
"location": [
48.512232,
1.546783
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.5120375,
1.547229375
],
"actualLocation": [
0,
0
],
"indexInRoute": 9,
"indexInOptimization": 10,
"arrivalTime": 1602795405000,
"timeToNextOrder": 6512,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2309.24365234375,
"distanceToNextOrder": 127.15222930908203,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515242,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898875,
"location": [
49.161539,
0.50058
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c71@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811762,
"location": [
49.161539,
0.50058
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
49.1636175,
0.5046125
],
"actualLocation": [
0,
0
],
"indexInRoute": 10,
"indexInOptimization": 7,
"arrivalTime": 1602801917000,
"timeToNextOrder": 4489,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2436.39599609375,
"distanceToNextOrder": 112.42899322509766,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514818,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898868,
"location": [
48.458357,
-0.054451
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c01@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811755,
"location": [
48.458357,
-0.054451
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.4585184375,
-0.053071875
],
"actualLocation": [
0,
0
],
"indexInRoute": 11,
"indexInOptimization": 0,
"arrivalTime": 1602806406000,
"timeToNextOrder": 30,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2548.824951171875,
"distanceToNextOrder": 0.27365899085998535,
"revenueAtArrival": 0,
"visitTimestamp": 0
}
],
"totalTime": 111636,
"totalDistance": 2549.0986328125,
"id": 252963
}

Step 5: Add Orders to the Route

Once the orders are created, they need to be added to the route.

  • Method: POST
  • Endpoint: /routes/{id}/orders
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-Type: application/json
  • URL: https://fleetmanagement.magiclaneapis.com/v1/routes/{id}/orders
  • Path Parameter:
    • id (integer, *required) - The unique route ID.
  • Query Parameters:
    • reoptimize (integer, , not required) - 0: (default) - If the route will not be re-optimized, the orders will be added to the end of the route.
      • 1 : The route will be re-optimized.
    • encodeShape (integer, not required) - 0 : The route's shape will not be encoded.
      • 1 :(default) - The route's shape will be encoded.
Note

There are three options to add orders to a route:

  • at the end of the route's orders list.
  • at the optimal positions, which are determined by the algorithm.The orders are inserted at the best positions between the route's orders, without rearranging the route's orders.
  • at specified positions between the route's orders.

The route can be reoptimized, which means that after the addition, the route orders will be rearranged in the best order of visit, so it doesn’t matter which option was chosen to add the orders. The orders will be also added in the list of orders of the route's optimization.

Example:

  • Request Body:
{
"orders": [
{
"id": 899037,
"position": 0
},
{
"id": 899038,
"position": 0
}
],
"optimalPosition": true,
}
  • Response Body: (error code 200)
note

There are two possible responses:

  1. If the route is reoptimized, the response will be a request object with the status of the request.
  2. If the route is not reoptimized, the response will be the updated route.

In this case the route won't be reoptimized.

{
"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 0,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 1,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Test optimization - DeleteCustomerFromServiceWithOrdersInOptimizationAndService - Part 0"
},
"vehicleConstraints": {
"startDate": 1602633600000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 100000000,
"maxRevenue": 100000000,
"fuelPrice": 1.190000057220459
},
"rideStatus": 1,
"vehicle": {
"length": 0,
"weight": 0,
"width": 0,
"licensePlate": "",
"consumption": 6.5,
"fuelType": 3,
"make": "Kia",
"id": 137533,
"name": "Car vehicle",
"model": "Ceed",
"costPerHour": 0,
"type": 0,
"status": 0,
"maxLoadWeight": 100000000,
"height": 0,
"maxLoadCube": 100000000,
"idDriver": 137533,
"endTime": 3060,
"fixedCost": 0,
"startTime": 1020,
"lastPosition": [
2147483647,
2147483647
]
},
"destination": {
"depotId": 0,
"alias": "departure1",
"address": {
"streetNumber": "34",
"postalCode": "86000",
"streetName": "Boulevard Chasseigne",
"county": "Nouvelle-Aquitaine",
"state": "",
"extra": "",
"city": "Poitiers",
"country": "France"
},
"location": [
48.457382,
-0.054054
],
"matchedLocation": [
48.45707125,
-0.05397125
],
"arrivalTime": 1602806436000,
"traveledDistance": 2549.0986328125
},
"departure": {
"depotId": 0,
"alias": "departure1",
"address": {
"streetNumber": "34",
"postalCode": "86000",
"streetName": "Boulevard Chasseigne",
"county": "Nouvelle-Aquitaine",
"state": "",
"extra": "",
"city": "Poitiers",
"country": "France"
},
"location": [
48.457382,
-0.054054
],
"matchedLocation": [
48.45707125,
-0.05397125
],
"numberOfpackages": 0,
"weight": 0,
"cube": 0,
"departureTime": 1602694800000,
"timeToNext": 10141,
"distanceToNext": 318.5107421875
},
"shape": "sgwfHjpIAm@DYt@_DJw@?]a@kGOaIO{FY{F?}AlFugAxB}d@vAea@JsCB}D_@}[BqAFyAJeAh@oC`@_BfAaDv@qBvA}C`@uATaApA_HXmAT}@f@oArA}CZw@nD_Lr@}An@eArAaBrAqAhF_Gl@}@\\w@`@oAjBiH`@oAv@mBv@iBV]TMTATUH]A_@COBk@VkApAyD~@aDXmAd@aCt@cGj@wFFOj@kIRgERyGJeI?sDGkGIcDyCg{@s@}Nc@gIaAyMsCm[cLcjAi@qEcAgHw@kEwBsIe@cBkTgr@iHwVeAgEeDgNeNwm@k@yCg@{DQ_B[wFGwE?cCRoFXyDd@{Db@aCz@yDf@gBjA",
"creationTimestamp": 1743498523095,
"neededFuel": 165.69140625,
"matrixBuildType": 1,
"price": 197.17279052734375,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 138624,
"orders": [
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514938,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898870,
"location": [
46.199373,
0.069986
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c21@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811757,
"location": [
46.199373,
0.069986
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
46.1988575,
0.0709096875
],
"actualLocation": [
0,
0
],
"indexInRoute": 0,
"indexInOptimization": 2,
"arrivalTime": 1602704941000,
"timeToNextOrder": 14681,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 318.5107421875,
"distanceToNextOrder": 300.998046875,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514874,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898869,
"location": [
45.049782,
2.475759
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c11@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811756,
"location": [
45.049782,
2.475759
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
45.0504703125,
2.4740134375
],
"actualLocation": [
0,
0
],
"indexInRoute": 1,
"indexInOptimization": 1,
"arrivalTime": 1602719622000,
"timeToNextOrder": 5591,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 619.5087890625,
"distanceToNextOrder": 94.72080993652344,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515118,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898873,
"location": [
44.464582,
2.45502
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c51@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811760,
"location": [
44.464582,
2.45502
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
44.4659359375,
2.4531175
],
"actualLocation": [
0,
0
],
"indexInRoute": 2,
"indexInOptimization": 5,
"arrivalTime": 1602725213000,
"timeToNextOrder": 13583,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 714.2296142578125,
"distanceToNextOrder": 317.7894592285156,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515058,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898872,
"location": [
44.346051,
4.694878
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c41@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811759,
"location": [
44.346051,
4.694878
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
44.34524125,
4.6933515625
],
"actualLocation": [
0,
0
],
"indexInRoute": 3,
"indexInOptimization": 4,
"arrivalTime": 1602738796000,
"timeToNextOrder": 14457,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1032.01904296875,
"distanceToNextOrder": 367.3101501464844,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515364,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898877,
"location": [
46.851831,
5.941769
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c91@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811764,
"location": [
46.851831,
5.941769
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
46.8518,
5.9413090625
],
"actualLocation": [
0,
0
],
"indexInRoute": 4,
"indexInOptimization": 9,
"arrivalTime": 1602753253000,
"timeToNextOrder": 10286,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1399.3292236328125,
"distanceToNextOrder": 250.83740234375,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515179,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898874,
"location": [
48.43446,
5.234103
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c61@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811761,
"location": [
48.43446,
5.234103
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.4331953125,
5.2355121875
],
"actualLocation": [
0,
0
],
"indexInRoute": 5,
"indexInOptimization": 6,
"arrivalTime": 1602763539000,
"timeToNextOrder": 8770,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1650.1666259765625,
"distanceToNextOrder": 207.42904663085938,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515487,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898879,
"location": [
48.332842,
3.125077
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c111@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811766,
"location": [
48.332842,
3.125077
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.33309,
3.125410625
],
"actualLocation": [
0,
0
],
"indexInRoute": 6,
"indexInOptimization": 11,
"arrivalTime": 1602772309000,
"timeToNextOrder": 8998,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1857.595703125,
"distanceToNextOrder": 191.96372985839844,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515303,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898876,
"location": [
47.0839,
3.273493
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c81@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811763,
"location": [
47.0839,
3.273493
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
47.083435625,
3.274508125
],
"actualLocation": [
0,
0
],
"indexInRoute": 7,
"indexInOptimization": 8,
"arrivalTime": 1602781307000,
"timeToNextOrder": 6707,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2049.559326171875,
"distanceToNextOrder": 114.37818908691406,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514998,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898871,
"location": [
47.602138,
2.330583
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c31@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811758,
"location": [
47.602138,
2.330583
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
47.6008803125,
2.3348309375
],
"actualLocation": [
0,
0
],
"indexInRoute": 8,
"indexInOptimization": 3,
"arrivalTime": 1602788014000,
"timeToNextOrder": 7391,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2163.9375,
"distanceToNextOrder": 145.3060302734375,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515426,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898878,
"location": [
48.512232,
1.546783
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c101@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811765,
"location": [
48.512232,
1.546783
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.5120375,
1.547229375
],
"actualLocation": [
0,
0
],
"indexInRoute": 9,
"indexInOptimization": 10,
"arrivalTime": 1602795405000,
"timeToNextOrder": 6512,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2309.24365234375,
"distanceToNextOrder": 127.15222930908203,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498515242,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898875,
"location": [
49.161539,
0.50058
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c71@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811762,
"location": [
49.161539,
0.50058
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
49.1636175,
0.5046125
],
"actualLocation": [
0,
0
],
"indexInRoute": 10,
"indexInOptimization": 7,
"arrivalTime": 1602801917000,
"timeToNextOrder": 4489,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2436.39599609375,
"distanceToNextOrder": 112.42899322509766,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"creationTimestamp": 1743498514818,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "",
"state": 1,
"type": 0,
"priority": 0,
"id": 898868,
"location": [
48.458357,
-0.054451
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "c01@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "",
"customData": "",
"id": 1811755,
"location": [
48.458357,
-0.054451
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.4585184375,
-0.053071875
],
"actualLocation": [
0,
0
],
"indexInRoute": 11,
"indexInOptimization": 0,
"arrivalTime": 1602806406000,
"timeToNextOrder": 30,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 2548.824951171875,
"distanceToNextOrder": 0.27365899085998535,
"revenueAtArrival": 0,
"visitTimestamp": 0
}
],
"totalTime": 111636,
"totalDistance": 2549.0986328125,
"id": 252963
}

Conclusion

This example demonstrates how to retrieve an existing route and add new orders at optimal positions without rearranging the existing order sequence. If reoptimization is enabled, the orders will be arranged for maximum efficiency. By following this guide, you can integrate order addition functionality into your routing and logistics applications.

For more details, refer to the RestAPI documentation .