Tasks list
This API is used to retrieve a list of tasks in PTM. It allows you to:
— view all tasks created in the account
— filter tasks by period or status
— sort and paginate the data
— see task status, initiator, addresses, and other parameters
How to get data
Request address
To get the data, use the address: https://tasks.<server_address>/backend/public/dashboard/tasks
Request method
GET
Request parameters
-
page — page number for pagination (default: 1)
-
start — offset for SQL query (default: 0)
-
limit — number of records to fetch (default: 25)
-
usr_id — user ID (from authorization or initialization response)
-
acc_id — account ID (from authorization or initialization response)
-
filter — JSON filter, e.g., selecting tasks for a specific period:
[{"property":"c_begin_time","operator":"bt_date","value":[1575147600,1583139659]}]
|
-
sort— JSON sorting, e.g., sort by task ID:
[{"property":"id","direction":"DESC"}]
|
Example request (JavaScript fetch):
fetch("https://tasks.<server_address>/backend/public/dashboard/tasks?page=1&start=0&limit=25&sort=%5B%7B%22property%22%3A%22id%22%2C%22direction%22%3A%22ASC%22%7D%5D", {
method: "GET",
headers: {
"accept": "*/*",
"x-csrf-token": token // token obtained via getToken
},
credentials: "include"
})
|
Response
{
"page": 1,
"items": [
{
"id": 403,
"c_status_id": 2,
"c_task_type_id": 5,
"c_initiator": "Ivanov I.I.",
"c_address_initiator": "Moscow, Lenina St., 10",
"c_address_tasks": "Moscow, Pushkina St., 25",
"c_address_base": "Base #1",
"c_tasks_lat": 55.7558,
"c_tasks_lon": 37.6173,
"c_base_lat": 55.7512,
"c_base_lon": 37.6184,
"c_user_id": 12,
"c_driver_id": 101,
"c_vehicle_id": "10518",
"c_initiator_type": 1,
"c_begin_time": 1575147600,
"c_return_time": 1575154800,
"c_running_time": 1575148000,
"c_progress_time": 1575149000,
"c_end_time": 1575152000,
"c_information": "{\"comment\":\"Document delivery\"}",
"created_at": "2020-12-01T10:00:00Z",
"updated_at": "2020-12-01T10:10:00Z",
"c_accept_time": 1575147700,
"c_initiator_type_name": "Template: Delivery",
"c_initiator_parameters": "{\"priority\":\"high\"}",
"c_status_name": "Completed",
"c_task_type_name": "Delivery",
"c_task_type_priority": "1",
"c_task_type_priority_name": "High",
"c_task_type_color": "#FF0000"
}
],
"total": 22,
"msg": []
}
|
In response to the API request, the following is returned:
-
page — page number
-
items — array of tasks
-
total — total number of tasks
-
msg — server messages (usually empty)
Main task fields:
-
id — task ID
-
c_status_id — status ID
-
c_task_type_id — task type ID
-
c_initiator — initiator (requestor)
-
c_address_initiator — initiator’s address
-
c_address_tasks — task execution address
-
c_address_base — base address
-
c_tasks_lat, c_tasks_lon — task coordinates
-
c_base_lat, c_base_lon — base coordinates
-
c_user_id — user ID who created the task
-
c_driver_id — assigned driver ID
-
c_vehicle_id — vehicle ID
-
c_initiator_type — task template ID
-
c_begin_time — start time (Unix timestamp)
-
c_return_time — return time
-
c_running_time — time dispatched
-
c_progress_time — task start time
-
c_end_time — completion time
-
c_information — additional JSON data (e.g., comment)
-
created_at — creation time
-
updated_at — last update time
-
c_accept_time — time the task was accepted by the driver
-
c_initiator_type_name — template name
-
c_initiator_parameters — template parameters (JSON)
-
c_status_name — status name
-
c_task_type_name — task type name
-
c_task_type_priority — priority ID
-
c_task_type_priority_name — priority name
-
c_task_type_color — color code of the task type