[comment]: # ({83b3ff24-83b3ff24})
# usermacro.create

[comment]: # ({/83b3ff24-83b3ff24})

[comment]: # ({0daa0d1b-0daa0d1b})
### Description

`object usermacro.create(object/array hostMacros)`

This method allows to create new host macros.

[comment]: # ({/0daa0d1b-0daa0d1b})

[comment]: # ({7c7df9b5-7c7df9b5})
### Parameters

`(object/array)` Host macros to create.

The method accepts host macros with the [standard host macro
properties](object#host_macro).

[comment]: # ({/7c7df9b5-7c7df9b5})

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

`(object)` Returns an object containing the IDs of the created host
macros under the `hostmacroids` property. The order of the returned IDs
matches the order of the passed host macros.

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

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

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

[comment]: # ({c6bccbc9-c6bccbc9})
#### Creating a host macro

Creat a host macro "{$SNMP\_COMMUNITY}" with the value "public" on host
"10198".

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "usermacro.create",
    "params": {
        "hostid": "10198",
        "macro": "{$SNMP_COMMUNITY}",
        "value": "public"
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "hostmacroids": [
            "11"
        ]
    },
    "id": 1
}
```

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

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

CUserMacro::create() in
*frontends/php/include/classes/api/services/CUserMacro.php*.

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