create_task

To create a new task for a unit, use the unit/create_task method.

Endpoint

Copied!
svc=unit/create_task&params={
    "itemId": <long>,
    "props": <object>
}

Parameters

The request must contain the following parameters:

Parameter Description
itemId ID of the unit for which you want to create a task.
props Task properties as a JSON object. Includes the task subtype, event name, and optionally, description, assignee, priority, status, timestamps, coordinates, and specific parameters.

Task property parameters

The required parameters are marked with an asterisk (*).

Property parameter Type Description
task_sub_type* Integer (uint8) Task subtype. Allowed values:
  • 21 – custom task
  • 22 – filling
  • 23 – battery
  • 26 – maintenance
task_evt_name* String Event name.
task_description String Text description.
task_assignee Long ID of the user to whom the task should be assigned. Requires the OPERATE_AS access right to this user.
task_priority Integer (uint8) Task priority. Allowed values:
  • 1 – low
  • 2 – medium (default)
  • 3 – high
task_status Integer (uint8) Task status. Must be 1 (TASK_STATUS_NEW) or omitted.
task_create_time Unsigned integer UNIX timestamp of the task creation (seconds). The default value is the current server time.
task_update_time Unsigned integer UNIX timestamp of the task update(seconds).
task_address_x
task_address_y
Double Coordinates. Both must be specified or both omitted.
task_params Object Subtype-specific parameters (for example, fuel volume)
task_id This parameter is ignored if sprecified. The server always generates the ID automatically.
task_tags This parameter must be empty.
task_comments This parameter must be empty.
task_done_rejected This parameter must be zero or omitted.

Response

If the request is completed successfully, the response is returned in the following format:

Copied!
{
    "svc_result": {},
    "svc_error": 0
}

If the request fails, an error code is returned.

Error codes

Error code Description
1 Invalid input parameters.
2 Missing Edit tasks access right to the unit.
3 Missing OPERATE_AS access right to the specified user.
4 Specified unit not found.
7 Unknown error.

If you find a mistake in the text, please select it and press Ctrl+Enter.

Report a mistake

Your message was sent. Thank you!

An error occurred while submitting the form

Download PDF file
Download Word document

See also