# Optimization

Last updated:

<!-- -->

October 18, 2026

<!-- -->

\| 25 minutes read

<br />

<br />

The **Optimization Rest API** allows you to create, retrieve, update, and delete route optimizations within the Fleet Management system. It helps in planning the most efficient routes by considering various constraints such as time windows, vehicle capacity, and priority.

### Optimization Object Fields[​](#optimization-object-fields "Direct link to Optimization Object Fields")

| Field                     | Type    | Description                                                                                                                        |
| ------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `id`                      | Integer | Unique identifier for the optimization.                                                                                            |
| `name`                    | String  | Name of the optimization.                                                                                                          |
| `configurationParameters` | Array   | List of configuration parameters for the optimization.                                                                             |
| `orders`                  | Array   | List of order IDs included in the optimization.                                                                                    |
| `matrixBuiltType`         | Integer | Defines how the distance matrix is built:`0` - Set by user using "matrices" field`1` - Real road map distances and times (default) |
| `matrices`                | Array   | Contains distance and time matrices, required when `matrixBuiltType` is set to `0`.                                                |
| `departures`              | Array   | List of departure locations for the optimization.                                                                                  |
| `destinations`            | Array   | List of destination locations for the optimization.                                                                                |
| `vehicles`                | Array   | List of vehicle IDs assigned to the optimization.                                                                                  |
| `vehiclesConstraints`     | Array   | List of vehicle constraints applied in the optimization.                                                                           |
| `numberOfVehicles`        | Integer | Total number of vehicles used in the optimization.                                                                                 |
| `creationTimestamp`       | Integer | Timestamp of when the optimization was created.                                                                                    |

***

## Endpoints[​](#endpoints "Direct link to Endpoints")

### 1. Create Optimization[​](#1-create-optimization "Direct link to 1. Create Optimization")

**Description:** An optimization must be created before it can be solved. It defines the routing problem by including `orders`, `vehicles`, and `constraints`.To solve the optimization, the system initiates the process and returns a `request` object. This object allows you to track the status of the optimization until the solution is ready.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `POST /fleetmanagement/optimizations`

* **Headers:**

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

* **Query Parameter:**

  * `encodeShape` (integer, *optional*)

    <!-- -->

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

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `400 Bad Request`           | - The vehicles list is empty.<br />- One or more vehicles are set multiple times.<br />- The vehicle with the id X is not available.<br />- In the same optimization we cannot combine vehicles with type EBike and with vehicle type Car, Truck or Bike.<br />- Number of vehicles constraints should be one or equal to the number of vehicles.<br />- The orders list is empty.<br />- The order with the id X is already scheduled for another optimization. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `404 Not Found`             | - One of the vehicles was not found.<br />- One of the orders was not found.<br />- One of the miscellaneous location set for departure/destination was not found.                                                                                                                                                                                                                                                                                               |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                                                                                                                                                                                                                                                                                         |

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, which can be interpreted as described in the **Returned error codes** section.

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

* **Request Body:**

- Schema View
- JSON Example
- JSON View

* `orders`(

  <!-- -->

  array\[integer]

  <!-- -->

  )

  List of order IDs to include in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization (optional).

* `vehicles`(

  <!-- -->

  array\[integer]

  <!-- -->

  )

  List of vehicle IDs assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization is created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

```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"
      }
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      }
    }
  ],
  "destinations": [],
  "vehicles": [
    135932,
    135933
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "matrixBuildType": 1
}

```

```json
{
  "orders": [
    0,
    0
  ],
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      }
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      }
    }
  ],
  "vehicles": [
    0
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "matrixBuildType": 1
}

```

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

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

* ▶`request`(

  <!-- -->

  object

  <!-- -->

  )

  Request object for tracking the optimization process (optional).

```json
{
  "id": 137827,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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"
      },
      "matchedLocation": [
        48.870569,
        2.356448
      ],
      "numberOfPackages": 3,
      "weight": 20,
      "cube": 1.2,
      "timeToNext": 650,
      "distanceToNext": 30,
      "departureTime": 1752745378776
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      },
      "matchedLocation": [
        48.82674,
        2.342116
      ],
      "numberOfPackages": 4,
      "weight": 15,
      "cube": 2.2,
      "timeToNext": 450,
      "distanceToNext": 23,
      "departureTime": 1752745379776
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26547,
    "optimizationId": 137827,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1,
  "request": {
    "id": 0,
    "optimizationId": 0,
    "status": 0,
    "message": "string",
    "creationTimestamp": 0
  }
}

```

***

### 2. Get all Optimizations[​](#2-get-all-optimizations "Direct link to 2. Get all Optimizations")

**Description:** Fetches all available optimizations.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `GET /fleetmanagement/optimizations`

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

* **Query Parameters:**

  * `search` (string, *optional*) – General search term across optimizations.
  * `id` (string, *optional*) – Filter by optimization ID (`id=value:exact` for exact match).
  * `name` (string, *optional*) – Filter by optimization name (`name=value:exact` for exact match).
  * `creationTime` (string, *optional*) – Filter by creation time (`creationTime=value:exact` for exact match).
  * `ignoreTimeWindow` (string, *optional*) – Filter by optimizations that ignore time windows (`ignoreTimeWindow=value:exact` for exact match).
  * `routeType` (string, *optional*) – Filter by route type (`routeType=value`).
  * `sort` (string, *optional*) – Sorting format: `column1:asc/desc,column2:asc/desc`. Example: `name:asc,creationTime:desc,routeType:asc`
    * Available columns: `id, name, creationTime, ignoreTimeWindow, optimizeBy, optimizationQuality, maxOptimizeTime, routeType, matricesBuildType, restrictions, maxWaitTimeOrders, distanceUnit, arrangeCriterion, balancedRoutes`.
  * `includeColumns` (string, *optional*) – Specify which columns to include.
    <!-- -->
    * Available columns: `id, parentId, name, parentTime, creationTime, childTime, ignoreTimeWindow, balancedRoutes, optimizeBy, arrangeCriterion, optimizationQuality, maxOptimizeTime, routeType, matricesBuildType, restrictions, distanceUnit, idVehicles, maxWaitTimeOrders`.
  * `page` (integer, *optional*) – Page number for pagination.
  * `per_page` (integer, *optional*) – Number of items per page.

* **Returned error codes:**

| Error Code                  | Description                                                                                |
| --------------------------- | ------------------------------------------------------------------------------------------ |
| `200 Successful`            | Successful operation.                                                                      |
| `400 Bad Request`           | The values sent for page and per\_page parameters are incorrect; should be greater than 0. |
| `401 Unauthorized`          | API key is missing or invalid.                                                             |
| `405 Method Not Allowed`    | Incorrect method type.                                                                     |
| `500 Internal Server Error` | Database error occurred.                                                                   |

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

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

- Schema View
- JSON Example
- JSON View

* ▶`optimizations`(

  <!-- -->

  array

  <!-- -->

  )

  List of optimization objects.

```json
{
  "optimizations": [
    {
      "id": 137827,
      "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.827327,
              2.342267
            ],
            "customData": ""
          },
          "location": [
            48.827327,
            2.342267
          ],
          "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.860914,
              2.310625
            ],
            "customData": ""
          },
          "location": [
            48.860914,
            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.344043
            ],
            "customData": ""
          },
          "location": [
            48.895658,
            2.344043
          ],
          "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"
          },
          "matchedLocation": [
            48.870569,
            2.356448
          ],
          "numberOfPackages": 3,
          "weight": 20,
          "cube": 1.2,
          "timeToNext": 650,
          "distanceToNext": 30,
          "departureTime": 1752745378776
        },
        {
          "depotId": 0,
          "alias": "Depot 2",
          "location": [
            48.82674,
            2.342116
          ],
          "address": {
            "country": "France",
            "state": "Ile-de-France",
            "county": "Paris",
            "city": "Paris",
            "postalCode": "75002",
            "streetName": "Rue de Richelieu",
            "streetNumber": "2"
          },
          "matchedLocation": [
            48.82674,
            2.342116
          ],
          "numberOfPackages": 4,
          "weight": 15,
          "cube": 2.2,
          "timeToNext": 450,
          "distanceToNext": 23,
          "departureTime": 1752745379776
        }
      ],
      "destinations": [],
      "vehicles": [
        {
          "id": 135932,
          "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,
          "availableBreaks": []
        },
        {
          "id": 135933,
          "type": 0,
          "status": 0,
          "name": "Car vehicle 2",
          "manufacturer": "Renault",
          "model": "Master",
          "fuelType": 2,
          "lastPosition": [
            48.82674,
            2.342116
          ],
          "consumption": 6.5,
          "plate": "AA-124-AA",
          "maxLoadWeight": 60,
          "maxLoadCube": 50,
          "height": 0,
          "width": 0,
          "weight": 0,
          "length": 0,
          "axleLoad": 0,
          "fixedCost": 0,
          "costPerHour": 0,
          "startTime": 420,
          "endTime": 1439,
          "availableBreaks": []
        }
      ],
      "vehiclesConstraints": [
        {
          "fuelPrice": 1.09,
          "startDate": 1596758400000,
          "maxNumberOfPackages": 53,
          "minNumberOfOrders": 0,
          "maxNumberOfOrders": 99999999,
          "minDistance": 0,
          "maxDistance": 99999999,
          "maxRevenue": 85
        }
      ],
      "configurationParameters": {
        "name": "Paris - test optimization",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 2,
        "maxTimeToOptimize": 300,
        "maxWaitTime": 18000,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "creationTimestamp": 1752745377776,
      "matrixBuildType": 1
    }
  ]
}

```

```json
{
  "optimizations": [
    {
      "id": 0,
      "orders": {
        "orders": [
          {
            "id": 0,
            "creationTimestamp": 0,
            "customerInfo": {
              "id": 0,
              "alias": "string",
              "firstName": "string",
              "lastName": "string",
              "address": {
                "country": "string",
                "state": "string",
                "county": "string",
                "city": "string",
                "postalCode": "string",
                "streetName": "string",
                "streetNumber": "string",
                "extra": "string"
              },
              "email": "string",
              "phoneNumber": "string",
              "location": [
                0,
                0
              ],
              "customData": "string"
            },
            "location": [
              0,
              0
            ],
            "alias": "string",
            "firstName": "string",
            "lastName": "string",
            "address": {
              "country": "string",
              "state": "string",
              "county": "string",
              "city": "string",
              "postalCode": "string",
              "streetName": "string",
              "streetNumber": "string",
              "extra": "string"
            },
            "phoneNumber": "string",
            "customData": "string",
            "type": 0,
            "status": 0,
            "state": 1,
            "priority": 0,
            "numberOfPackages": 0,
            "weight": 0,
            "cube": 0,
            "revenue": 0,
            "timeWindow": [
              0,
              0
            ],
            "serviceTime": 0,
            "depotId": 0
          }
        ]
      },
      "departures": [
        {
          "depotId": 0,
          "alias": "string",
          "location": [
            0,
            0
          ],
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "matchedLocation": [
            0,
            0
          ],
          "numberOfPackages": 0,
          "weight": 0,
          "cube": 0,
          "timeToNext": 0,
          "distanceToNext": 0,
          "departureTime": 0
        }
      ],
      "destinations": [
        {
          "alias": "string",
          "location": [
            0,
            0
          ],
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "matchedLocation": [
            0,
            0
          ],
          "traveledDistance": 0,
          "arrivalTime": 0
        }
      ],
      "vehicles": {
        "vehicles": [
          {
            "id": 0,
            "type": 0,
            "status": 0,
            "name": "string",
            "manufacturer": "string",
            "model": "string",
            "fuelType": 0,
            "lastPosition": [
              0,
              0
            ],
            "consumption": 0,
            "plate": "string",
            "maxLoadWeight": 0,
            "maxLoadCube": 0,
            "height": 0,
            "width": 0,
            "weight": 0,
            "length": 0,
            "axleLoad": 0,
            "fixedCost": 0,
            "costPerHour": 0,
            "startTime": 0,
            "endTime": 0,
            "availableBreaks": []
          }
        ]
      },
      "vehiclesConstraints": [
        {
          "fuelPrice": 0,
          "startDate": 0,
          "maxNumberOfPackages": 0,
          "minNumberOfOrders": 0,
          "maxNumberOfOrders": 0,
          "minDistance": 0,
          "maxDistance": 0,
          "maxRevenue": 0
        }
      ],
      "configurationParameters": {
        "name": "string",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 0,
        "maxTimeToOptimize": 0,
        "maxWaitTime": 0,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "creationTimestamp": 0,
      "matrixBuildType": 1
    }
  ]
}

```

***

### 3. Get an Optimization by ID[​](#3-get-an-optimization-by-id "Direct link to 3. Get an Optimization by ID")

**Description:** Retrieves a specific optimization by its ID.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `GET /fleetmanagement/optimizations/{id}`

* **Headers:**

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

* **Path Parameter:**
  * `id` (integer, \**required*) - The unique optimization ID.

* **Returned error codes:**

| Error Code                  | Description                                                                                            |
| --------------------------- | ------------------------------------------------------------------------------------------------------ |
| `200 Successful`            | Successful operation.                                                                                  |
| `400 Bad Request`           | Invalid input or missing required fields.                                                              |
| `401 Unauthorized`          | API key is missing or invalid.                                                                         |
| `404 Not Found`             | The optimization or one of its components(orders, vehicles, departures,etc) was not found in database. |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                 |
| `500 Internal Server Error` | Database error occurred.                                                                               |

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

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

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

* ▶`request`(

  <!-- -->

  object

  <!-- -->

  )

  Request object for tracking the optimization process (optional).

```json
{
  "id": 137827,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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"
      },
      "matchedLocation": [
        48.870569,
        2.356448
      ],
      "numberOfPackages": 3,
      "weight": 20,
      "cube": 1.2,
      "timeToNext": 650,
      "distanceToNext": 30,
      "departureTime": 1752745378776
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      },
      "matchedLocation": [
        48.82674,
        2.342116
      ],
      "numberOfPackages": 4,
      "weight": 15,
      "cube": 2.2,
      "timeToNext": 450,
      "distanceToNext": 23,
      "departureTime": 1752745379776
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1
}

```

***

### 4. Update an Optimization[​](#4-update-an-optimization "Direct link to 4. Update an Optimization")

**Description:** Updates an existing optimization.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `PUT /fleetmanagement/optimizations/{id}`

* **Headers:**

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

* **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.

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `400 Bad Request`           | - The vehicles list is empty.<br />- One or more vehicles are set multiple times.<br />- The vehicle with the id X is not available.<br />- In the same optimization we cannot combine vehicles with type EBike and with vehicle type Car, Truck or Bike.<br />- Number of vehicles constraints should be one or equal to the number of vehicles.<br />- The orders list is empty.<br />- The order with the id X is already scheduled for another optimization. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `404 Not Found`             | - One of the vehicles was not found.<br />- One of the orders was not found.<br />- One of the miscellaneous location set for departure/destination was not found.                                                                                                                                                                                                                                                                                               |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                                                                                                                                                                                                                                                                                         |

Note

Orders within an optimization **cannot be updated directly** using `UpdateOptimization` request. However, all other fields in the optimization can be modified using this method.

To modify orders, refer to the following examples:

* [Adding Orders to an Optimization](/docs/cloud-rest-api/guides/fleet-management/core-concepts/optimization.md#9-add-orders-to-an-optimization)
* [Updating an Order from an Optimization](/docs/cloud-rest-api/guides/fleet-management/core-concepts/optimization.md#10-update-order-from-an-optimization)
* [Deleting an Order from an Optimization](/docs/cloud-rest-api/guides/fleet-management/core-concepts/optimization.md#11-delete-order-from-an-optimization)

Once the optimization is updated, it will be reoptimized. The reoptimized 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 once the request status is `Finished`.

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

* **Request Body:**

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

* ▶`request`(

  <!-- -->

  object

  <!-- -->

  )

  Request object for tracking the optimization process (optional).

```json
{
  "id": 137827,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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"
      },
      "matchedLocation": [
        48.870569,
        2.356448
      ],
      "numberOfPackages": 3,
      "weight": 20,
      "cube": 1.2,
      "timeToNext": 650,
      "distanceToNext": 30,
      "departureTime": 1752745378776
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      },
      "matchedLocation": [
        48.82674,
        2.342116
      ],
      "numberOfPackages": 4,
      "weight": 15,
      "cube": 2.2,
      "timeToNext": 450,
      "distanceToNext": 23,
      "departureTime": 1752745379776
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26547,
    "optimizationId": 137827,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1,
  "request": {
    "id": 0,
    "optimizationId": 0,
    "status": 0,
    "message": "string",
    "creationTimestamp": 0
  }
}

```

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

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

* ▶`request`(

  <!-- -->

  object

  <!-- -->

  )

  Request object for tracking the optimization process (optional).

```json
{
  "id": 137827,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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"
      },
      "matchedLocation": [
        48.870569,
        2.356448
      ],
      "numberOfPackages": 3,
      "weight": 20,
      "cube": 1.2,
      "timeToNext": 650,
      "distanceToNext": 30,
      "departureTime": 1752745378776
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      },
      "matchedLocation": [
        48.82674,
        2.342116
      ],
      "numberOfPackages": 4,
      "weight": 15,
      "cube": 2.2,
      "timeToNext": 450,
      "distanceToNext": 23,
      "departureTime": 1752745379776
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26547,
    "optimizationId": 137827,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1,
  "request": {
    "id": 0,
    "optimizationId": 0,
    "status": 0,
    "message": "string",
    "creationTimestamp": 0
  }
}

```

***

### 5. Delete an Optimization[​](#5-delete-an-optimization "Direct link to 5. Delete an Optimization")

**Description:** Delete the optimizations for the user. Optimizations can be deleted individually or in bulk.

* **Base URL:** `https://api.magiclane.net/api/v1`
* **Endpoint:** `DELETE /fleetmanagement/optimizations`
* **Headers:**
  * `Authorization: YOUR_API_KEY`
* **Returned error codes:**

| Error Code                  | Description                                                                 |
| --------------------------- | --------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                       |
| `400 Bad Request`           | Invalid input or missing required fields.                                   |
| `401 Unauthorized`          | API key is missing or invalid.                                              |
| `404 Not Found`             | Can't delete the optimizations because at least one of them does not exist. |
| `405 Method Not Allowed`    | Incorrect method type.                                                      |
| `500 Internal Server Error` | Database error occurred.                                                    |

Note

When an optimization is deleted, the routes assigned to that optimization are also deleted.

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

* **Request Body:**

```json
{
  "ids": [123, 456]
}

```

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

```json
{
  "message": "Operation done successfully",
}

```

***

### 6. Get Solutions for Multiple Optimizations[​](#6-get-solutions-for-multiple-optimizations "Direct link to 6. Get Solutions for Multiple Optimizations")

**Description:** Retrieves solutions for multiple optimizations.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `GET /fleetmanagement/optimizations/solution`

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

* **Query Parameter:**

  * `encodeShape` (integer, *optional*)

    <!-- -->

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

* **Returned error codes:**

| Error Code                  | Description                               |
| --------------------------- | ----------------------------------------- |
| `200 Successful`            | Successful operation.                     |
| `400 Bad Request`           | Invalid input or missing required fields. |
| `401 Unauthorized`          | API key is missing or invalid.            |
| `404 Not Found`             | The solutions were not found.             |
| `405 Method Not Allowed`    | Incorrect method type.                    |
| `500 Internal Server Error` | Database error occurred.                  |

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

* **Request Body:**

```json
{
  "ids": [123, 456]
}

```

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

- Schema View
- JSON Example
- JSON View

* ▶`routes`(

  <!-- -->

  array

  <!-- -->

  )

  List of route objects.

* ▶`droppedOrders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of orders excluded from the optimization because no feasible solution was found.

```json
{
  "droppedOrders": [],
  "routes": [
    {
      "id": 255145,
      "optimizationId": 139950,
      "configurationParameters": {
        "name": "Paris - test optimization - Part 1",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 2,
        "maxTimeToOptimize": 300,
        "maxWaitTime": 18000,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "vehicleConstraints": {
        "fuelPrice": 1.0700000524520874,
        "startDate": 1596758400000,
        "maxNumberOfPackages": 53,
        "minNumberOfOrders": 0,
        "maxNumberOfOrders": 99999999,
        "minDistance": 0,
        "maxDistance": 100000000,
        "maxRevenue": 85
      },
      "rideStatus": 1,
      "vehicle": {
        "id": 139813,
        "type": 0,
        "status": 0,
        "name": "Car vehicle",
        "manufacturer": "",
        "model": "",
        "fuelType": 2,
        "lastPosition": [
          48.868507,
          2.359727
        ],
        "consumption": 6.5,
        "plate": "",
        "maxLoadWeight": 60,
        "maxLoadCube": 50,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 10,
        "startTime": 420,
        "endTime": 1439,
        "availableBreaks": [
          {
            "duration": 1800,
            "timeWindows": [
              [
                720,
                780
              ],
              [
                900,
                960
              ]
            ]
          }
        ]
      },
      "departure": {
        "depotId": 0,
        "alias": "Departure2",
        "location": [
          48.82674,
          2.342116
        ],
        "address": {
          "country": "France",
          "state": "",
          "county": "Nouvelle-Aquitaine",
          "city": "Poitiers",
          "postalCode": "86000",
          "streetName": "Boulevard Chasseigne",
          "streetNumber": "34"
        },
        "matchedLocation": [
          48.82679375,
          2.3420853125
        ],
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "timeToNext": 12,
        "distanceToNext": 0.07019499689340591,
        "departureTime": 1596783600000
      },
      "destination": {
        "alias": "Departure2",
        "location": [
          48.82674,
          2.342116
        ],
        "address": {
          "country": "France",
          "state": "",
          "county": "Nouvelle-Aquitaine",
          "city": "Poitiers",
          "postalCode": "86000",
          "streetName": "Boulevard Chasseigne",
          "streetNumber": "34"
        },
        "matchedLocation": [
          48.82679375,
          2.3420853125
        ],
        "traveledDistance": 0.6638350486755371,
        "arrivalTime": 1596783691000
      },
      "shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@mAa@BW",
      "creationTimestamp": 1744096606089,
      "neededFuel": 0.04314928129315376,
      "matrixBuildType": 1,
      "price": 0.04616973176598549,
      "totalWaitTime": 0,
      "totalServiceTime": 0,
      "orders": [
        {
          "orderInfo": {
            "id": 933799,
            "creationTimestamp": 1744096603223,
            "customerInfo": {
              "id": 1839506,
              "alias": "",
              "firstName": "",
              "lastName": "",
              "address": {
                "country": "",
                "state": "",
                "county": "",
                "city": "",
                "postalCode": "",
                "streetName": "",
                "streetNumber": ""
              },
              "email": "c1@yahoo.com",
              "phoneNumber": "+12025550181",
              "location": [
                48.827327,
                2.342267
              ],
              "customData": ""
            },
            "location": [
              48.827327,
              2.342267
            ],
            "alias": "",
            "firstName": "",
            "lastName": "",
            "address": {
              "country": "",
              "state": "",
              "county": "",
              "city": "",
              "postalCode": "",
              "streetName": "",
              "streetNumber": ""
            },
            "phoneNumber": "+12025550181",
            "customData": "",
            "type": 0,
            "status": 1,
            "state": 1,
            "priority": 0,
            "numberOfPackages": 0,
            "weight": 0,
            "cube": 0,
            "revenue": 0,
            "timeWindow": [
              420,
              1086
            ],
            "serviceTime": 0,
            "depotId": 0
          },
          "matchedLocation": [
            48.82734625,
            2.3421875
          ],
          "actualLocation": [
            0,
            0
          ],
          "indexInRoute": 0,
          "indexInOptimization": 1,
          "arrivalTime": 1596783612000,
          "timeToNextOrder": 79,
          "waitTime": 0,
          "numberOfPackagesAtArrival": 0,
          "collectedNumberOfPackages": 0,
          "deliveredNumberOfPackages": 0,
          "weightAtArrival": 0,
          "collectedWeight": 0,
          "deliveredWeight": 0,
          "cubeAtArrival": 0,
          "collectedCube": 0,
          "deliveredCube": 0.07019499689340591,
          "traveledDistance": 0.5936400294303894,
          "distanceToNextOrder": 0,
          "revenueAtArrival": 0
        }
      ],
      "breaks": [
        {
          "duration": 1800,
          "startTime": 720
        }
      ],
      "totalTime": 91,
      "totalDistance": 0.6638350486755371
    }
  ]
}

```

```json
{
  "droppedOrders": [
    {
      "id": 0,
      "creationTimestamp": 0,
      "customerInfo": {
        "id": 0,
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "email": "string",
        "phoneNumber": "string",
        "location": [
          0,
          0
        ],
        "customData": "string"
      },
      "location": [
        0,
        0
      ],
      "alias": "string",
      "firstName": "string",
      "lastName": "string",
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "phoneNumber": "string",
      "customData": "string",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "revenue": 0,
      "timeWindow": [
        0,
        0
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ],
  "routes": [
    {
      "id": 0,
      "optimizationId": 0,
      "configurationParameters": {
        "name": "string",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 0,
        "maxTimeToOptimize": 0,
        "maxWaitTime": 0,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "vehicleConstraints": [
        {
          "fuelPrice": 0,
          "startDate": 0,
          "maxNumberOfPackages": 0,
          "minNumberOfOrders": 0,
          "maxNumberOfOrders": 0,
          "minDistance": 0,
          "maxDistance": 0,
          "maxRevenue": 0
        }
      ],
      "rideStatus": 0,
      "vehicle": {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      },
      "departure": {
        "depotId": 0,
        "alias": "string",
        "location": [
          0,
          0
        ],
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "matchedLocation": [
          0,
          0
        ],
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "timeToNext": 0,
        "distanceToNext": 0,
        "departureTime": 0
      },
      "destination": {
        "alias": "string",
        "location": [
          0,
          0
        ],
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "matchedLocation": [
          0,
          0
        ],
        "traveledDistance": 0,
        "arrivalTime": 0
      },
      "shape": "string",
      "creationTimestamp": 0,
      "neededFuel": 0,
      "matrixBuildType": 1,
      "price": 0,
      "totalWaitTime": 0,
      "totalServiceTime": 0,
      "orders": {
        "orders": [
          {
            "id": 0,
            "creationTimestamp": 0,
            "customerInfo": {
              "id": 0,
              "alias": "string",
              "firstName": "string",
              "lastName": "string",
              "address": {
                "country": "string",
                "state": "string",
                "county": "string",
                "city": "string",
                "postalCode": "string",
                "streetName": "string",
                "streetNumber": "string",
                "extra": "string"
              },
              "email": "string",
              "phoneNumber": "string",
              "location": [
                0,
                0
              ],
              "customData": "string"
            },
            "location": [
              0,
              0
            ],
            "alias": "string",
            "firstName": "string",
            "lastName": "string",
            "address": {
              "country": "string",
              "state": "string",
              "county": "string",
              "city": "string",
              "postalCode": "string",
              "streetName": "string",
              "streetNumber": "string",
              "extra": "string"
            },
            "phoneNumber": "string",
            "customData": "string",
            "type": 0,
            "status": 0,
            "state": 1,
            "priority": 0,
            "numberOfPackages": 0,
            "weight": 0,
            "cube": 0,
            "revenue": 0,
            "timeWindow": [
              0,
              0
            ],
            "serviceTime": 0,
            "depotId": 0
          }
        ]
      },
      "breaks": [],
      "totalTime": 0,
      "totalDistance": 0
    }
  ]
}

```

### 7. Get Optimization's Solution[​](#7-get-optimizations-solution "Direct link to 7. Get Optimization's Solution")

**Description:** Retrieves the computed routes and waypoints for a specific optimization.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `GET /fleetmanagement/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.

* **Returned error codes:**

| Error Code                  | Description                               |
| --------------------------- | ----------------------------------------- |
| `200 Successful`            | Successful operation.                     |
| `400 Bad Request`           | Invalid input or missing required fields. |
| `401 Unauthorized`          | API key is missing or invalid.            |
| `404 Not Found`             | Solution not found.                       |
| `405 Method Not Allowed`    | Incorrect method type.                    |
| `425 Too Early`             | Request not finished.                     |
| `500 Internal Server Error` | Database error occurred.                  |

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

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

- Schema View
- JSON Example
- JSON View

* ▶`routes`(

  <!-- -->

  array

  <!-- -->

  )

  List of route objects.

* ▶`droppedOrders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of orders excluded from the optimization because no feasible solution was found.

```json
{
  "droppedOrders": [],
  "routes": [
    {
      "id": 255145,
      "optimizationId": 139950,
      "configurationParameters": {
        "name": "Paris - test optimization - Part 1",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 2,
        "maxTimeToOptimize": 300,
        "maxWaitTime": 18000,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "vehicleConstraints": {
        "fuelPrice": 1.0700000524520874,
        "startDate": 1596758400000,
        "maxNumberOfPackages": 53,
        "minNumberOfOrders": 0,
        "maxNumberOfOrders": 99999999,
        "minDistance": 0,
        "maxDistance": 100000000,
        "maxRevenue": 85
      },
      "rideStatus": 1,
      "vehicle": {
        "id": 139813,
        "type": 0,
        "status": 0,
        "name": "Car vehicle",
        "manufacturer": "",
        "model": "",
        "fuelType": 2,
        "lastPosition": [
          48.868507,
          2.359727
        ],
        "consumption": 6.5,
        "plate": "",
        "maxLoadWeight": 60,
        "maxLoadCube": 50,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 10,
        "startTime": 420,
        "endTime": 1439,
        "availableBreaks": [
          {
            "duration": 1800,
            "timeWindows": [
              [
                720,
                780
              ],
              [
                900,
                960
              ]
            ]
          }
        ]
      },
      "departure": {
        "depotId": 0,
        "alias": "Departure2",
        "location": [
          48.82674,
          2.342116
        ],
        "address": {
          "country": "France",
          "state": "",
          "county": "Nouvelle-Aquitaine",
          "city": "Poitiers",
          "postalCode": "86000",
          "streetName": "Boulevard Chasseigne",
          "streetNumber": "34"
        },
        "matchedLocation": [
          48.82679375,
          2.3420853125
        ],
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "timeToNext": 12,
        "distanceToNext": 0.07019499689340591,
        "departureTime": 1596783600000
      },
      "destination": {
        "alias": "Departure2",
        "location": [
          48.82674,
          2.342116
        ],
        "address": {
          "country": "France",
          "state": "",
          "county": "Nouvelle-Aquitaine",
          "city": "Poitiers",
          "postalCode": "86000",
          "streetName": "Boulevard Chasseigne",
          "streetNumber": "34"
        },
        "matchedLocation": [
          48.82679375,
          2.3420853125
        ],
        "traveledDistance": 0.6638350486755371,
        "arrivalTime": 1596783691000
      },
      "shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@mAa@BW",
      "creationTimestamp": 1744096606089,
      "neededFuel": 0.04314928129315376,
      "matrixBuildType": 1,
      "price": 0.04616973176598549,
      "totalWaitTime": 0,
      "totalServiceTime": 0,
      "orders": [
        {
          "orderInfo": {
            "id": 933799,
            "creationTimestamp": 1744096603223,
            "customerInfo": {
              "id": 1839506,
              "alias": "",
              "firstName": "",
              "lastName": "",
              "address": {
                "country": "",
                "state": "",
                "county": "",
                "city": "",
                "postalCode": "",
                "streetName": "",
                "streetNumber": ""
              },
              "email": "c1@yahoo.com",
              "phoneNumber": "+12025550181",
              "location": [
                48.827327,
                2.342267
              ],
              "customData": ""
            },
            "location": [
              48.827327,
              2.342267
            ],
            "alias": "",
            "firstName": "",
            "lastName": "",
            "address": {
              "country": "",
              "state": "",
              "county": "",
              "city": "",
              "postalCode": "",
              "streetName": "",
              "streetNumber": ""
            },
            "phoneNumber": "+12025550181",
            "customData": "",
            "type": 0,
            "status": 1,
            "state": 1,
            "priority": 0,
            "numberOfPackages": 0,
            "weight": 0,
            "cube": 0,
            "revenue": 0,
            "timeWindow": [
              420,
              1086
            ],
            "serviceTime": 0,
            "depotId": 0
          },
          "matchedLocation": [
            48.82734625,
            2.3421875
          ],
          "actualLocation": [
            0,
            0
          ],
          "indexInRoute": 0,
          "indexInOptimization": 1,
          "arrivalTime": 1596783612000,
          "timeToNextOrder": 79,
          "waitTime": 0,
          "numberOfPackagesAtArrival": 0,
          "collectedNumberOfPackages": 0,
          "deliveredNumberOfPackages": 0,
          "weightAtArrival": 0,
          "collectedWeight": 0,
          "deliveredWeight": 0,
          "cubeAtArrival": 0,
          "collectedCube": 0,
          "deliveredCube": 0.07019499689340591,
          "traveledDistance": 0.5936400294303894,
          "distanceToNextOrder": 0,
          "revenueAtArrival": 0
        }
      ],
      "breaks": [
        {
          "duration": 1800,
          "startTime": 720
        }
      ],
      "totalTime": 91,
      "totalDistance": 0.6638350486755371
    }
  ]
}

```

```json
{
  "droppedOrders": [
    {
      "id": 0,
      "creationTimestamp": 0,
      "customerInfo": {
        "id": 0,
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "email": "string",
        "phoneNumber": "string",
        "location": [
          0,
          0
        ],
        "customData": "string"
      },
      "location": [
        0,
        0
      ],
      "alias": "string",
      "firstName": "string",
      "lastName": "string",
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "phoneNumber": "string",
      "customData": "string",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "revenue": 0,
      "timeWindow": [
        0,
        0
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ],
  "routes": [
    {
      "id": 0,
      "optimizationId": 0,
      "configurationParameters": {
        "name": "string",
        "ignoreTimeWindow": false,
        "allowDroppingOrders": false,
        "groupingOrders": false,
        "balancedRoutes": 0,
        "optimizationCriterion": 0,
        "arrangeCriterion": 0,
        "optimizationQuality": 0,
        "maxTimeToOptimize": 0,
        "maxWaitTime": 0,
        "routeType": 0,
        "restrictions": 0,
        "distanceUnit": 0,
        "orderSequenceOptions": []
      },
      "vehicleConstraints": [
        {
          "fuelPrice": 0,
          "startDate": 0,
          "maxNumberOfPackages": 0,
          "minNumberOfOrders": 0,
          "maxNumberOfOrders": 0,
          "minDistance": 0,
          "maxDistance": 0,
          "maxRevenue": 0
        }
      ],
      "rideStatus": 0,
      "vehicle": {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      },
      "departure": {
        "depotId": 0,
        "alias": "string",
        "location": [
          0,
          0
        ],
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "matchedLocation": [
          0,
          0
        ],
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "timeToNext": 0,
        "distanceToNext": 0,
        "departureTime": 0
      },
      "destination": {
        "alias": "string",
        "location": [
          0,
          0
        ],
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "matchedLocation": [
          0,
          0
        ],
        "traveledDistance": 0,
        "arrivalTime": 0
      },
      "shape": "string",
      "creationTimestamp": 0,
      "neededFuel": 0,
      "matrixBuildType": 1,
      "price": 0,
      "totalWaitTime": 0,
      "totalServiceTime": 0,
      "orders": {
        "orders": [
          {
            "id": 0,
            "creationTimestamp": 0,
            "customerInfo": {
              "id": 0,
              "alias": "string",
              "firstName": "string",
              "lastName": "string",
              "address": {
                "country": "string",
                "state": "string",
                "county": "string",
                "city": "string",
                "postalCode": "string",
                "streetName": "string",
                "streetNumber": "string",
                "extra": "string"
              },
              "email": "string",
              "phoneNumber": "string",
              "location": [
                0,
                0
              ],
              "customData": "string"
            },
            "location": [
              0,
              0
            ],
            "alias": "string",
            "firstName": "string",
            "lastName": "string",
            "address": {
              "country": "string",
              "state": "string",
              "county": "string",
              "city": "string",
              "postalCode": "string",
              "streetName": "string",
              "streetNumber": "string",
              "extra": "string"
            },
            "phoneNumber": "string",
            "customData": "string",
            "type": 0,
            "status": 0,
            "state": 1,
            "priority": 0,
            "numberOfPackages": 0,
            "weight": 0,
            "cube": 0,
            "revenue": 0,
            "timeWindow": [
              0,
              0
            ],
            "serviceTime": 0,
            "depotId": 0
          }
        ]
      },
      "breaks": [],
      "totalTime": 0,
      "totalDistance": 0
    }
  ]
}

```

***

### 8. Reoptimize an Optimization[​](#8-reoptimize-an--optimization "Direct link to 8. Reoptimize an  Optimization")

**Description:** Creates a new and improved solution (if one exists) for the optimization. Reoptimizing an existing optimization returns a `request` object, which can be used to track the status of the process. Once the request status is marked as *finished*, the new solution can be retrieved using the \[Get Optimization's Solution]\(/guides/core-concepts optimization#7-get-optimizations-solution) endpoint. The latest fuel prices are used in generating the new solution (see [Get Fuel Prices](/docs/cloud-rest-api/guides/fleet-management/core-concepts/fuelprice.md)).

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `POST /fleetmanagement/optimizations/{id}/reoptimize`

* **Headers:**

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

* **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.

* **Returned error codes:**

| Error Code                  | Description                               |
| --------------------------- | ----------------------------------------- |
| `200 Successful`            | Successful operation.                     |
| `400 Bad Request`           | Invalid input or missing required fields. |
| `401 Unauthorized`          | API key is missing or invalid.            |
| `404 Not Found`             | Solution not found.                       |
| `405 Method Not Allowed`    | Incorrect method type.                    |
| `425 Too Early`             | Request not finished.                     |
| `500 Internal Server Error` | Database error occurred.                  |

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

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

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the request.

* `optimizationId`(

  <!-- -->

  integer

  <!-- -->

  )

  The ID of the associated optimization. Only present for optimization requests.

* `routeId`(

  <!-- -->

  integer

  <!-- -->

  )

  The ID of the associated route. Only present for route requests.

* `status`(

  <!-- -->

  integer

  <!-- -->

  )

  Current status of the request:

  <br />

  `0` - Created

  <br />

  `1` - Pending

  <br />

  `2` - Finished

  <br />

  `3` - Canceled

* `message`(

  <!-- -->

  string

  <!-- -->

  )

  Status message for the request.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the request was created.

```json
{
  "id": 32342,
  "optimizationId": 137211,
  "routeId": ,
  "status": 0,
  "message": "Operation done successfully!",
  "creationTimestamp": 123456
}

```

```json
{
 "id": 0,
  "optimizationId": 0,
  "routeId": ,
  "status": 0,
  "message": "string",
  "creationTimestamp": 0
}

```

***

### 9. Add Orders to an Optimization[​](#9-add-orders-to-an-optimization "Direct link to 9. Add Orders to an Optimization")

**Description:** Adds orders to the end of the existing optimization's order list. If the optimization is reoptimized, the new orders will be assigned to routes, and the returned optimization will include a `request` object to track the reoptimization status.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `POST /fleetmanagement/optimizations/{id}/orders`

* **Headers:**

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

* **Path Parameter:**
  * `id` (integer, \**required*) - The unique optimization ID.

* **Query Parameters:**

  * `reoptimize` (integer, *optional*)

    <!-- -->

    * `0` (default): - If the optimization will not be re-optimized, the orders will be added to the optimization's order list, but will not be in a route, so they won't be visited by any vehicle.
    * `1`: The route will be re-optimized.

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                  |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                        |
| `400 Bad Request`           | - One of the orders is scheduled for another optimization.<br />- One of the orders has the time window outside of the optimization’s vehicles start time-end time interval. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                               |
| `404 Not Found`             | - Optimization was not found.<br />- One of the orders to be added was not found.                                                                                            |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                       |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                     |

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

* **Request Body:**

```json
{ 
    "orders":[
        898241,
        898242
    ]
}

```

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

note

There are two possible responses:

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

* Schema View
* JSON Example
* JSON View

- `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

- ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

- ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

- ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

- ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

- ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

- ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

- `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

- `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

- `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

- ▶`request`(

  <!-- -->

  object

  <!-- -->

  )

  Request object for tracking the optimization process (optional).

```json
{
  "id": 137831,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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
    },
    {
      "id": 899037,
      "customerId": 1811911,
      "location": [
        48.868507,
        2.359727
      ],
      "alias": "Customer 13",
      "firstName": "Customer13",
      "lastName": "Customer13",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501813",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 3,
      "weight": 3.1,
      "cube": 0.2,
      "revenue": 3.1,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 899038,
      "customerId": 1811912,
      "location": [
        48.867329,
        2.348105
      ],
      "alias": "Customer 14",
      "firstName": "Customer14",
      "lastName": "Customer14",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501814",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 4,
      "weight": 4.1,
      "cube": 0.3,
      "revenue": 4.2,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ],
  "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"
      }
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      }
    }
  ],
  "destinations": [
    {
      "alias": "Destination 1",
      "location": [
        48.898165,
        2.34484
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75001",
        "streetName": "Rue de Rivoli",
        "streetNumber": "1"
      }
    },
    {
      "alias": "Destination 2",
      "location": [
        48.872064,
        2.402497
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      }
    }
  ],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 2,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26551,
    "optimizationId": 137831,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1,
  "request": {
    "id": 0,
    "optimizationId": 0,
    "status": 0,
    "message": "string",
    "creationTimestamp": 0
  }
}

```

***

### 10. Update Order from an Optimization[​](#10-update-order-from-an-optimization "Direct link to 10. Update Order from an Optimization")

**Description:** Updates an existing order within an optimization.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `PUT /fleetmanagement/optimizations/{id}/orders/{orderId}`

* **Headers:**

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

* **Path Parameters:**

  * `id` (integer, \**required*) - The unique optimization ID.
  * `orderId` (integer, \**required*) - The unique order ID within the optimization.

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                       |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                             |
| `400 Bad Request`           | - Order’s time window is outside of the optimization start-end time limit.<br />- The total number of packages/weight/cubic volume of the optimization’s orders exceeds the vehicles limitations. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                    |
| `404 Not Found`             | - Optimization was not found.<br />- Optimization’s solution not found.<br />- Order not found in optimization’s orders.                                                                          |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                            |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                          |

Note

These changes will also be seen in the route orders for the routes involved in the optimization. So when you want to update a route order you can use this method.

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

* **Request Body:**

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the order.

* ▶`customerInfo`(

  <!-- -->

  object

  <!-- -->

  )

  Customer details for the order.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the order was created.

* `customerId`(

  <!-- -->

  integer

  <!-- -->

  )

  ID of the customer who placed the order.

* `email`(

  <!-- -->

  string

  <!-- -->

  )

  Email address associated with the order.

* `location`(

  <!-- -->

  array\[double]

  <!-- -->

  )

  Order location as \[latitude, longitude].

* `alias`(

  <!-- -->

  string

  <!-- -->

  )

  Order alias.

* `firstName`(

  <!-- -->

  string

  <!-- -->

  )

  First name for the order.

* `lastName`(

  <!-- -->

  string

  <!-- -->

  )

  Last name for the order.

* ▶`address`(

  <!-- -->

  object

  <!-- -->

  )

  Order address.

* `phoneNumber`(

  <!-- -->

  string

  <!-- -->

  )

  Phone number for the order.

* `customData`(

  <!-- -->

  string

  <!-- -->

  )

  Custom data for the order.

* `type`(

  <!-- -->

  integer

  <!-- -->

  )

  Order type - Specifies the type of order.

  * `0` - Pickup
  * `1` - Delivery

* `status`(

  <!-- -->

  integer

  <!-- -->

  )

  Order status - Indicates the scheduling status of the order.

  * `0` - Unscheduled
  * `1` - Scheduled

* `state`(

  <!-- -->

  integer

  <!-- -->

  )

  Order state - Represents the current processing state of the order.

  * `0` - None
  * `1` - On Route
  * `2` - Servicing
  * `3` - Rejected
  * `4` - Completed
  * `5` - Failed

* `priority`(

  <!-- -->

  integer

  <!-- -->

  )

  Order priority - Indicates the urgency level of the order.

  * `0` - Low
  * `1` - High

* `numberOfPackages`(

  <!-- -->

  integer

  <!-- -->

  )

  Number of packages in the order.

* `weight`(

  <!-- -->

  number

  <!-- -->

  )

  Order weight.

* `cube`(

  <!-- -->

  number

  <!-- -->

  )

  Order cube.

* `revenue`(

  <!-- -->

  number

  <!-- -->

  )

  Order revenue.

* `timeWindow`(

  <!-- -->

  array\[integer]

  <!-- -->

  )

  Order time window.

* `serviceTime`(

  <!-- -->

  integer

  <!-- -->

  )

  Order service time.

* `depotId`(

  <!-- -->

  integer

  <!-- -->

  )

  Depot ID for the order.

```json
{
  "id": 899037,
  "customerId": 1811911,
  "location": [
    48.868507,
    2.359727
  ],
  "alias": "Customer 13",
  "firstName": "Customer13",
  "lastName": "Customer13",
  "address": {
    "country": "",
    "state": "",
    "county": "",
    "city": "",
    "postalCode": "",
    "streetName": "",
    "streetNumber": ""
  },
  "phoneNumber": "+120255501813",
  "customData": "",
  "type": 0,
  "status": 0,
  "state": 1,
  "priority": 0,
  "numberOfPackages": 3,
  "weight": 3.1,
  "cube": 0.2,
  "revenue": 3.1,
  "timeWindow": [
    420,
    1086
  ],
  "serviceTime": 0,
  "depotId": 0
}

```

```json
{
  "id": 0,
  "creationTimestamp": 0,
  "customerInfo": {
    "id": 0,
    "alias": "string",
    "firstName": "string",
    "lastName": "string",
    "address": {
      "country": "string",
      "state": "string",
      "county": "string",
      "city": "string",
      "postalCode": "string",
      "streetName": "string",
      "streetNumber": "string",
      "extra": "string"
    },
    "email": "string",
    "phoneNumber": "string",
    "location": [
      0,
      0
    ],
    "customData": "string"
  },
  "location": [
    0,
    0
  ],
  "alias": "string",
  "firstName": "string",
  "lastName": "string",
  "address": {
    "country": "string",
    "state": "string",
    "county": "string",
    "city": "string",
    "postalCode": "string",
    "streetName": "string",
    "streetNumber": "string",
    "extra": "string"
  },
  "phoneNumber": "string",
  "customData": "string",
  "type": 0,
  "status": 0,
  "state": 1,
  "priority": 0,
  "numberOfPackages": 0,
  "weight": 0,
  "cube": 0,
  "revenue": 0,
  "timeWindow": [
    0,
    0
  ],
  "serviceTime": 0,
  "depotId": 0
}

```

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

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

```json
{
  "id": 137831,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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
    },
    {
      "id": 899037,
      "customerId": 1811911,
      "location": [
        48.868507,
        2.359727
      ],
      "alias": "Customer 13",
      "firstName": "Customer13",
      "lastName": "Customer13",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501813",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 3,
      "weight": 3.1,
      "cube": 0.2,
      "revenue": 3.1,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 899038,
      "customerId": 1811912,
      "location": [
        48.867329,
        2.348105
      ],
      "alias": "Customer 14",
      "firstName": "Customer14",
      "lastName": "Customer14",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+120255501814",
      "customData": "",
      "type": 1,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 4,
      "weight": 4.1,
      "cube": 0.3,
      "revenue": 4.2,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ],
  "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"
      }
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      }
    }
  ],
  "destinations": [
    {
      "alias": "Destination 1",
      "location": [
        48.898165,
        2.34484
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75001",
        "streetName": "Rue de Rivoli",
        "streetNumber": "1"
      }
    },
    {
      "alias": "Destination 2",
      "location": [
        48.872064,
        2.402497
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      }
    }
  ],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 2,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1,
  "request": {
    "id": 26551,
    "optimizationId": 137831,
    "status": 1,
    "message": "Operation done successfully!",
    "creationTimestamp": 1752745377776
  }
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1
}

```

***

### 11. Delete Order from an Optimization[​](#11-delete-order-from-an-optimization "Direct link to 11. Delete Order from an Optimization")

**Description:** Delete an order from an existing optimization. It will not appear in the Route as well.

* **Base URL:** `https://api.magiclane.net/api/v1`

* **Endpoint:** `DELETE /fleetmanagement/optimizations/{id}/orders/{orderId}`

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

* **Path Parameters:**

  * `id` (integer, \**required*) - The unique optimization ID.
  * `orderId` (integer, \**required*) - The unique order ID.

* **Query Parameter:**

  * `encodeShape` (integer, *optional*)

    <!-- -->

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

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                                                 |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                                                       |
| `400 Bad Request`           | - If the optimization has only one order, the order cannot be deleted.<br />- The optimization does not contain the order.<br />- If one of the optimization’s routes contains only one order, the order cannot be deleted. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                                              |
| `404 Not Found`             | - Optimization was not found.<br />- Optimization’s solution not found.                                                                                                                                                     |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                                                      |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                                                    |

Note

A route must contain at least two orders for one to be deleted. If the order you want to delete is the only one in the route, it cannot be deleted.

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

* **Response Body:**

- Schema View
- JSON Example
- JSON View

* `id`(

  <!-- -->

  integer

  <!-- -->

  )

  Unique identifier for the optimization.

* ▶`orders`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of order objects included in the optimization.

* ▶`departures`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of departure locations for the optimization.

* ▶`destinations`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of destination locations for the optimization.

* ▶`vehicles`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle objects assigned to the optimization.

* ▶`vehiclesConstraints`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  List of vehicle constraints applied in the optimization.

* ▶`configurationParameters`(

  <!-- -->

  object

  <!-- -->

  )

  Configuration parameters for the optimization.

* `creationTimestamp`(

  <!-- -->

  integer

  <!-- -->

  )

  Timestamp when the optimization was created.

* `matrixBuildType`(

  <!-- -->

  integer

  <!-- -->

  )

  Defines how the distance matrix is built. **Possible values:**

  * `0` - Set by user using 'matrices' field`matrices` field
  * `1` - Real road map distances and times (default) distances and times

* `matrices`(

  <!-- -->

  array\[object]

  <!-- -->

  )

  Contains distance and time matrices, required when matrixBuildType is set to 0 (optional).

```json
{
  "id": 137827,
  "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.827327,
          2.342267
        ],
        "customData": ""
      },
      "location": [
        48.827327,
        2.342267
      ],
      "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.860914,
          2.310625
        ],
        "customData": ""
      },
      "location": [
        48.860914,
        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.344043
        ],
        "customData": ""
      },
      "location": [
        48.895658,
        2.344043
      ],
      "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"
      },
      "matchedLocation": [
        48.870569,
        2.356448
      ],
      "numberOfPackages": 3,
      "weight": 20,
      "cube": 1.2,
      "timeToNext": 650,
      "distanceToNext": 30,
      "departureTime": 1752745378776
    },
    {
      "depotId": 0,
      "alias": "Depot 2",
      "location": [
        48.82674,
        2.342116
      ],
      "address": {
        "country": "France",
        "state": "Ile-de-France",
        "county": "Paris",
        "city": "Paris",
        "postalCode": "75002",
        "streetName": "Rue de Richelieu",
        "streetNumber": "2"
      },
      "matchedLocation": [
        48.82674,
        2.342116
      ],
      "numberOfPackages": 4,
      "weight": 15,
      "cube": 2.2,
      "timeToNext": 450,
      "distanceToNext": 23,
      "departureTime": 1752745379776
    }
  ],
  "destinations": [],
  "vehicles": [
    {
      "id": 135932,
      "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,
      "availableBreaks": []
    },
    {
      "id": 135933,
      "type": 0,
      "status": 0,
      "name": "Car vehicle 2",
      "manufacturer": "Renault",
      "model": "Master",
      "fuelType": 2,
      "lastPosition": [
        48.82674,
        2.342116
      ],
      "consumption": 6.5,
      "plate": "AA-124-AA",
      "maxLoadWeight": 60,
      "maxLoadCube": 50,
      "height": 0,
      "width": 0,
      "weight": 0,
      "length": 0,
      "axleLoad": 0,
      "fixedCost": 0,
      "costPerHour": 0,
      "startTime": 420,
      "endTime": 1439,
      "availableBreaks": []
    }
  ],
  "vehiclesConstraints": [
    {
      "fuelPrice": 1.09,
      "startDate": 1596758400000,
      "maxNumberOfPackages": 53,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 99999999,
      "minDistance": 0,
      "maxDistance": 99999999,
      "maxRevenue": 85
    }
  ],
  "configurationParameters": {
    "name": "Paris - test optimization",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 2,
    "maxTimeToOptimize": 300,
    "maxWaitTime": 18000,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 1752745377776,
  "matrixBuildType": 1
}

```

```json
{
  "id": 0,
  "orders": {
    "orders": [
      {
        "id": 0,
        "creationTimestamp": 0,
        "customerInfo": {
          "id": 0,
          "alias": "string",
          "firstName": "string",
          "lastName": "string",
          "address": {
            "country": "string",
            "state": "string",
            "county": "string",
            "city": "string",
            "postalCode": "string",
            "streetName": "string",
            "streetNumber": "string",
            "extra": "string"
          },
          "email": "string",
          "phoneNumber": "string",
          "location": [
            0,
            0
          ],
          "customData": "string"
        },
        "location": [
          0,
          0
        ],
        "alias": "string",
        "firstName": "string",
        "lastName": "string",
        "address": {
          "country": "string",
          "state": "string",
          "county": "string",
          "city": "string",
          "postalCode": "string",
          "streetName": "string",
          "streetNumber": "string",
          "extra": "string"
        },
        "phoneNumber": "string",
        "customData": "string",
        "type": 0,
        "status": 0,
        "state": 1,
        "priority": 0,
        "numberOfPackages": 0,
        "weight": 0,
        "cube": 0,
        "revenue": 0,
        "timeWindow": [
          0,
          0
        ],
        "serviceTime": 0,
        "depotId": 0
      }
    ]
  },
  "departures": [
    {
      "depotId": 0,
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "numberOfPackages": 0,
      "weight": 0,
      "cube": 0,
      "timeToNext": 0,
      "distanceToNext": 0,
      "departureTime": 0
    }
  ],
  "destinations": [
    {
      "alias": "string",
      "location": [
        0,
        0
      ],
      "address": {
        "country": "string",
        "state": "string",
        "county": "string",
        "city": "string",
        "postalCode": "string",
        "streetName": "string",
        "streetNumber": "string",
        "extra": "string"
      },
      "matchedLocation": [
        0,
        0
      ],
      "traveledDistance": 0,
      "arrivalTime": 0
    }
  ],
  "vehicles": {
    "vehicles": [
      {
        "id": 0,
        "type": 0,
        "status": 0,
        "name": "string",
        "manufacturer": "string",
        "model": "string",
        "fuelType": 0,
        "lastPosition": [
          0,
          0
        ],
        "consumption": 0,
        "plate": "string",
        "maxLoadWeight": 0,
        "maxLoadCube": 0,
        "height": 0,
        "width": 0,
        "weight": 0,
        "length": 0,
        "axleLoad": 0,
        "fixedCost": 0,
        "costPerHour": 0,
        "startTime": 0,
        "endTime": 0,
        "availableBreaks": []
      }
    ]
  },
  "vehiclesConstraints": [
    {
      "fuelPrice": 0,
      "startDate": 0,
      "maxNumberOfPackages": 0,
      "minNumberOfOrders": 0,
      "maxNumberOfOrders": 0,
      "minDistance": 0,
      "maxDistance": 0,
      "maxRevenue": 0
    }
  ],
  "configurationParameters": {
    "name": "string",
    "ignoreTimeWindow": false,
    "allowDroppingOrders": false,
    "groupingOrders": false,
    "balancedRoutes": 0,
    "optimizationCriterion": 0,
    "arrangeCriterion": 0,
    "optimizationQuality": 0,
    "maxTimeToOptimize": 0,
    "maxWaitTime": 0,
    "routeType": 0,
    "restrictions": 0,
    "distanceUnit": 0,
    "orderSequenceOptions": []
  },
  "creationTimestamp": 0,
  "matrixBuildType": 1
}

```

***
