[comment]: # translation:outdated

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

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

[comment]: # ({51763cd1-db3d5c68})
### Descrizione

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

Questo metodo consente di creare nuove macro host.

::: noteclassic
Questo metodo è disponibile solo per i tipi di utente *Admin* e *Super admin*.
Le autorizzazioni per chiamare il metodo possono essere revocate nelle impostazioni del ruolo utente.
Per ulteriori informazioni, vedere [Ruoli utente](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/51763cd1-db3d5c68})

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

`(object/array)` Macro host da creare.

Il metodo accetta macro host con le [proprietà standard delle macro host](object#host-macro).

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

[comment]: # ({bd0c3c49-bd0c3c49})
### Valori restituiti

"(object)" Restituisce un oggetto contenente gli ID delle macro host create
sotto la proprietà "hostmacroids". L'ordine degli ID restituiti
corrisponde all'ordine delle macro host passate.

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

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

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

[comment]: # ({b1d03639-7c0da88a})
#### Creazione di una macro host

Creare una macro host "{$SNMP\_COMMUNITY}" con il valore "public" sull'host
"10198".

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

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

Risposta:

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

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

[comment]: # ({084b8f3c-084b8f3c})
### Fonte

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

[comment]: # ({/084b8f3c-084b8f3c})
