object task.create(object task)
This method allows to create a new task (such as collect diagnostic data or check items or low-level discovery rules without config reload).
<note note>Starting from Zabbix version 5.0.5, task.create accepts array of task objects object/array tasks, allowing to create multiple tasks in single request. :::
(object) A task to create.
The method accepts the following parameters. Please use this format for Zabbix versions before 5.0.5 only.
| Parameter | Type | Description |
|---|---|---|
| type (required) |
integer | Task type. Possible values: 6 - Check now. |
| itemids (required) |
string/array | IDs of items and low-level discovery rules. |
Please be aware that starting from Zabbix version 5.0.5, request format has changed:
| Parameter | Type | Description |
|---|---|---|
| type (required) |
integer | Task type. Possible values: 1 - Diagnostic information; 6 - Check now. |
| request (required) |
object | Task request object according to the task type. Correct format of request object is described in Task object section. |
| proxy_hostid | integer | Proxy about which Diagnostic information task will collect data. Ignored for Check now tasks. |
Note that 'Check now' tasks can be created for the following types of items/discovery rules:
(object) Returns an object containing the IDs of the created tasks under the taskids property. One task is created for each item and low-level discovery rule. The order of the returned IDs matches the order of the passed itemids or task objects passed as array.
Create a task check now for two items. One is an item, the other is a low-level discovery rule.
Request for Zabbix versions before 5.0.5:
{
"jsonrpc": "2.0",
"method": "task.create",
"params": {
"type": "6",
"itemids": [
"10092",
"10093"
],
},
"auth": "700ca65537074ec963db7efabda78259",
"id": 1
}Same request for Zabbix versions starting from 5.0.5:
{
"jsonrpc": "2.0",
"method": "task.create",
"params": [
{
"type": "6",
"request": {
"itemid": "10092"
}
},
{
"type": "6",
"request": {
"itemid": "10093"
}
}
],
"auth": "700ca65537074ec963db7efabda78259",
"id": 1
}Response is similar for both example requests:
Create a task diagnostic information task. Request:
{
"jsonrpc": "2.0",
"method": "task.create",
"params": [
{
"type": "1",
"request": {
"alerting": {
"stats": [
"alerts"
],
"top": {
"media.alerts": 10
}
},
"lld": {
"stats": "extend",
"top": {
"values": 5
}
}
},
"proxy_hostid": 0
}
],
"auth": "700ca65537074ec963db7efabda78259",
"id": 2
}Response:
CTask::create() in ui/include/classes/api/services/CTask.php.