usermacro_get
Retrieve Zabbix user macros globally or for specific hosts/templates to reuse {$MACRO} variables in item keys and triggers; filter by IDs, names, or values.
Instructions
Retrieve user macros. User macros are custom variables ({$MACRO}) that can be defined globally or on individual hosts/templates. They are used in item keys, trigger expressions, and other places to make configuration reusable and environment-specific. Host-level macros override global macros of the same name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return. | |
| filter | No | Return only results whose properties exactly match the given values (a single value or a list of values per key). Example: {"status": 0} or {"status": [0, 1]}. Keys: automatic (6.2+), hostid, hostmacroid, macro, type, value. Text properties cannot be filtered; use 'search' for them. | |
| output | No | Properties of the usermacro object to return. Pass 'extend' for all, 'count' for the number of matches only, or a comma-separated list of property names. Default when omitted: hostmacroid, hostid, macro, value. Properties: automatic (6.2+), config (7.4+), description, hostid, hostmacroid, macro, type, value. | |
| search | No | Return results whose string properties contain the given pattern (case-insensitive; '*' is a wildcard when searchWildcardsEnabled is true). Example: {"name": "web"}. Keys: description, macro, value. | |
| server | No | Target Zabbix server. Available: default. Defaults to 'default' if omitted. | |
| hostids | No | Return only macros defined on the given hosts. | |
| raw_json | No | Strips the security disclaimer preamble from the response so it is pure JSON. Default: false. Requires the bearer token to have 'allow_raw_json' explicitly enabled by an operator in the admin portal - tokens without that policy receive a PolicyError instead. WARNING: setting true bypasses the prompt-injection mitigation marker that wraps untrusted Zabbix data (host names, item descriptions, problem text). LLM clients (Claude, GPT, Cursor, ...) should leave this false; only programmatic non-LLM consumers (Python scripts, n8n workflows that json.loads the result) should set true. | |
| sortfield | No | Sort by one or more of: macro (comma-separated for several; pair with 'sortorder'). No other property is sortable. | |
| sortorder | No | Sort order: 'ASC' (ascending) or 'DESC' (descending). | |
| countOutput | No | Return the count of matching results instead of the actual data. | |
| searchByAny | No | If true, return results matching ANY search field (OR). Default is ALL fields (AND). | |
| extra_params | No | Other native usermacro.get parameters, merged into the request as-is. Parameters: globalmacro, groupids, inherited (6.0+). Sub-object selects (value 'extend', 'count' or a list of property names): selectGroups (removed in 7.2), selectHostGroups (6.2+), selectHosts, selectTemplateGroups (6.2+), selectTemplates. Any other key is refused here, because Zabbix would silently ignore it. For a parameter you are sure exists on your release but is not listed, use zabbix_raw_api_call. | |
| hostmacroids | No | Return only host macros with the given IDs. | |
| globalmacroids | No | Return only global macros with the given IDs. | |
| searchWildcardsEnabled | No | If true, enable * and ? wildcards in search patterns. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |