Skip to main content
GuidesExamples

Template Parameters

Estimated reading time: 10 minutes

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

FieldTypeDescription
idIntegerUnique identifier for the template.
nameStringName of the template.
ignoreTimeWindowBooleanWhether to ignore the time window. Default: false.
balancedRoutesBooleanWhether the routes should have a similar number of orders.
optimizationCriterionInteger
Optimization criterion:
0 - Distance
1 - Time (default)
arrangeCriterionInteger
Order arrangement criterion (used only if optimizing by distance):
0 - Matrix (default)
1 - Euclidean
2 - Exact Euclidean
3 - Manhattan
optimizationQualityInteger
Optimization quality:
0 - Unoptimized
1 - Fast
2 - Optimized (default)
3 - Best
maxTimeToOptimizeIntegerMaximum time (seconds) for optimization (only used if optimization quality is Best). Default: 300.
maxWaitTimeIntegerMaximum wait time (seconds) before arriving at the next order. Default: 99999999.
routeTypeInteger
Route type:
0 - Round Route (default)
1 - End Anywhere
2 - Custom End
matrixBuiltTypeInteger
Matrix build type:
0 - Set by user using "matrices" field
1 - Real road distances and times
restrictionsInteger
Road restrictions:
0 - None (default)
1 - Tolls
2 - Highways
vehicleCategoryInteger
Vehicle category:
0 - None Electric (default)
1 - Electric
sameDepartureForAllBooleanWhether all routes share the same departure point. Default: false.
sameDestinationForAllBooleanWhether all routes share the same destination. Default: false.
sameVehicleConstraintsForAllBooleanWhether 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 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.
Note

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
    • page (integer, optional) – Page number for pagination.
    • per_page (integer, optional) – Number of items per page.
  • 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)
{
"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 CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundTemplate not found in database.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase 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 CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundTemplate not found in database.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase 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 CodeDescription
200 SuccessfulSuccessful operation.
400 Bad RequestInvalid input or missing required fields.
401 UnauthorizedAPI key is missing or invalid.
404 Not FoundCan't delete template parameters because at least one of them does not exist.
405 Method Not AllowedIncorrect method type.
500 Internal Server ErrorDatabase error occurred.

Example:

  • Request Body:
{
"ids": [101, 102]
}
  • Response Body: (error code 200)
{
"message": "Operation done successfully"
}