Skip to main content
GuidesExamples

Request

Estimated reading time: 5 minutes

Overview

The Request RestAPI allows you to manage requests within the Fleet Management system. You can create, retrieve, update, and delete request data. This RestAPI supports filtering, sorting, and pagination to help manage large datasets efficiently.

Request Object Fields

FieldTypeDescription
idIntegerUnique identifier for the request.
optimizationIdInteger

The ID of the associated optimization.
Only available in the JSON response if the request is an optimization request.

routeIdInteger

The ID of the associated route.
Only available in the JSON response if the request is a route request.

statusInteger
Current status of the request:
0 - Created
1 - Pending
2 - Finished
3 - Canceled
messageStringStatus message for the request.
creationTimestampIntegerTimestamp when the request was created.

Endpoints

1. Get All Requests

Description: Fetches a list of all requests.

  • Method: GET
  • Endpoint: /requests
  • Headers:
    • Authorization: YOUR_API_KEY
  • URL: https://fleetmanagement.magiclaneapis.com/v1/requests
  • Returned error codes:
Error CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase error occurred.

Example:

  • Response Body: (error code 200)
{
"requests": [
{
"id": 23412,
"optimizationId": 32754,
"status": 0,
"message": "Operation done successfully!",
"creationTimestamp": 1747834619
},
{
"id": 23456,
"routeId": 46578,
"status": 0,
"message": "Operation done successfully!",
"creationTimestamp": 1745676643
},
{
"id": 23567,
"routeId": 46587,
"status": 0,
"message": "Operation done successfully!",
"creationTimestamp": 1747786578
}
]
}

2. Get a Request by ID

Description: Retrieves a specific request by ID.

  • Method: GET
  • Endpoint: /requests/{id}
  • Headers:
    • Authorization: YOUR_API_KEY
  • URL: https://fleetmanagement.magiclaneapis.com/v1/requests/{id}
  • Path Parameter:
    • id (integer) - The unique request ID.
  • Returned error codes:
Error CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundRequest not found in database.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase error occurred.

Example:

  • Response Body: (error code 200)
note

In this example, the request contains only the routeId, which means it is a route request.

{
"id": 23567,
"routeId": 46587,
"status": 0,
"message": "Operation done successfully!",
"creationTimestamp": 1747786578
}

3. Cancel Request

Description: Cancel request.

  • Method: DELETE
  • Endpoint: /requests
  • Headers:
    • Authorization: YOUR_API_KEY
  • URL: https://fleetmanagement.magiclaneapis.com/v1/requests
  • Path Parameter:
    • id (integer) - The unique request ID.
  • Returned error codes:
Error CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestRequest done, cannot be canceled anymore.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundRequest not found in database.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase error occurred.
note

When a request is canceled, the corresponding operation that the request is tracking is also canceled. This means that any ongoing processes or actions associated with this request will be stopped immediately, ensuring that no further progress is made on the task.

Example:

  • Response Body: (error code 200)
{
"message": "Operation done successfully!"
}