Table of Contents


Available since version: 1.8
This function allows you to retrieve usermacro details based on filtering options. All parameters are optional. If parameter is set in query this option counted as ON, except if parameter is equal to NULL,


nodeidsarrayNode IDs
groupidsarrayHost Group IDs
hostidsarraySelect all macros from the given hosts and templates.
templateidsarraySelect all host macros from hosts that are linked to the given templates.
hostmacroidsarrayHost Usermacro IDs
globalmacroidsarrayHost Usermacro IDs
globalmacrointegerSearch only global macros
editableintegeronly with read-write permission. Ignored for SuperAdmins
filterarrayOptional filter by usermacro fields
searcharrayReturn user macros by any given usermacro object field pattern
startSearchintegerSearch usermacros field pattern only in start of the field
excludeSearchintegerExclude from result, usermacros by given field pattern
searchWildcardsEnabledintegerSearch pattern in whole field using wildcards 1 - enable, 0 - disable
outputstringOutput options Values: shorten, refer, extend
select_groupsstringSelect host groups Values: shorten, refer, extend
select_hostsstringSelect hosts Values: shorten, refer, extend
select_templatesstringSelect templates Values: shorten, refer, extend
countOutputintegerCount usermacros, return the number of usermacros found
preservekeysintegerReturn hash instead of array Keys of hash are object IDs
sortfieldstringSort by usermacro field Values: macro
sortorderstringSort order Values: ASC, DESC
limitintmax number of usermacro objects to return


resultOperation successful. Result will contain array of Usermacro objects.
errorIn case of any errors


Get host usermacros details by usermacro name “{$AAA}” in specified host groups ID “100100000000011”,“100100000000099”,“100100000010034”:

"jsonrpc": "2.0",
"method": "usermacro.get",
"params": {
	"groupids": ["100100000000011","100100000000099","100100000010034"],
	"filter": {"macro": "{$AAA}"},
	"output": "extend"
"auth": "6f38cddc44cfbb6c1bd186f9a220b5a0",
"id": 2
Retrieved host usermacro details:

"jsonrpc": "2.0",
"result": [{
	"groups": [
		{"groupid": "100100000000011"}
	"hosts": [
		{"hostid": "100100000010077"}
	"hostmacroid": "100100000000005",
	"hostid": "100100000010077",
	"macro": "{$AAA}",
	"value": "aaaa"
"id": 2