# Add Optimization with Single Vehicle

Last updated:

<!-- -->

October 18, 2026

<!-- -->

\| 19 minutes read

<br />

<br />

This example demonstrates how to create and optimize a fleet management solution using the **Fleet Management Rest API** with a single vehicle. The example covers the following features:

* Adding an optimization with a single vehicle.
* Defining orders with various fields (e.g., time windows, packages, weights).
* Setting up a single vehicle with specific constraints.
* Displaying the optimized solution on a map.

## How to Use the Sample[​](#how-to-use-the-sample "Direct link to How to Use the Sample")

When you run the example application:

1. An optimization is created and saved.
2. The optimized solution is returned and displayed on the map.

## Step-by-Step Guide[​](#step-by-step-guide "Direct link to Step-by-Step Guide")

### Step 1: Create Customers and Orders[​](#step-1-create-customers-and-orders "Direct link to Step 1: Create Customers and Orders")

Note

Each order must have a customer associated with it. You can either:

* Create a new customer and assign it to the order.
* Use an existing customer (refer to the [Get Customer](/docs/cloud-rest-api/guides/fleet-management/core-concepts/customer.md#3-get-a-customer-by-id)).

#### Initializing and Adding Customers[​](#initializing-and-adding-customers "Direct link to Initializing and Adding Customers")

1. **Initialize Customers**: Create twelve `Customer` objects and populate their fields (e.g., name, address, contact details).
2. **Send Request**: Call the `Add Customers` endpoint to save these customers in the system.

* **Method:** `POST`

* **Endpoint:** `/customers`

* **Headers:**

  * `Authorization: YOUR_API_KEY`
  * `Content-Type: application/json`

* **URL:** `https://api.magiclane.net/api/v1/fleetmanagement/customers`

Note

If the operation is successful, the `Customer` object will have its `id` field populated. If the operation fails, an error code is returned.

#### Example:[​](#example "Direct link to Example:")

* **Request Body:**

```json
[
  {
    "alias": "Customer 1",
    "firstName": "Customer1",
    "lastName": "Customer1",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer1@example.com",
    "phoneNumber": "+12025550180",
    "location": [
      48.870852,
      2.356148
    ],
    "customData": ""
  },
  {
    "alias": "Customer 2",
    "firstName": "Customer2",
    "lastName": "Customer2",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer2@example.com",
    "phoneNumber": "+12025550181",
    "location": [
      48.892138,
      2.330583
    ],
    "customData": ""
  },
  {
    "alias": "Customer 3",
    "firstName": "Customer3",
    "lastName": "Customer3",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer3@example.com",
    "phoneNumber": "+12025550182",
    "location": [
      48.88025,
      2.299601
    ],
    "customData": ""
  },
  {
    "alias": "Customer 4",
    "firstName": "Customer4",
    "lastName": "Customer4",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer4@example.com",
    "phoneNumber": "+12025550183",
    "location": [
      48.845198,
      2.402896
    ],
    "customData": ""
  },
  {
    "alias": "Customer 5",
    "firstName": "Customer5",
    "lastName": "Customer5",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer5@example.com",
    "phoneNumber": "+12025550184",
    "location": [
      48.897163,
      2.292865
    ],
    "customData": ""
  },
  {
    "alias": "Customer 6",
    "firstName": "Customer6",
    "lastName": "Customer6",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer6@example.com",
    "phoneNumber": "+12025550185",
    "location": [
      48.90092,
      2.400039
    ],
    "customData": ""
  },
  {
    "alias": "Customer 7",
    "firstName": "Customer7",
    "lastName": "Customer7",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer7@example.com",
    "phoneNumber": "+12025550186",
    "location": [
      48.890914,
      2.310625
    ],
    "customData": ""
  },
  {
    "alias": "Customer 8",
    "firstName": "Customer8",
    "lastName": "Customer8",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer8@example.com",
    "phoneNumber": "+12025550187",
    "location": [
      48.827865,
      2.379216
    ],
    "customData": ""
  },
  {
    "alias": "Customer 9",
    "firstName": "Customer9",
    "lastName": "Customer9",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer9@example.com",
    "phoneNumber": "+12025550188",
    "location": [
      48.887096,
      2.283513
    ],
    "customData": ""
  },
  {
    "alias": "Customer 10",
    "firstName": "Customer10",
    "lastName": "Customer10",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer10@example.com",
    "phoneNumber": "+12025550189",
    "location": [
      48.896894,
      2.321586
    ],
    "customData": ""
  },
  {
    "alias": "Customer 11",
    "firstName": "Customer11",
    "lastName": "Customer11",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer11@example.com",
    "phoneNumber": "+120255501810",
    "location": [
      48.870449,
      2.342204
    ],
    "customData": ""
  },
  {
    "alias": "Customer 12",
    "firstName": "Customer12",
    "lastName": "Customer12",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer12@example.com",
    "phoneNumber": "+120255501811",
    "location": [
      48.895658,
      2.344042
    ],
    "customData": ""
  }
]

```

* **Response Body:** (error code `200`)

```json
[
  {
    "id": 1791105,
    "alias": "Customer 1",
    "firstName": "Customer1",
    "lastName": "Customer1",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer1@example.com",
    "phoneNumber": "+12025550180",
    "location": [
      48.870852,
      2.356148
    ],
    "customData": ""
  },
  {
    "id": 1791104,
    "alias": "Customer 2",
    "firstName": "Customer2",
    "lastName": "Customer2",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer2@example.com",
    "phoneNumber": "+12025550181",
    "location": [
      48.892138,
      2.330583
    ],
    "customData": ""
  },
  {
    "id": 1791103,
    "alias": "Customer 3",
    "firstName": "Customer3",
    "lastName": "Customer3",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer3@example.com",
    "phoneNumber": "+12025550182",
    "location": [
      48.88025,
      2.299601
    ],
    "customData": ""
  },
  {
    "id": 1791102,
    "alias": "Customer 4",
    "firstName": "Customer4",
    "lastName": "Customer4",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer4@example.com",
    "phoneNumber": "+12025550183",
    "location": [
      48.845198,
      2.402896
    ],
    "customData": ""
  },
  {
    "id": 1791101,
    "alias": "Customer 5",
    "firstName": "Customer5",
    "lastName": "Customer5",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer5@example.com",
    "phoneNumber": "+12025550184",
    "location": [
      48.897163,
      2.292865
    ],
    "customData": ""
  },
  {
    "id": 1791100,
    "alias": "Customer 6",
    "firstName": "Customer6",
    "lastName": "Customer6",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer6@example.com",
    "phoneNumber": "+12025550185",
    "location": [
      48.90092,
      2.400039
    ],
    "customData": ""
  },
  {
    "id": 1791099,
    "alias": "Customer 7",
    "firstName": "Customer7",
    "lastName": "Customer7",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer7@example.com",
    "phoneNumber": "+12025550186",
    "location": [
      48.890914,
      2.310625
    ],
    "customData": ""
  },
  {
    "id": 1791098,
    "alias": "Customer 8",
    "firstName": "Customer8",
    "lastName": "Customer8",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer8@example.com",
    "phoneNumber": "+12025550187",
    "location": [
      48.827865,
      2.379216
    ],
    "customData": ""
  },
  {
    "id": 1791097,
    "alias": "Customer 9",
    "firstName": "Customer9",
    "lastName": "Customer9",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer9@example.com",
    "phoneNumber": "+12025550188",
    "location": [
      48.887096,
      2.283513
    ],
    "customData": ""
  },
  {
    "id": 1791096,
    "alias": "Customer 10",
    "firstName": "Customer10",
    "lastName": "Customer10",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer10@example.com",
    "phoneNumber": "+12025550189",
    "location": [
      48.896894,
      2.321586
    ],
    "customData": ""
  },
  {
    "id": 1791095,
    "alias": "Customer 11",
    "firstName": "Customer11",
    "lastName": "Customer11",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer11@example.com",
    "phoneNumber": "+120255501810",
    "location": [
      48.870449,
      2.342204
    ],
    "customData": ""
  },
  {
    "id": 1791094,
    "alias": "Customer 12",
    "firstName": "Customer12",
    "lastName": "Customer12",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "customer12@example.com",
    "phoneNumber": "+120255501811",
    "location": [
      48.895658,
      2.344042
    ],
    "customData": ""
  }
]

```

#### Initializing and Adding Orders[​](#initializing-and-adding-orders "Direct link to Initializing and Adding Orders")

1. **Initialize Orders**: Create twelve `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://api.magiclane.net/api/v1/fleetmanagement/orders`

Note

If the operation is successful, the `Order` object will have its `id` field populated. If the operation fails, an error code is returned.

#### Example:[​](#example-1 "Direct link to Example:")

* **Request Body:**

```json
[
  {
    "customerId": 1791105,
    "location": [
      48.870852,
      2.356148
    ],
    "alias": "Customer 1",
    "firstName": "Customer1",
    "lastName": "Customer1",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550180",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 0,
    "weight": 0,
    "cube": 0,
    "revenue": 0,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791104,
    "location": [
      48.892138,
      2.330583
    ],
    "alias": "Customer 2",
    "firstName": "Customer2",
    "lastName": "Customer2",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550181",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 0,
    "weight": 0,
    "cube": 0,
    "revenue": 0,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791103,
    "location": [
      48.88025,
      2.299601
    ],
    "alias": "Customer 3",
    "firstName": "Customer3",
    "lastName": "Customer3",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550182",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 3,
    "weight": 5.1,
    "cube": 2.5,
    "revenue": 12,
    "timeWindow": [
      770,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791102,
    "location": [
      48.845198,
      2.402896
    ],
    "alias": "Customer 4",
    "firstName": "Customer4",
    "lastName": "Customer4",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550183",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 8,
    "weight": 15.4,
    "cube": 5.8,
    "revenue": 2.7,
    "timeWindow": [
      753,
      1036
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791101,
    "location": [
      48.897163,
      2.292865
    ],
    "alias": "Customer 5",
    "firstName": "Customer5",
    "lastName": "Customer5",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550184",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 9,
    "weight": 16.2,
    "cube": 8.4,
    "revenue": 7.5,
    "timeWindow": [
      736,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791100,
    "location": [
      48.90092,
      2.400039
    ],
    "alias": "Customer 6",
    "firstName": "Customer6",
    "lastName": "Customer6",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550185",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 9,
    "weight": 16.5,
    "cube": 9.7,
    "revenue": 10,
    "timeWindow": [
      786,
      1053
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791099,
    "location": [
      48.890914,
      2.310625
    ],
    "alias": "Customer 7",
    "firstName": "Customer7",
    "lastName": "Customer7",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550186",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 5,
    "weight": 7.5,
    "cube": 2.6,
    "revenue": 13.4,
    "timeWindow": [
      820,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791098,
    "location": [
      48.827865,
      2.379216
    ],
    "alias": "Customer 8",
    "firstName": "Customer8",
    "lastName": "Customer8",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550187",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 11,
    "weight": 12.1,
    "cube": 4.6,
    "revenue": 14.7,
    "timeWindow": [
      753,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791097,
    "location": [
      48.887096,
      2.283513
    ],
    "alias": "Customer 9",
    "firstName": "Customer9",
    "lastName": "Customer9",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550188",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 6,
    "weight": 5.2,
    "cube": 1.5,
    "revenue": 2.9,
    "timeWindow": [
      770,
      1070
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791096,
    "location": [
      48.896894,
      2.321586
    ],
    "alias": "Customer 10",
    "firstName": "Customer10",
    "lastName": "Customer10",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550189",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 13,
    "weight": 6.3,
    "cube": 7.5,
    "revenue": 8.1,
    "timeWindow": [
      836,
      1053
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791095,
    "location": [
      48.870449,
      2.342204
    ],
    "alias": "Customer 11",
    "firstName": "Customer11",
    "lastName": "Customer11",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+120255501810",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 10,
    "weight": 8,
    "cube": 4.1,
    "revenue": 6.2,
    "timeWindow": [
      903,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 1791094,
    "location": [
      48.895658,
      2.344042
    ],
    "alias": "Customer 12",
    "firstName": "Customer12",
    "lastName": "Customer12",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+120255501811",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 6,
    "weight": 4.8,
    "cube": 11.5,
    "revenue": 2.3,
    "timeWindow": [
      870,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  }
]

```

* **Response Body:** (error code `200`)

```json
[
  {
    "id": 879888,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791105,
      "alias": "Customer 1",
      "firstName": "Customer1",
      "lastName": "Customer1",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer1@example.com",
      "phoneNumber": "+12025550180",
      "location": [
        48.870852,
        2.356148
      ],
      "customData": ""
    },
    "location": [
      48.870852,
      2.356148
    ],
    "alias": "Customer 1",
    "firstName": "Customer1",
    "lastName": "Customer1",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550180",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 0,
    "weight": 0,
    "cube": 0,
    "revenue": 0,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879887,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791104,
      "alias": "Customer 2",
      "firstName": "Customer2",
      "lastName": "Customer2",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer2@example.com",
      "phoneNumber": "+12025550181",
      "location": [
        48.892138,
        2.330583
      ],
      "customData": ""
    },
    "location": [
      48.892138,
      2.330583
    ],
    "alias": "Customer 2",
    "firstName": "Customer2",
    "lastName": "Customer2",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550181",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 0,
    "weight": 0,
    "cube": 0,
    "revenue": 0,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879886,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791103,
      "alias": "Customer 3",
      "firstName": "Customer3",
      "lastName": "Customer3",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer3@example.com",
      "phoneNumber": "+12025550182",
      "location": [
        48.88025,
        2.299601
      ],
      "customData": ""
    },
    "location": [
      48.88025,
      2.299601
    ],
    "alias": "Customer 3",
    "firstName": "Customer3",
    "lastName": "Customer3",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550182",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 3,
    "weight": 5.1,
    "cube": 2.5,
    "revenue": 12,
    "timeWindow": [
      770,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879885,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791102,
      "alias": "Customer 4",
      "firstName": "Customer4",
      "lastName": "Customer4",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer4@example.com",
      "phoneNumber": "+12025550183",
      "location": [
        48.845198,
        2.402896
      ],
      "customData": ""
    },
    "location": [
      48.845198,
      2.402896
    ],
    "alias": "Customer 4",
    "firstName": "Customer4",
    "lastName": "Customer4",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550183",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 8,
    "weight": 15.4,
    "cube": 5.8,
    "revenue": 2.7,
    "timeWindow": [
      753,
      1036
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879884,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791101,
      "alias": "Customer 5",
      "firstName": "Customer5",
      "lastName": "Customer5",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer5@example.com",
      "phoneNumber": "+12025550184",
      "location": [
        48.897163,
        2.292865
      ],
      "customData": ""
    },
    "location": [
      48.897163,
      2.292865
    ],
    "alias": "Customer 5",
    "firstName": "Customer5",
    "lastName": "Customer5",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550184",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 9,
    "weight": 16.2,
    "cube": 8.4,
    "revenue": 7.5,
    "timeWindow": [
      736,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879883,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791100,
      "alias": "Customer 6",
      "firstName": "Customer6",
      "lastName": "Customer6",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer6@example.com",
      "phoneNumber": "+12025550185",
      "location": [
        48.90092,
        2.400039
      ],
      "customData": ""
    },
    "location": [
      48.90092,
      2.400039
    ],
    "alias": "Customer 6",
    "firstName": "Customer6",
    "lastName": "Customer6",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550185",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 9,
    "weight": 16.5,
    "cube": 9.7,
    "revenue": 10,
    "timeWindow": [
      786,
      1053
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879882,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791099,
      "alias": "Customer 7",
      "firstName": "Customer7",
      "lastName": "Customer7",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer7@example.com",
      "phoneNumber": "+12025550186",
      "location": [
        48.890914,
        2.310625
      ],
      "customData": ""
    },
    "location": [
      48.890914,
      2.310625
    ],
    "alias": "Customer 7",
    "firstName": "Customer7",
    "lastName": "Customer7",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550186",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 5,
    "weight": 7.5,
    "cube": 2.6,
    "revenue": 13.4,
    "timeWindow": [
      820,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879881,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791098,
      "alias": "Customer 8",
      "firstName": "Customer8",
      "lastName": "Customer8",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer8@example.com",
      "phoneNumber": "+12025550187",
      "location": [
        48.827865,
        2.379216
      ],
      "customData": ""
    },
    "location": [
      48.827865,
      2.379216
    ],
    "alias": "Customer 8",
    "firstName": "Customer8",
    "lastName": "Customer8",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550187",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 11,
    "weight": 12.1,
    "cube": 4.6,
    "revenue": 14.7,
    "timeWindow": [
      753,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879880,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791097,
      "alias": "Customer 9",
      "firstName": "Customer9",
      "lastName": "Customer9",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer9@example.com",
      "phoneNumber": "+12025550188",
      "location": [
        48.887096,
        2.283513
      ],
      "customData": ""
    },
    "location": [
      48.887096,
      2.283513
    ],
    "alias": "Customer 9",
    "firstName": "Customer9",
    "lastName": "Customer9",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550188",
    "customData": "",
    "type": 1,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 6,
    "weight": 5.2,
    "cube": 1.5,
    "revenue": 2.9,
    "timeWindow": [
      770,
      1070
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879879,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791096,
      "alias": "Customer 10",
      "firstName": "Customer10",
      "lastName": "Customer10",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer10@example.com",
      "phoneNumber": "+12025550189",
      "location": [
        48.896894,
        2.321586
      ],
      "customData": ""
    },
    "location": [
      48.896894,
      2.321586
    ],
    "alias": "Customer 10",
    "firstName": "Customer10",
    "lastName": "Customer10",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+12025550189",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 13,
    "weight": 6.3,
    "cube": 7.5,
    "revenue": 8.1,
    "timeWindow": [
      836,
      1053
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879878,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791095,
      "alias": "Customer 11",
      "firstName": "Customer11",
      "lastName": "Customer11",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer11@example.com",
      "phoneNumber": "+120255501810",
      "location": [
        48.870449,
        2.342204
      ],
      "customData": ""
    },
    "location": [
      48.870449,
      2.342204
    ],
    "alias": "Customer 11",
    "firstName": "Customer11",
    "lastName": "Customer11",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+120255501810",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 10,
    "weight": 8,
    "cube": 4.1,
    "revenue": 6.2,
    "timeWindow": [
      903,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "id": 879877,
    "creationTimestamp": 1752745377776,
    "customerInfo": {
      "id": 1791094,
      "alias": "Customer 12",
      "firstName": "Customer12",
      "lastName": "Customer12",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "email": "customer12@example.com",
      "phoneNumber": "+120255501811",
      "location": [
        48.895658,
        2.344042
      ],
      "customData": ""
    },
    "location": [
      48.895658,
      2.344042
    ],
    "alias": "Customer 12",
    "firstName": "Customer12",
    "lastName": "Customer12",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+120255501811",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 6,
    "weight": 4.8,
    "cube": 11.5,
    "revenue": 2.3,
    "timeWindow": [
      870,
      1020
    ],
    "serviceTime": 0,
    "depotId": 0
  }
]

```

### Step 2: Configure Optimization Parameters[​](#step-2-configure-optimization-parameters "Direct link to Step 2: Configure Optimization Parameters")

Note

Configuration Parameters define the behavior of the optimization process. These settings include optimization goals, search time limits, and flexibility in handling orders. Proper configuration ensures the optimization aligns with your business needs.

1. **Create Configuration**: Define a `ConfigurationParameters` object and set the desired parameters.

```json
{
  "name": "Paris - test optimization",
  "ignoreTimeWindow": false,
  "allowDroppingOrders": false,
  "groupingOrders": false,
  "balancedRoutes": 0,
  "optimizationCriterion": 0,
  "arrangeCriterion": 0,
  "optimizationQuality": 2,
  "maxTimeToOptimize": 300,
  "maxWaitTime": 8000,
  "routeType": 0,
  "restrictions": 0,
  "distanceUnit": 0,
  "orderSequenceOptions": []
}

```

### Step 3: Create the Vehicle and Define Vehicle Constraints[​](#step-3-create-the-vehicle-and-define-vehicle-constraints "Direct link to Step 3: Create the Vehicle and Define Vehicle Constraints")

Note

Vehicle constraints ensure that vehicles operate within their capabilities. These include time windows, capacity limits, distance constraints, and revenue goals. You can define constraints individually for each vehicle or apply a single set of constraints to all vehicles.

#### **Adding Vehicles**[​](#adding-vehicles "Direct link to adding-vehicles")

1. **Initialize Vehicles**: Create a `Vehicle` object and populate its fields (e.g., type, capacity, availability).
2. **Send Request**: Call the `Add Vehicles` endpoint to save vehicle in the database.

* **Method:** `POST`

* **Endpoint:** `/vehicles`

* **Headers:**

  * `Authorization: YOUR_API_KEY`
  * `Content-Type: application/json`

* **URL:** `https://api.magiclane.net/api/v1/fleetmanagement/vehicles`

Note

If the operation is successful, the `Vehicle` object will have its `id` field populated. If the operation fails, an error code is returned.

#### Example:[​](#example-2 "Direct link to Example:")

* **Request Body:**

```json
[
  {
    "type": 0,
    "status": 0,
    "name": "Car vehicle 1",
    "manufacturer": "Renault",
    "model": "Master",
    "fuelType": 2,
    "lastPosition": [
      48.870569,
      2.356448
    ],
    "consumption": 6.5,
    "plate": "AA-123-AA",
    "maxLoadWeight": 60,
    "maxLoadCube": 50,
    "height": 0,
    "width": 0,
    "weight": 0,
    "length": 0,
    "axleLoad": 0,
    "fixedCost": 0,
    "costPerHour": 0,
    "startTime": 420,
    "endTime": 1439
  }
]

```

* **Response Body:** (error code `200`)

```json
[
  {
    "id": 135748,
    "type": 0,
    "status": 0,
    "name": "Car vehicle 1",
    "manufacturer": "Renault",
    "model": "Master",
    "fuelType": 2,
    "lastPosition": [
      48.870569,
      2.356448
    ],
    "consumption": 6.5,
    "plate": "AA-123-AA",
    "maxLoadWeight": 60,
    "maxLoadCube": 50,
    "height": 0,
    "width": 0,
    "weight": 0,
    "length": 0,
    "axleLoad": 0,
    "fixedCost": 0,
    "costPerHour": 0,
    "startTime": 420,
    "endTime": 1439
  }
]

```

#### **Defining Vehicle Constraints**[​](#defining-vehicle-constraints "Direct link to defining-vehicle-constraints")

1. **Create Constraints**: Define a `VehicleConstraints` object that applies to added vehicle. Add this object to a list.

```json
[
  {
    "fuelPrice": 1.09,
    "startDate": 1596758400000,
    "maxNumberOfPackages": 53,
    "minNumberOfOrders": 0,
    "maxNumberOfOrders": 99999999,
    "minDistance": 0,
    "maxDistance": 99999999,
    "maxRevenue": 85.9
  }
]

```

### Step 4: Create the Departure and Destination[​](#step-4-create-the-departure-and-destination "Direct link to Step 4: Create the Departure and Destination")

Note

* **Departures**: Define the starting points for vehicle routes. These locations impact optimization by influencing travel distance and time.
* **Destinations**: Define the final stops for vehicle routes. These locations ensure routes are optimized for efficiency.

#### **Adding Departures and Destinations**[​](#adding-departures-and-destinations "Direct link to adding-departures-and-destinations")

1. **Initialize Departures**: Create a `Departure` object, for added vehicle. Since the route is round-trip, the vehicle will start and end at the same point, so departure will also be used as destination .

```json
[
  {
    "depotId": 0,
    "alias": "Depot 1",
    "location": [
      48.870569,
      2.356448
    ],
    "address": {
      "country": "France",
      "state": "Ile-de-France",
      "county": "Paris",
      "city": "Paris",
      "postalCode": "75001",
      "streetName": "Rue de Rivoli",
      "streetNumber": "1"
    }
  }
]

```

### Step 5: Create the Optimization[​](#step-5-create-the-optimization "Direct link to Step 5: Create the Optimization")

Note

An optimization represents a routing problem defined by orders, vehicles, constraints, and configuration parameters. This step combines all the elements to generate an optimized solution.

1. **Create Optimization**: Define an `Optimization` object and assign the `OrderList`, `ConfigurationParameters`, `VehicleList`, `VehicleConstraintsList`, and `Departures`.
2. **Send Request**: Call the `Add Optimization` endpoint to create the optimization.

* **Method:** `POST`

* **Endpoint:** `/optimizations`

* **Headers:**

  * `Authorization: YOUR_API_KEY`
  * `Content-Type: application/json`

* **URL:** `https://api.magiclane.net/api/v1/fleetmanagement/optimizations`

* **Query Parameter:**

  * `encodeShape` (integer, *optional*)

    <!-- -->

    * `0`: The route's shape will not be encoded.
    * `1` (default): The route's shape will be encoded.

Note

Adding an optimization returns a `request` object, which allows you to track the status of the optimization process. Once the request status is finished, the solution can be retrieved using [Get Optimization's Solution](/docs/cloud-rest-api/guides/fleet-management/core-concepts/optimization.md#7-get-optimizations-solution) request. The solution consists of one or more routes. A route is the trip that a vehicle travels to visit the orders, so the number of routes returned is maximum the number of vehicles set in the optimization(see [Routes](/docs/cloud-rest-api/guides/fleet-management/core-concepts/route.md)).<br />If the operation is successful, the `Optimization` object will have its `id` field populated. If the operation fails, an error code is returned.

#### Example:[​](#example-3 "Direct link to Example:")

* **Request Body:**

```json
{
  "orders": [
    879888,
    879887,
    879886,
    879885,
    879884,
    879883,
    879882,
    879881,
    879880,
    879879,
    879878,
    879877
  ],
  "departures": [
    {
      "depotId": 0,
      "alias": "Depot 1",
      "location": [
        48.870569,
        2.356448
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75001",
        "streetName": "Rue de Rivoli",
        "streetNumber": "1"
      }
    }
  ],
  "destinations": [],
  "vehicles": [
    135748
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85.9
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 8000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "matrixBuildType": 1
}

```

* **Response Body:** (error code `200`)

```json
{
  "id": 137826,
  "orders": [
    {
      "id": 879888,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791105,
        "alias": "Customer 1",
        "firstName": "Customer1",
        "lastName": "Customer1",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer1@example.com",
        "phoneNumber": "+12025550180",
        "location": [
          48.870852,
          2.356148
        ],
        "customData": ""
      },
      "location": [
        48.870852,
        2.356148
      ],
      "alias": "Customer 1",
      "firstName": "Customer1",
      "lastName": "Customer1",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550180",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "revenue": 0,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879887,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791104,
        "alias": "Customer 2",
        "firstName": "Customer2",
        "lastName": "Customer2",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer2@example.com",
        "phoneNumber": "+12025550181",
        "location": [
          48.892138,
          2.330583
        ],
        "customData": ""
      },
      "location": [
        48.892138,
        2.330583
      ],
      "alias": "Customer 2",
      "firstName": "Customer2",
      "lastName": "Customer2",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550181",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "revenue": 0,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879886,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791103,
        "alias": "Customer 3",
        "firstName": "Customer3",
        "lastName": "Customer3",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer3@example.com",
        "phoneNumber": "+12025550182",
        "location": [
          48.88025,
          2.299601
        ],
        "customData": ""
      },
      "location": [
        48.88025,
        2.299601
      ],
      "alias": "Customer 3",
      "firstName": "Customer3",
      "lastName": "Customer3",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550182",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 3,
      "weight": 5.1,
      "cube": 2.5,
      "revenue": 12,
      "timeWindow": [
        770,
        1020
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879885,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791102,
        "alias": "Customer 4",
        "firstName": "Customer4",
        "lastName": "Customer4",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer4@example.com",
        "phoneNumber": "+12025550183",
        "location": [
          48.845198,
          2.402896
        ],
        "customData": ""
      },
      "location": [
        48.845198,
        2.402896
      ],
      "alias": "Customer 4",
      "firstName": "Customer4",
      "lastName": "Customer4",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550183",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 8,
      "weight": 15.4,
      "cube": 5.8,
      "revenue": 2.7,
      "timeWindow": [
        753,
        1036
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879884,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791101,
        "alias": "Customer 5",
        "firstName": "Customer5",
        "lastName": "Customer5",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer5@example.com",
        "phoneNumber": "+12025550184",
        "location": [
          48.897163,
          2.292865
        ],
        "customData": ""
      },
      "location": [
        48.897163,
        2.292865
      ],
      "alias": "Customer 5",
      "firstName": "Customer5",
      "lastName": "Customer5",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550184",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 9,
      "weight": 16.2,
      "cube": 8.4,
      "revenue": 7.5,
      "timeWindow": [
        736,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879883,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791100,
        "alias": "Customer 6",
        "firstName": "Customer6",
        "lastName": "Customer6",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer6@example.com",
        "phoneNumber": "+12025550185",
        "location": [
          48.90092,
          2.400039
        ],
        "customData": ""
      },
      "location": [
        48.90092,
        2.400039
      ],
      "alias": "Customer 6",
      "firstName": "Customer6",
      "lastName": "Customer6",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550185",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 9,
      "weight": 16.5,
      "cube": 9.7,
      "revenue": 10,
      "timeWindow": [
        786,
        1053
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879882,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791099,
        "alias": "Customer 7",
        "firstName": "Customer7",
        "lastName": "Customer7",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer7@example.com",
        "phoneNumber": "+12025550186",
        "location": [
          48.890914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.890914,
        2.310625
      ],
      "alias": "Customer 7",
      "firstName": "Customer7",
      "lastName": "Customer7",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550186",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 5,
      "weight": 7.5,
      "cube": 2.6,
      "revenue": 13.4,
      "timeWindow": [
        820,
        1020
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879881,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791098,
        "alias": "Customer 8",
        "firstName": "Customer8",
        "lastName": "Customer8",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer8@example.com",
        "phoneNumber": "+12025550187",
        "location": [
          48.827865,
          2.379216
        ],
        "customData": ""
      },
      "location": [
        48.827865,
        2.379216
      ],
      "alias": "Customer 8",
      "firstName": "Customer8",
      "lastName": "Customer8",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550187",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 11,
      "weight": 12.1,
      "cube": 4.6,
      "revenue": 14.7,
      "timeWindow": [
        753,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879880,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791097,
        "alias": "Customer 9",
        "firstName": "Customer9",
        "lastName": "Customer9",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer9@example.com",
        "phoneNumber": "+12025550188",
        "location": [
          48.887096,
          2.283513
        ],
        "customData": ""
      },
      "location": [
        48.887096,
        2.283513
      ],
      "alias": "Customer 9",
      "firstName": "Customer9",
      "lastName": "Customer9",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550188",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 6,
      "weight": 5.2,
      "cube": 1.5,
      "revenue": 2.9,
      "timeWindow": [
        770,
        1070
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879879,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791096,
        "alias": "Customer 10",
        "firstName": "Customer10",
        "lastName": "Customer10",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer10@example.com",
        "phoneNumber": "+12025550189",
        "location": [
          48.896894,
          2.321586
        ],
        "customData": ""
      },
      "location": [
        48.896894,
        2.321586
      ],
      "alias": "Customer 10",
      "firstName": "Customer10",
      "lastName": "Customer10",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+12025550189",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 13,
      "weight": 6.3,
      "cube": 7.5,
      "revenue": 8.1,
      "timeWindow": [
        836,
        1053
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879878,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791095,
        "alias": "Customer 11",
        "firstName": "Customer11",
        "lastName": "Customer11",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer11@example.com",
        "phoneNumber": "+120255501810",
        "location": [
          48.870449,
          2.342204
        ],
        "customData": ""
      },
      "location": [
        48.870449,
        2.342204
      ],
      "alias": "Customer 11",
      "firstName": "Customer11",
      "lastName": "Customer11",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501810",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 10,
      "weight": 8,
      "cube": 4.1,
      "revenue": 6.2,
      "timeWindow": [
        903,
        1020
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879877,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1791094,
        "alias": "Customer 12",
        "firstName": "Customer12",
        "lastName": "Customer12",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "customer12@example.com",
        "phoneNumber": "+120255501811",
        "location": [
          48.895658,
          2.344042
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344042
      ],
      "alias": "Customer 12",
      "firstName": "Customer12",
      "lastName": "Customer12",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501811",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 6,
      "weight": 4.8,
      "cube": 11.5,
      "revenue": 2.3,
      "timeWindow": [
        870,
        1020
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ],
  "departures": [
    {
      "depotId": 0,
      "alias": "Depot 1",
      "location": [
        48.870569,
        2.356448
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75001",
        "streetName": "Rue de Rivoli",
        "streetNumber": "1"
      }
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135748,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 1",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.870569,
        2.356448
      ],
      "consumption": 6.5,
      "plate": "AA-123-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85.9
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 8000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26545,
    "optimizationId": 137826,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

### Step 6: Display the Solution[​](#step-6-display-the-solution "Direct link to Step 6: Display the Solution")

Once the optimization is complete, retrieve the solution (routes) to visualize the optimized routes and waypoints.

* **Method:** `GET`

* **Endpoint:** `/optimizations/{id}/solution`

* **Headers:**
  * `Authorization: YOUR_API_KEY`

* **Path Parameter:**
  * `id` (integer, **required**) - The unique optimization 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:[​](#example-4 "Direct link to Example:")

* **Response Body:** (error code `200`)

```json
{
	"totalRecords": 1,
	"routes": [
		{
			"configurationParameters": {
				"orderSequenceOptions": [
				],
				"distanceUnit": 0,
				"maxTimeToOptimize": 300,
				"optimizationQuality": 2,
				"routeType": 0,
				"arrangeCriterion": 0,
				"restrictions": 0,
				"maxWaitTime": 8000,
				"balancedRoutes": 0,
				"groupingOrders": false,
				"optimizationCriterion": 0,
				"allowDroppingOrders": false,
				"ignoreTimeWindow": false,
				"name": "Paris - test optimization - Part 0"
			},
			"vehicleConstraints": {
				"startDate": 1596758400000,
				"maxNumberOfPackages": 99999999,
				"minNumberOfOrders": 0,
				"maxNumberOfOrders": 99999999,
				"minDistance": 0.0,
				"maxDistance": 100000000.0,
				"maxRevenue": 100000000.0,
				"fuelPrice": 1.0900000333786010742
			},
			"rideStatus": 1,
			"vehicle": {
				"length": 0.0,
				"weight": 0.0,
				"width": 0.0,
				"licensePlate": "AA-123-AA",
				"consumption": 6.5,
				"fuelType": 0,
				"make": "Renault",
				"id": 161794,
				"name": "Car vehicle 1",
				"model": "Master",
				"costPerHour": 0.0,
				"type": 0,
				"status": 0,
				"maxLoadWeight": 60.0,
				"height": 0.0,
				"maxLoadCube": 50.0,
				"idDriver": 161794,
				"endTime": 1100,
				"fixedCost": 0.0,
				"startTime": 420,
				"lastPosition": [
					2147483647.0,
					2147483647.0
				]
			},
			"destination": {
				"depotId": 0,
				"alias": "Depot 1",
				"address": {
					"streetNumber": "",
					"postalCode": "",
					"streetName": "",
					"county": "",
					"state": "",
					"extra": "",
					"city": "",
					"country": ""
				},
				"location": [
					48.870569000000003257,
					2.3564479999999998761
				],
				"matchedLocation": [
					48.870568437499997572,
					2.356441562500000142
				],
				"arrivalTime": 1596811043000,
				"traveledDistance": 43.550060272216796875
			},
			"departure": {
				"depotId": 0,
				"alias": "Depot 1",
				"address": {
					"streetNumber": "",
					"postalCode": "",
					"streetName": "",
					"county": "",
					"state": "",
					"extra": "",
					"city": "",
					"country": ""
				},
				"location": [
					48.870569000000003257,
					2.3564479999999998761
				],
				"matchedLocation": [
					48.870568437499997572,
					2.356441562500000142
				],
				"numberOfpackages": 34,
				"weight": 49.200000762939453125,
				"cube": 21.600000381469726562,
				"departureTime": 1596804545693,
				"timeToNext": 1014,
				"distanceToNext": 5.9496679306030273438
			},
			"shape": "a`hiHwfkM`GxCBVVPPHs@~Ek_@_QqAu@o@WwD{BOOx@uIDYFSHEAIGAU_@OKiDiBaF}ByBqAwAeBwKoNsC{DoKqNw@kA}@}@qQ",
			"creationTimestamp": 1753085297311,
			"neededFuel": 2.8307538032531738281,
			"matrixBuildType": 1,
			"price": 3.085521697998046875,
			"totalWaitTime": 0,
			"totalServiceTime": 0,
			"optimizationId": 148942,
			"orders": [
				{
					"orderInfo": {
						"revenue": 10.0,
						"serviceTime": 0,
						"timeWindow": [
							786,
							1053
						],
						"creationTimestamp": 1753085263119,
						"cube": 9.6999998092651367188,
						"numberOfPackages": 9,
						"depotId": 0,
						"customData": "",
						"weight": 16.5,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c5",
						"state": 1,
						"type": 1,
						"priority": 0,
						"id": 1194037,
						"location": [
							48.900919999999999277,
							2.4000390000000000335
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c5@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c5",
							"customData": "",
							"id": 1998456,
							"location": [
								48.900919999999999277,
								2.4000390000000000335
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.900595937500000332,
						2.4000474999999998893
					],
					"indexInRoute": 0,
					"indexInOptimization": 5,
					"arrivalTime": 1596805560000,
					"timeToNextOrder": 857,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 34,
					"collectedNumberOfPackages": 0,
					"deliveredNumberOfPackages": 9,
					"weightAtArrival": 49.200000762939453125,
					"collectedWeight": 0.0,
					"deliveredWeight": 16.5,
					"cubeAtArrival": 21.600000381469726562,
					"collectedCube": 0.0,
					"deliveredCube": 9.6999998092651367188,
					"traveledDistance": 5.9496679306030273438,
					"distanceToNextOrder": 9.274402618408203125,
					"revenueAtArrival": 0.0,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 2.7000000476837158203,
						"serviceTime": 0,
						"timeWindow": [
							753,
							1036
						],
						"creationTimestamp": 1753085263025,
						"cube": 5.8000001907348632812,
						"numberOfPackages": 8,
						"depotId": 0,
						"customData": "",
						"weight": 15.399999618530273438,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c3",
						"state": 1,
						"type": 1,
						"priority": 0,
						"id": 1194035,
						"location": [
							48.845198000000003447,
							2.4028960000000001429
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c3@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c3",
							"customData": "",
							"id": 1998454,
							"location": [
								48.845198000000003447,
								2.4028960000000001429
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.845262499999996919,
						2.4027009375000001334
					],
					"indexInRoute": 1,
					"indexInOptimization": 3,
					"arrivalTime": 1596806417000,
					"timeToNextOrder": 530,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 25,
					"collectedNumberOfPackages": 0,
					"deliveredNumberOfPackages": 8,
					"weightAtArrival": 32.700000762939453125,
					"collectedWeight": 0.0,
					"deliveredWeight": 15.399999618530273438,
					"cubeAtArrival": 11.900000572204589844,
					"collectedCube": 0.0,
					"deliveredCube": 5.8000001907348632812,
					"traveledDistance": 15.224070549011230469,
					"distanceToNextOrder": 3.1860260963439941406,
					"revenueAtArrival": 10.0,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 14.699999809265136719,
						"serviceTime": 0,
						"timeWindow": [
							753,
							1086
						],
						"creationTimestamp": 1753085263204,
						"cube": 4.5999999046325683594,
						"numberOfPackages": 11,
						"depotId": 0,
						"customData": "",
						"weight": 12.100000381469726562,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c7",
						"state": 1,
						"type": 1,
						"priority": 0,
						"id": 1194039,
						"location": [
							48.827865000000002738,
							2.3792159999999999975
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c7@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c7",
							"customData": "",
							"id": 1998458,
							"location": [
								48.827865000000002738,
								2.3792159999999999975
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.827919999999998879,
						2.3791415625000000844
					],
					"indexInRoute": 2,
					"indexInOptimization": 7,
					"arrivalTime": 1596806947000,
					"timeToNextOrder": 1051,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 17,
					"collectedNumberOfPackages": 0,
					"deliveredNumberOfPackages": 11,
					"weightAtArrival": 17.300001144409179688,
					"collectedWeight": 0.0,
					"deliveredWeight": 12.100000381469726562,
					"cubeAtArrival": 6.1000003814697265625,
					"collectedCube": 0.0,
					"deliveredCube": 4.5999999046325683594,
					"traveledDistance": 18.410097122192382812,
					"distanceToNextOrder": 6.7776498794555664062,
					"revenueAtArrival": 12.699999809265136719,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 6.1999998092651367188,
						"serviceTime": 0,
						"timeWindow": [
							903,
							1020
						],
						"creationTimestamp": 1753085263334,
						"cube": 4.0999999046325683594,
						"numberOfPackages": 10,
						"depotId": 0,
						"customData": "",
						"weight": 8.0,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c10",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194042,
						"location": [
							48.870449000000000694,
							2.3422040000000001747
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c10@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c10",
							"customData": "",
							"id": 1998461,
							"location": [
								48.870449000000000694,
								2.3422040000000001747
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.870181875000000105,
						2.3423449999999998994
					],
					"indexInRoute": 3,
					"indexInOptimization": 10,
					"arrivalTime": 1596807998000,
					"timeToNextOrder": 595,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 6,
					"collectedNumberOfPackages": 10,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 5.200000762939453125,
					"collectedWeight": 8.0,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 1.5000004768371582031,
					"collectedCube": 4.0999999046325683594,
					"deliveredCube": 0.0,
					"traveledDistance": 25.187747955322265625,
					"distanceToNextOrder": 3.8362429141998291016,
					"revenueAtArrival": 27.399999618530273438,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 12.0,
						"serviceTime": 0,
						"timeWindow": [
							770,
							1020
						],
						"creationTimestamp": 1753085262979,
						"cube": 2.5,
						"numberOfPackages": 3,
						"depotId": 0,
						"customData": "",
						"weight": 5.0999999046325683594,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c2",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194034,
						"location": [
							48.880249999999996646,
							2.2996010000000000062
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c2@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c2",
							"customData": "",
							"id": 1998453,
							"location": [
								48.880249999999996646,
								2.2996010000000000062
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.880213437499996587,
						2.2997093749999999446
					],
					"indexInRoute": 4,
					"indexInOptimization": 2,
					"arrivalTime": 1596808593000,
					"timeToNextOrder": 369,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 16,
					"collectedNumberOfPackages": 3,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 13.200000762939453125,
					"collectedWeight": 5.0999999046325683594,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 5.6000003814697265625,
					"collectedCube": 2.5,
					"deliveredCube": 0.0,
					"traveledDistance": 29.023990631103515625,
					"distanceToNextOrder": 1.8877489566802978516,
					"revenueAtArrival": 33.59999847412109375,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 2.9000000953674316406,
						"serviceTime": 0,
						"timeWindow": [
							770,
							1070
						],
						"creationTimestamp": 1753085263252,
						"cube": 1.5,
						"numberOfPackages": 6,
						"depotId": 0,
						"customData": "",
						"weight": 5.1999998092651367188,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c8",
						"state": 1,
						"type": 1,
						"priority": 0,
						"id": 1194040,
						"location": [
							48.887095999999999663,
							2.283513000000000126
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c8@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c8",
							"customData": "",
							"id": 1998459,
							"location": [
								48.887095999999999663,
								2.283513000000000126
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.886898125000001869,
						2.2838078125000000895
					],
					"indexInRoute": 5,
					"indexInOptimization": 8,
					"arrivalTime": 1596808962000,
					"timeToNextOrder": 330,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 19,
					"collectedNumberOfPackages": 0,
					"deliveredNumberOfPackages": 6,
					"weightAtArrival": 18.300001144409179688,
					"collectedWeight": 0.0,
					"deliveredWeight": 5.1999998092651367188,
					"cubeAtArrival": 8.1000003814697265625,
					"collectedCube": 0.0,
					"deliveredCube": 1.5,
					"traveledDistance": 30.911739349365234375,
					"distanceToNextOrder": 1.896412968635559082,
					"revenueAtArrival": 45.59999847412109375,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 7.5,
						"serviceTime": 0,
						"timeWindow": [
							736,
							1086
						],
						"creationTimestamp": 1753085263078,
						"cube": 8.3999996185302734375,
						"numberOfPackages": 9,
						"depotId": 0,
						"customData": "",
						"weight": 16.200000762939453125,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c4",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194036,
						"location": [
							48.897162999999999045,
							2.2928649999999999309
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c4@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c4",
							"customData": "",
							"id": 1998455,
							"location": [
								48.897162999999999045,
								2.2928649999999999309
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.897063750000000937,
						2.2924699999999997857
					],
					"indexInRoute": 6,
					"indexInOptimization": 4,
					"arrivalTime": 1596809292000,
					"timeToNextOrder": 406,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 13,
					"collectedNumberOfPackages": 9,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 13.100001335144042969,
					"collectedWeight": 16.200000762939453125,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 6.6000003814697265625,
					"collectedCube": 8.3999996185302734375,
					"deliveredCube": 0.0,
					"traveledDistance": 32.8081512451171875,
					"distanceToNextOrder": 2.8310110569000244141,
					"revenueAtArrival": 48.5,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 13.399999618530273438,
						"serviceTime": 0,
						"timeWindow": [
							820,
							1020
						],
						"creationTimestamp": 1753085263166,
						"cube": 2.5999999046325683594,
						"numberOfPackages": 5,
						"depotId": 0,
						"customData": "",
						"weight": 7.5,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c6",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194038,
						"location": [
							48.890914000000002204,
							2.3106249999999999289
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c6@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c6",
							"customData": "",
							"id": 1998457,
							"location": [
								48.890914000000002204,
								2.3106249999999999289
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.891068437500003085,
						2.3109646874999998367
					],
					"indexInRoute": 7,
					"indexInOptimization": 6,
					"arrivalTime": 1596809698000,
					"timeToNextOrder": 185,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 22,
					"collectedNumberOfPackages": 5,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 29.3000030517578125,
					"collectedWeight": 7.5,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 15.0,
					"collectedCube": 2.5999999046325683594,
					"deliveredCube": 0.0,
					"traveledDistance": 35.639163970947265625,
					"distanceToNextOrder": 1.2335729598999023438,
					"revenueAtArrival": 56.0,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 8.1000003814697265625,
						"serviceTime": 0,
						"timeWindow": [
							836,
							1053
						],
						"creationTimestamp": 1753085263293,
						"cube": 7.5,
						"numberOfPackages": 13,
						"depotId": 0,
						"customData": "",
						"weight": 6.3000001907348632812,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c9",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194041,
						"location": [
							48.896894000000003189,
							2.3215859999999999275
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c9@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c9",
							"customData": "",
							"id": 1998460,
							"location": [
								48.896894000000003189,
								2.3215859999999999275
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.897175937500001908,
						2.3212631250000002048
					],
					"indexInRoute": 8,
					"indexInOptimization": 9,
					"arrivalTime": 1596809883000,
					"timeToNextOrder": 240,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 27,
					"collectedNumberOfPackages": 13,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 36.8000030517578125,
					"collectedWeight": 6.3000001907348632812,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 17.600000381469726562,
					"collectedCube": 7.5,
					"deliveredCube": 0.0,
					"traveledDistance": 36.872737884521484375,
					"distanceToNextOrder": 1.5006899833679199219,
					"revenueAtArrival": 69.40000152587890625,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 14.100000381469726562,
						"serviceTime": 0,
						"timeWindow": [
							420,
							1086
						],
						"creationTimestamp": 1753085262939,
						"cube": 0.10000000149011611938,
						"numberOfPackages": 1,
						"depotId": 0,
						"customData": "",
						"weight": 4.5999999046325683594,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c1",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194033,
						"location": [
							48.892138000000002762,
							2.3305829999999998492
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c1@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c1",
							"customData": "",
							"id": 1998452,
							"location": [
								48.892138000000002762,
								2.3305829999999998492
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.892148437499997726,
						2.3306215625000001879
					],
					"indexInRoute": 9,
					"indexInOptimization": 1,
					"arrivalTime": 1596810123000,
					"timeToNextOrder": 281,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 40,
					"collectedNumberOfPackages": 1,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 43.100002288818359375,
					"collectedWeight": 4.5999999046325683594,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 25.100000381469726562,
					"collectedCube": 0.10000000149011611938,
					"deliveredCube": 0.0,
					"traveledDistance": 38.3734283447265625,
					"distanceToNextOrder": 1.5621720552444458008,
					"revenueAtArrival": 77.5,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 2.2999999523162841797,
						"serviceTime": 0,
						"timeWindow": [
							870,
							1020
						],
						"creationTimestamp": 1753085263379,
						"cube": 11.5,
						"numberOfPackages": 6,
						"depotId": 0,
						"customData": "",
						"weight": 4.8000001907348632812,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c11",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194043,
						"location": [
							48.895657999999997401,
							2.3440430000000000987
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c11@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c11",
							"customData": "",
							"id": 1998462,
							"location": [
								48.895657999999997401,
								2.3440430000000000987
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.895803437499999688,
						2.3440406249999998778
					],
					"indexInRoute": 10,
					"indexInOptimization": 11,
					"arrivalTime": 1596810404000,
					"timeToNextOrder": 633,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 41,
					"collectedNumberOfPackages": 6,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 47.700000762939453125,
					"collectedWeight": 4.8000001907348632812,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 25.200000762939453125,
					"collectedCube": 11.5,
					"deliveredCube": 0.0,
					"traveledDistance": 39.93560028076171875,
					"distanceToNextOrder": 3.5893819332122802734,
					"revenueAtArrival": 91.59999847412109375,
					"visitTimestamp": 0
				},
				{
					"orderInfo": {
						"revenue": 13.0,
						"serviceTime": 0,
						"timeWindow": [
							420,
							1086
						],
						"creationTimestamp": 1753085262895,
						"cube": 0.10000000149011611938,
						"numberOfPackages": 1,
						"depotId": 0,
						"customData": "",
						"weight": 3.2000000476837158203,
						"phoneNumber": "+12312312",
						"lastName": "",
						"status": 1,
						"firstName": "",
						"alias": "c0",
						"state": 1,
						"type": 0,
						"priority": 0,
						"id": 1194032,
						"location": [
							48.870851999999999293,
							2.3561480000000001311
						],
						"address": {
							"streetNumber": "",
							"postalCode": "",
							"streetName": "",
							"county": "",
							"state": "",
							"extra": "",
							"city": "",
							"country": ""
						},
						"customerInfo": {
							"phoneNumber": "+12312312",
							"email": "c0@yahoo.com",
							"lastName": "",
							"firstName": "",
							"alias": "c0",
							"customData": "",
							"id": 1998451,
							"location": [
								48.870851999999999293,
								2.3561480000000001311
							],
							"address": {
								"streetNumber": "",
								"postalCode": "",
								"streetName": "",
								"county": "",
								"state": "",
								"extra": "",
								"city": "",
								"country": ""
							}
						}
					},
					"matchedLocation": [
						48.87077843750000028,
						2.3565665624999998506
					],
					"indexInRoute": 11,
					"indexInOptimization": 0,
					"arrivalTime": 1596811037000,
					"timeToNextOrder": 6,
					"waitTime": 0,
					"numberOfPackagesAtArrival": 47,
					"collectedNumberOfPackages": 1,
					"deliveredNumberOfPackages": 0,
					"weightAtArrival": 52.5,
					"collectedWeight": 3.2000000476837158203,
					"deliveredWeight": 0.0,
					"cubeAtArrival": 36.700000762939453125,
					"collectedCube": 0.10000000149011611938,
					"deliveredCube": 0.0,
					"traveledDistance": 43.524982452392578125,
					"distanceToNextOrder": 0.025076000019907951355,
					"revenueAtArrival": 93.90000152587890625,
					"visitTimestamp": 0
				}
			],
			"totalTime": 6497,
			"totalDistance": 43.550060272216796875,
			"id": 273348
		}
	]
}

```

***

## Analyzing the Solution - Paris Route Optimization Test[​](#analyzing-the-solution----paris-route-optimization-test "Direct link to Analyzing the Solution -  Paris Route Optimization Test")

![Paris Route Optimization](/docs/cloud-rest-api/assets/images/_solution_02-75e1bc347149b374513dc128358dec25.png)

**Paris Route Optimization**

***

### Summary Table[​](#summary-table "Direct link to Summary Table")

| Metric              | Part 0 (Current Route) |
| ------------------- | ---------------------- |
| **Total Distance**  | 43.55 km               |
| **Total Time**      | 1 hr 48 min 17 sec     |
| **Cost**            | €3.09                  |
| **Departure Point** | Depot 1                |
| **Departure Time**  | 12:49:05 (07/08/2020)  |
| **Destination**     | Depot 1 (Return)       |
| **Arrival Time**    | 14:37:23               |
| **Total Stops**     | 12                     |
| **Pickups**         | 8                      |
| **Deliveries**      | 4                      |

***

### Route Insights[​](#route-insights "Direct link to Route Insights")

**Route (Part 0)** covers **12 tasks** with a mix of **8 pickups** and **4 deliveries**, spanning a total of **43.55 km** and incurring an estimated cost of **€3.09**.

Departing from **Depot 1**, the vehicle begins its route with a series of deliveries - starting at **Order 6**, where it successfully offloads 9 pieces. It then continues to **Order 4** and **Order 8**, delivering 8 and 11 pieces respectively. Following these, two pickups are made at **Order 11** and **Order 3**. The delivery phase concludes at **Order 9**, where 6 more pieces are handed over.

With all deliveries complete, the vehicle transitions into a focused pickup phase - collecting at **Order 5**, **Order 7**, **Order 10**, **Order 2**, and **Order 12**, before making its final collection at **Order 1**. Throughout the journey, the load is dynamically managed, steadily increasing in volume and weight, and culminating in a final onboard total of **52.5 kg** and **36.7 cubic meters**.

The route concludes with a return to **Depot 1** at **14:37:23**, completing a fully optimized loop with no delays, zero wait times, and smooth task sequencing.

***

### Operational Highlights[​](#operational-highlights "Direct link to Operational Highlights")

* **Dynamic Load Handling:** The vehicle managed an evolving load profile, balancing capacity as pickups added volume, weight, and pieces across the route.
* **Time Window Compliance:** All service points were visited within their specified time windows, with zero wait times, demonstrating a highly synchronized schedule.
* **Compact Route Design:** Despite handling 12 stops, the route remained efficient, minimizing both distance and cost while maintaining compliance with constraints.
* **Travel Time:** Total travel time is approximately 1 hour 47 minutes, efficient given the mix of pickups and deliveries.

***

## Conclusion[​](#conclusion "Direct link to Conclusion")

This example demonstrates how to create a fully customized optimization with a single vehicle, define orders, and visualize the results on a map. By following the steps above, you can adapt this example to your specific use case and integrate it into your fleet management workflow.
