# Order

Last updated:

<!-- -->

October 18, 2026

<!-- -->

\| 12 minutes read

<br />

<br />

The **Order Rest API** allows you to manage orders within the Fleet Management system. You can create, retrieve, update, and delete order records. This Rest API supports filtering, sorting, and pagination to help manage large datasets efficiently.

### Order Object Fields[​](#order-object-fields "Direct link to Order Object Fields")

| Field               | Type    | Description                                                                                  |
| ------------------- | ------- | -------------------------------------------------------------------------------------------- |
| `id`                | Integer | Unique identifier for the order.                                                             |
| `customerInfo`      | Object  | Customer details linked to the order. Cannot be changed once saved.                          |
| `location`          | Object  | Location details of the order.                                                               |
| `alias`             | String  | Short name or identifier for the order.                                                      |
| `firstName`         | String  | First name of the customer.                                                                  |
| `lastName`          | String  | Last name of the customer.                                                                   |
| `address`           | Object  | Address details of the order.                                                                |
| `phoneNumber`       | String  | Contact number for the order.                                                                |
| `customData`        | String  | Additional order-specific data.                                                              |
| `type`              | Integer | Order type:`0` - Pickup`1` - Delivery                                                        |
| `status`            | Integer | Order status:`0` - Unscheduled`1` - Scheduled                                                |
| `state`             | Integer | Order state:`0` - None`1` - On Route`2` - Servicing`3` - Rejected`4` - Completed`5` - Failed |
| `priority`          | Integer | Order priority:`0` - Low`1` - High                                                           |
| `numberOfPackages`  | Integer | Number of packages in the order.                                                             |
| `weight`            | Float   | Total weight of the order.                                                                   |
| `cube`              | Float   | Total volume of the order.                                                                   |
| `timeWindow`        | Object  | Time window during which the order should be serviced.                                       |
| `serviceTime`       | Integer | Time (in seconds) required to complete the order.                                            |
| `revenue`           | Float   | Revenue associated with the order.                                                           |
| `depotId`           | Integer | Depot associated with the order.                                                             |
| `creationTimestamp` | Integer | Timestamp of when the order was created.                                                     |

***

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

### 1. Create Order[​](#1-create-order "Direct link to 1. Create Order")

**Description:** Adds a list of orders to the database.

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

* **Endpoint:** `POST /fleetmanagement/orders`

* **Headers:**

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

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                                                                                                                           |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                                                                                                                                 |
| `400 Bad Request`           | - The order’s customer was not found/doesn’t exist.<br />- The order doesn’t have the coordinates set.<br />- The time window format is wrong.<br />- The number of packages/weight/cubic volume has a negative value or exceeds the maximum limit.<br />- The orders’ phone number has wrong format. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                                                                                                                        |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                                                                                                                                |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                                                                                                                              |

Note

If the operation is successful, the `Order` 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

* `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
[
  {
    "customerId": 1838721,
    "location": [
      48.870852,
      2.356148
    ],
    "alias": "Magic Order",
    "firstName": "Magic",
    "lastName": "Order",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+1202555018",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 3,
    "weight": 5.1,
    "cube": 2.5,
    "revenue": 12,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  },
  {
    "customerId": 0,
    "email": "magiccustomer2@example.com",
    "location": [
      48.827865,
      2.379216
    ],
    "alias": "Magic Order2",
    "firstName": "Magic2",
    "lastName": "Order2",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "phoneNumber": "+1202555019",
    "customData": "",
    "type": 0,
    "status": 0,
    "state": 1,
    "priority": 0,
    "numberOfPackages": 2,
    "weight": 4.5,
    "cube": 1.1,
    "revenue": 16,
    "timeWindow": [
      420,
      1086
    ],
    "serviceTime": 0,
    "depotId": 0
  }
]

```

```json
[
  {
    "customerId": 0,
    "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

* ▶`orders`(

  <!-- -->

  array

  <!-- -->

  )

  List of order objects.

```json
{
  "orders": [
    {
      "id": 879887,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1838721,
        "alias": "Magic Customer",
        "firstName": "Magic",
        "lastName": "Customer",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "magiccustomer@example.com",
        "phoneNumber": "+1202555018",
        "location": [
          48.870852,
          2.356148
        ],
        "customData": ""
      },
      "location": [
        48.870852,
        2.356148
      ],
      "alias": "Magic Order",
      "firstName": "Magic",
      "lastName": "Order",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+1202555018",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 3,
      "weight": 5.1,
      "cube": 2.5,
      "revenue": 12,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879888,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1838722,
        "alias": "Magic Customer2",
        "firstName": "Magic",
        "lastName": "Customer2",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "magiccustomer2@example.com",
        "phoneNumber": "+1202555018",
        "location": [
          48.870852,
          2.356148
        ],
        "customData": ""
      },
      "location": [
        48.827865,
        2.379216
      ],
      "alias": "Magic Order2",
      "firstName": "Magic2",
      "lastName": "Order2",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+1202555019",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 2,
      "weight": 4.5,
      "cube": 1.1,
      "revenue": 16,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ]
}

```

```json
{
  "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
    }
  ]
}

```

***

### 2. Get All Orders[​](#2-get-all-orders "Direct link to 2. Get All Orders")

**Description:** Fetches a list of all orders with optional filtering.

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

* **Endpoint:** `GET /fleetmanagement/orders`

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

* **Query Parameters:**

  * `search` (string, *optional*) – General search term across orders.
  * `id` (string, *optional*) – Filter by order ID (`id=value:exact` for exact match).
  * `alias` (string, *optional*) – Filter by order alias (`alias=value:exact` for exact match).
  * `firstName` (string, *optional*) – Filter by first name (`firstName=value:exact` for exact match).
  * `lastName` (string, *optional*) – Filter by last name (`lastName=value:exact` for exact match).
  * `location` (string, *optional*) – Filter by location (`location=value:exact` for exact match).
  * `country` (string, *optional*) – Filter by country (`country=value:exact` for exact match).
  * `state` (string, *optional*) – Filter by state (`state=value:exact` for exact match).
  * `county` (string, *optional*) – Filter by county (`county=value:exact` for exact match).
  * `city` (string, *optional*) – Filter by city (`city=value:exact` for exact match).
  * `postalCode` (string, *optional*) – Filter by postal code (`postalCode=value:exact` for exact match).
  * `streetName` (string, *optional*) – Filter by street name (`streetName=value:exact` for exact match).
  * `streetNumber` (string, *optional*) – Filter by street number (`streetNumber=value:exact` for exact match).
  * `extra` (string, *optional*) – Filter by extra address value (`extra=value:exact` for exact match).
  * `phoneNumber` (string, *optional*) – Filter by phone number (`phoneNumber=value:exact` for exact match).
  * `type` (string, *optional*) – Filter by order type.
  * `status` (string, *optional*) – Filter by order status.
  * `orderState` (string, *optional*) – Filter by order state.
  * `timeWindowStart` (string, *optional*) – Filter by time window start (`timeWindowStart=value:exact` for exact match).
  * `timeWindowEnd` (string, *optional*) – Filter by time window end (`timeWindowEnd=value:exact` for exact match).
  * `creationTime` (string, *optional*) – Filter by creation time (`creationTime=value:exact` for exact match).
  * `priority` (string, *optional*) – Filter by order priority.
  * `customData` (string, *optional*) – Filter by custom data (`customData=value:exact` for exact match).
  * `customerId` (string, *optional*) – Filter by customer ID (`customerId=value:exact` for exact match).
  * `depotId` (string, *optional*) – Filter by depot/misc location ID (`depotId=value:exact` for exact match).
  * `sort` (string, *optional*) – Sorting format: `column1:asc/desc,column2:asc/desc`
    * Available columns: `id, alias, firstName, lastName, latitude, longitude, country, state, county, city, postalCode, streetName, streetNumber, extra, phoneNumber, type, timeWindowStart, timeWindowEnd, creationTime, serviceTime, priority, customData, customerId, depotId`
  * `includeColumns` (string, *optional*) – Specify which columns to include.
    <!-- -->
    * Available columns: `id, alias, firstName, lastName, phoneNumber, type,timeWindowStart, timeWindowEnd, serviceTime, creationTime, packages, revenue, cube, weight, priority, status, orderState, customerId, depotId, latitude, longitude, country, state, county, city, postalCode, streetName, streetNumber, extra`
  * `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

* ▶`orders`(

  <!-- -->

  array

  <!-- -->

  )

  List of order objects.

```json
{
  "orders": [
    {
      "id": 879887,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1838721,
        "alias": "Magic Customer",
        "firstName": "Magic",
        "lastName": "Customer",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "magiccustomer@example.com",
        "phoneNumber": "+1202555018",
        "location": [
          48.870852,
          2.356148
        ],
        "customData": ""
      },
      "location": [
        48.870852,
        2.356148
      ],
      "alias": "Magic Order",
      "firstName": "Magic",
      "lastName": "Order",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+1202555018",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 3,
      "weight": 5.1,
      "cube": 2.5,
      "revenue": 12,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    },
    {
      "id": 879888,
      "creationTimestamp": 1752745377776,
      "customerInfo": {
        "id": 1838722,
        "alias": "Magic Customer2",
        "firstName": "Magic",
        "lastName": "Customer2",
        "address": {
          "country": "",
          "state": "",
          "county": "",
          "city": "",
          "postalCode": "",
          "streetName": "",
          "streetNumber": ""
        },
        "email": "magiccustomer2@example.com",
        "phoneNumber": "+1202555018",
        "location": [
          48.870852,
          2.356148
        ],
        "customData": ""
      },
      "location": [
        48.827865,
        2.379216
      ],
      "alias": "Magic Order2",
      "firstName": "Magic2",
      "lastName": "Order2",
      "address": {
        "country": "",
        "state": "",
        "county": "",
        "city": "",
        "postalCode": "",
        "streetName": "",
        "streetNumber": ""
      },
      "phoneNumber": "+1202555019",
      "customData": "",
      "type": 0,
      "status": 0,
      "state": 1,
      "priority": 0,
      "numberOfPackages": 2,
      "weight": 4.5,
      "cube": 1.1,
      "revenue": 16,
      "timeWindow": [
        420,
        1086
      ],
      "serviceTime": 0,
      "depotId": 0
    }
  ]
}

```

```json
{
  "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
    }
  ]
}

```

***

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

**Description:** Retrieves a specific order by ID.

* **Base URL:** `https://api.magiclane.net/api/v1`
* **Endpoint:** `GET /fleetmanagement/orders/{id}`
* **Headers:**
  * `Authorization: YOUR_API_KEY`
* **Path Parameter:**
  * `id` (integer, \**required*) - The unique order 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`             | Order 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 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": 879887,
  "creationTimestamp": 1752745377776,
  "customerInfo": {
    "id": 1838721,
    "alias": "Magic Customer",
    "firstName": "Magic",
    "lastName": "Customer",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "magiccustomer@example.com",
    "phoneNumber": "+1202555018",
    "location": [
      48.870852,
      2.356148
    ],
    "customData": ""
  },
  "location": [
    48.870852,
    2.356148
  ],
  "alias": "Magic Order",
  "firstName": "Magic",
  "lastName": "Order",
  "address": {
    "country": "",
    "state": "",
    "county": "",
    "city": "",
    "postalCode": "",
    "streetName": "",
    "streetNumber": ""
  },
  "phoneNumber": "+1202555018",
  "customData": "",
  "type": 0,
  "status": 0,
  "state": 1,
  "priority": 0,
  "numberOfPackages": 3,
  "weight": 5.1,
  "cube": 2.5,
  "revenue": 12,
  "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
}

```

***

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

**Description:** Updates an existing order record.

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

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

* **Headers:**

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

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

* **Query Parameter:**
  <br />
  <!-- -->
  -`autoAssignDepot`(integer, *optional*) ( `0`: (default) - No depot will be auto assigned to the current order. `1`: The closest depot (depending on time) will be assigned to the current order.)

* **Returned error codes:**

| Error Code                  | Description                                                                                                                                                                                                                                                                                           |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200 Successful`            | Successful operation.                                                                                                                                                                                                                                                                                 |
| `400 Bad Request`           | - The order’s customer was not found/doesn’t exist.<br />- The order doesn’t have the coordinates set.<br />- The time window format is wrong.<br />- The number of packages/weight/cubic volume has a negative value or exceeds the maximum limit.<br />- The orders’ phone number has wrong format. |
| `401 Unauthorized`          | API key is missing or invalid.                                                                                                                                                                                                                                                                        |
| `404 Not Found`             | Order not found in database.                                                                                                                                                                                                                                                                          |
| `405 Method Not Allowed`    | Incorrect method type.                                                                                                                                                                                                                                                                                |
| `500 Internal Server Error` | Database error occurred.                                                                                                                                                                                                                                                                              |

#### Example:[​](#example-3 "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": 879887,
  "creationTimestamp": 1752745377776,
  "customerInfo": {
    "id": 1838721,
    "alias": "Magic Customer",
    "firstName": "Magic",
    "lastName": "Customer",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "magiccustomer@example.com",
    "phoneNumber": "+1202555018",
    "location": [
      48.870852,
      2.356148
    ],
    "customData": ""
  },
  "location": [
    48.870852,
    2.356148
  ],
  "alias": "Magic Order",
  "firstName": "Magic",
  "lastName": "Order",
  "address": {
    "country": "",
    "state": "",
    "county": "",
    "city": "",
    "postalCode": "",
    "streetName": "",
    "streetNumber": ""
  },
  "phoneNumber": "+1202555018",
  "customData": "",
  "type": 0,
  "status": 0,
  "state": 1,
  "priority": 0,
  "numberOfPackages": 3,
  "weight": 5.1,
  "cube": 2.5,
  "revenue": 12,
  "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 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": 879887,
  "creationTimestamp": 1752745377776,
  "customerInfo": {
    "id": 1838721,
    "alias": "Magic Customer",
    "firstName": "Magic",
    "lastName": "Customer",
    "address": {
      "country": "",
      "state": "",
      "county": "",
      "city": "",
      "postalCode": "",
      "streetName": "",
      "streetNumber": ""
    },
    "email": "magiccustomer@example.com",
    "phoneNumber": "+1202555018",
    "location": [
      48.870852,
      2.356148
    ],
    "customData": ""
  },
  "location": [
    48.870852,
    2.356148
  ],
  "alias": "Magic Order",
  "firstName": "Magic",
  "lastName": "Order",
  "address": {
    "country": "",
    "state": "",
    "county": "",
    "city": "",
    "postalCode": "",
    "streetName": "",
    "streetNumber": ""
  },
  "phoneNumber": "+1202555018",
  "customData": "",
  "type": 0,
  "status": 0,
  "state": 1,
  "priority": 0,
  "numberOfPackages": 3,
  "weight": 5.1,
  "cube": 2.5,
  "revenue": 12,
  "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
}

```

***

### 5. Delete Orders[​](#5-delete-orders "Direct link to 5. Delete Orders")

**Description:** Deletes orders from the system.

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

* **Endpoint:** `DELETE /fleetmanagement/orders`

* **Headers:**

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

* **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 orders because at least one of them does not exist or is used in another operation. |
| `405 Method Not Allowed`    | Incorrect method type.                                                                           |
| `500 Internal Server Error` | Database error occurred.                                                                         |

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

* **Request Body:**

```json
{
  "ids": [78910, 78911]
}

```

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

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

```
