Template Parameters
Overview
The Template RestAPI allows you to manage templates within the Fleet Management system. You can create, retrieve, update, and delete templates. This RestAPI supports filtering, sorting, and pagination to help manage large datasets efficiently.
Template Parameters are used solely for storing configuration data as reusable templates. These templates can later be retrieved and applied to operations, enabling consistent and efficient reuse of pre-defined settings.
Template Parameters Object Fields
Field | Type | Description |
---|---|---|
id | Integer | Unique identifier for the template. |
name | String | Name of the template. |
ignoreTimeWindow | Boolean | Whether to ignore the time window. Default: false . |
balancedRoutes | Boolean | Whether the routes should have a similar number of orders. |
optimizationCriterion | Integer | Optimization criterion: 0 - Distance1 - Time (default) |
arrangeCriterion | Integer | Order arrangement criterion (used only if optimizing by distance): 0 - Matrix (default)1 - Euclidean2 - Exact Euclidean3 - Manhattan |
optimizationQuality | Integer | Optimization quality: 0 - Unoptimized1 - Fast2 - Optimized (default)3 - Best |
maxTimeToOptimize | Integer | Maximum time (seconds) for optimization (only used if optimization quality is Best). Default: 300 . |
maxWaitTime | Integer | Maximum wait time (seconds) before arriving at the next order. Default: 99999999 . |
routeType | Integer | Route type: 0 - Round Route (default)1 - End Anywhere2 - Custom End |
matrixBuiltType | Integer | Matrix build type: 0 - Set by user using "matrices" field1 - Real road distances and times |
restrictions | Integer | Road restrictions: 0 - None (default)1 - Tolls2 - Highways |
vehicleCategory | Integer | Vehicle category: 0 - None Electric (default)1 - Electric |
sameDepartureForAll | Boolean | Whether all routes share the same departure point. Default: false . |
sameDestinationForAll | Boolean | Whether all routes share the same destination. Default: false . |
sameVehicleConstraintsForAll | Boolean | Whether all vehicles share the same constraints. Default: false . |
Endpoints
1. Create Template Parameters
Description: Adds a new template to the database.
- Method:
POST
- Endpoint:
/templates
- Headers:
Authorization: YOUR_API_KEY
Content-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/templates
- 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. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
If the operation is successful, the Template Parameters
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:
- Request Body:
{
"name": "Paris - test Optimization 50 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
}
- Response Body: (error code
200
)
{
"id": 87988,
"name": "Paris - test Optimization 50 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
}
2. Get All Templates Parameters
Description: Fetches a list of all templates with optional filtering.
- Method:
GET
- Endpoint:
/templates
- Headers:
Authorization: YOUR_API_KEY
- URL:
https://fleetmanagement.magiclaneapis.com/v1/templates
- 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 optimizations that ignore time windows (ignoreTimeWindow=value:exact
for exact match).balancedRoutes
(string, optional) – Determines if routes have a similar number of orders.routeType
(string, optional) – Filter by route type (routeType=value
).vehicleCategory
(string, optional) – Filter by vehicle type (electric or non-electric).sameVehicleConstraints
(string, optional) – Determines if only one vehicle constraint will be used for all vehicles.sameDeparture
(string, optional) – Determines if all routes start from the same departure point.sameDestination
(string, optional) – Determines if all routes end at the same destination.sort
(string, optional) – Sorting format: – Sorting format:column1:asc/desc,column2:asc/desc
- Available columns:
id, name, creationTime, ignoreTimeWindow, optimizeBy, optimizationQuality, maxOptimizeTime, routeType, matricesBuildType, restrictions, maxWaitTimeOrders, arrangeCriterion, balancedRoutes
- Available columns:
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 | Invalid input or missing required fields. |
401 Unauthorized | API key is missing or invalid. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
Example:
- Response Body: (error code
200
)
{
"templatesParameters": [
{
"id": 87987,
"name": "Paris - test Optimization 50 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
},
{
"id": 87988,
"name": "Paris - test Optimization 25 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
}
]
}
3. Get a Template Parameters by ID
Description: Retrieves a specific template by ID.
- Method:
GET
- Endpoint:
/templates/{id}
- Headers:
Authorization: YOUR_API_KEY
- URL:
https://fleetmanagement.magiclaneapis.com/v1/templates/{id}
- Path Parameter:
id
(integer, *required) - The unique template 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 | Template not found in database. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
Example:
- Response Body: (error code
200
)
{
"id": 87988,
"name": "Paris - test Optimization 50 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
}
4. Update a Template Parameters
Description: Updates an existing template record.
- Method:
PUT
- Endpoint:
/templates/{id}
- Headers:
Authorization: YOUR_API_KEY
Content-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/templates/{id}
- Path Parameter:
id
(integer, *required) - The unique template 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 | Template not found in database. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
Example:
- Request Body:
{
"id": 87988,
"name": "Paris - test Optimization 50 vehicles in Berlin",
"ignoreTimeWindow": false,
"balancedRoutes": 0,
"optimizationCriterion": 1,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 600,
"maxWaitTime": 800,
"routeType": 2,
"matrixBuiltType": 1,
"restrictions": 0,
"vehicleCategory": 0,
"sameDepartureForAll": false,
"sameDestinationForAll": false,
"sameVehicleConstraintsForAll": true
}
- Response Body: (error code
200
)
{
"message": "Operation done successfully"
}
5. Delete Templates Parameters
Description: Deletes templates from the system.
- Method:
DELETE
- Endpoint:
/templates
- Headers:
Authorization: YOUR_API_KEY
- URL:
https://fleetmanagement.magiclaneapis.com/v1/templates
- 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 template parameters because at least one of them does not exist. |
405 Method Not Allowed | Incorrect method type. |
500 Internal Server Error | Database error occurred. |
Example:
- Request Body:
{
"ids": [101, 102]
}
- Response Body: (error code
200
)
{
"message": "Operation done successfully"
}