[comment]: # ({c9bc126a-c9bc126a})
# task.create

[comment]: # ({/c9bc126a-c9bc126a})

[comment]: # ({9a39d714-0e3179d3})
### Description

`object task.create(object/array tasks)`

This method allows to create tasks.

::: noteclassic
This method is available to users of any type (to *Admin* and *User* type users since Zabbix 7.4.3).
Permissions to call the method can be revoked in user role settings.
See [User roles](/manual/web_interface/frontend_sections/users/user_roles) for more information.
:::

[comment]: # ({/9a39d714-0e3179d3})

[comment]: # ({8628e056-2574c234})
### Parameters

`(object/array)` A task to create.

The method accepts tasks with the [standard task properties](object#task-object).

Note that 'Execute now' tasks can be created only for the following types of items/discovery rules:

-   Zabbix agent (passive)
-   Simple check
-   SNMP agent (v1/v2/v3)
-   Zabbix internal
-   External check
-   Database monitor
-   HTTP agent
-   IPMI agent
-   SSH agent
-   TELNET agent
-   JMX agent
-   Calculated
-   Dependent item
-   Script
-   Browser

If the item/discovery rule is of type "Dependent item", then its master item must also be one of the above types.

[comment]: # ({/8628e056-2574c234})

[comment]: # ({ab87ce2a-ab87ce2a})
### Return values

`(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`.

[comment]: # ({/ab87ce2a-ab87ce2a})

[comment]: # ({b41637d2-b41637d2})
### Examples

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({69ebf78a-5c5fa6f1})
#### Creating a task

Create an 'Execute now' task for an item and a low-level discovery rule.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "task.create",
    "params": [
        {
            "type": 6,
            "request": {
                "itemid": "10092"
            }
        },
        {
            "type": 6,
            "request": {
                "itemid": "10093"
            }
        }
    ],
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "1",
            "2"
        ]
    },
    "id": 1
}
```

Create a 'Refresh proxy configuration' task for two proxies.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "task.create",
    "params": [
        {
            "type": 2,
            "request": {
                "proxyids": ["10459", "10460"]
            }
        }
    ],
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "1"
        ]
    },
    "id": 1
}
```

Create a 'Diagnostic information' task.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "task.create",
    "params": [
        {
            "type": 1,
            "request": {
                "alerting": {
                    "stats": [
                        "alerts"
                    ],
                    "top": {
                        "media.alerts": 10
                    }
                },
                "lld": {
                    "stats": "extend",
                    "top": {
                        "values": 5
                    }
                }
            },
            "proxyid": 0
        }
    ],
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "taskids": [
            "3"
        ]
    },
    "id": 1
}
```

[comment]: # ({/69ebf78a-5c5fa6f1})

[comment]: # ({58f08e8d-d87c906b})
### See also

-   [Task](/manual/api/reference/task/object)
-   ['Execute now' request object](/manual/api/reference/task/object#execute-now-request-object)
-   ['Refresh proxy configuration' request object](/manual/api/reference/task/object#refresh-proxy-configuration-request-object)
-   ['Diagnostic information' request object](/manual/api/reference/task/object#diagnostic-information-request-object)

[comment]: # ({/58f08e8d-d87c906b})

[comment]: # ({be350bd3-be350bd3})
### Source

CTask::create() in *ui/include/classes/api/services/CTask.php*.

[comment]: # ({/be350bd3-be350bd3})
