[comment]: # ({4c82c7ad-4c82c7ad})
# alert.get

[comment]: # ({/4c82c7ad-4c82c7ad})

[comment]: # ({3c5ac067-ed55724c})
### Description

`integer/array alert.get(object parameters)`

The method allows to retrieve alerts according to the given parameters.

::: noteclassic
This method is available to users of any type. 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]: # ({/3c5ac067-ed55724c})

[comment]: # ({9bc7f5ce-218fa8cf})
### Parameters

`(object)` Parameters defining the desired output.

The method supports the following parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|--|--|------|
|alertids|string/array|Return only alerts with the given IDs.|
|actionids|string/array|Return only alerts generated by the given actions.|
|eventids|string/array|Return only alerts generated by the given events.|
|groupids|string/array|Return only alerts generated by objects from the given host groups.|
|hostids|string/array|Return only alerts generated by objects from the given hosts.|
|mediatypeids|string/array|Return only message alerts that used the given media types.|
|objectids|string/array|Return only alerts generated by the given objects|
|userids|string/array|Return only message alerts that were sent to the given users.|
|eventobject|integer|Return only alerts generated by events related to objects of the given type.<br><br>See event ["object"](/manual/api/reference/event/object#event) for a list of supported object types.<br><br>Default: 0 - trigger.|
|eventsource|integer|Return only alerts generated by events of the given type.<br><br>See event ["source"](/manual/api/reference/event/object#event) for a list of supported event types.<br><br>Default: 0 - trigger events.|
|time\_from|timestamp|Return only alerts that have been generated after the given time.|
|time\_till|timestamp|Return only alerts that have been generated before the given time.|
|selectHosts|query|Return a [hosts](/manual/api/reference/host/object) property with data of hosts that triggered the action operation.|
|selectMediatypes|query|Return a [mediatypes](/manual/api/reference/mediatype/object) property with an array of the media types that were used for the message alert.|
|selectUsers|query|Return a [users](/manual/api/reference/user/object) property with an array of the users that the message was addressed to.|
|sortfield|string/array|Sort the result by the given properties.<br><br>Possible values: `alertid`, `clock`, `eventid`, `mediatypeid`, `sendto`, `status`.|
|countOutput|boolean|These parameters being common for all `get` methods are described in the [reference commentary](/manual/api/reference_commentary#common_get_method_parameters).|
|editable|boolean|^|
|excludeSearch|boolean|^|
|filter|object|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|

[comment]: # ({/9bc7f5ce-218fa8cf})

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

`(integer/array)` Returns either:

-   an array of objects;
-   the count of retrieved objects, if the `countOutput` parameter has
    been used.

[comment]: # ({/7223bab1-7223bab1})

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

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

[comment]: # ({57a43812-8d56d57c})
#### Retrieve alerts by action ID

Retrieve all alerts generated by action "3".

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

```json
{
    "jsonrpc": "2.0",
    "method": "alert.get",
    "params": {
        "output": "extend",
        "actionids": "3"
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "alertid": "1",
            "actionid": "3",
            "eventid": "21243",
            "userid": "1",
            "clock": "1362128008",
            "mediatypeid": "1",
            "sendto": "support@company.com",
            "subject": "PROBLEM: Zabbix agent on Linux server is unreachable for 5 minutes: ",
            "message": "Trigger: Zabbix agent on Linux server is unreachable for 5 minutes: \nTrigger status: PROBLEM\nTrigger severity: Not classified",
            "status": "0",
            "retries": "3",
            "error": "",
            "esc_step": "1",
            "alerttype": "0",
            "p_eventid": "0",
            "acknowledgeid": "0"
        }
    ],
    "id": 1
}
```

[comment]: # ({/57a43812-8d56d57c})

[comment]: # ({5371aed2-5371aed2})
### See also

-   [Host](/manual/api/reference/host/object#host)
-   [Media type](/manual/api/reference/mediatype/object#media_type)
-   [User](/manual/api/reference/user/object#user)

[comment]: # ({/5371aed2-5371aed2})

[comment]: # ({14a85885-14a85885})
### Source

CAlert::get() in *ui/include/classes/api/services/CAlert.php*.

[comment]: # ({/14a85885-14a85885})
