[comment]: # translation:outdated

[comment]: # ({66c5a546-66c5a546})
# host.massadd

[comment]: # ({/66c5a546-66c5a546})

[comment]: # ({d60cc608-55030171})
### Descrizione

`object host.massadd(object parameters)`

Questo metodo consente di aggiungere simultaneamente più oggetti correlati a tutti gli
host specificati.

::: 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 [User
roles](/manual/web_interface/frontend_sections/users/user_roles).
:::

[comment]: # ({/d60cc608-55030171})

[comment]: # ({10a236c0-c25e2be4})
### Parametri

`(object)` Parametri contenenti gli ID degli host da aggiornare e gli
oggetti da aggiungere a tutti gli host.

Il metodo accetta i seguenti parametri.

|Parametro|[Tipo](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|hosts|object/array|[Host](/manual/api/reference/host/object) da aggiornare.<br><br>Gli host devono avere definita solo la proprietà `hostid`.<br><br>[Comportamento dei parametri](/manual/api/reference_commentary#parameter-behavior):<br>- *obbligatorio*|
|groups|object/array|[Gruppi di host](/manual/api/reference/hostgroup/object) da aggiungere agli host specificati.<br><br>I gruppi di host devono avere definita solo la proprietà `groupid`.|
|interfaces|object/array|[Interfacce host](/manual/api/reference/hostinterface/object) da creare per gli host specificati.|
|macros|object/array|[Macro utente](/manual/api/reference/usermacro/object) da creare per gli host specificati.|
|templates|object/array|[Template](/manual/api/reference/template/object) da collegare agli host specificati.<br><br>I template devono avere definita solo la proprietà `templateid`.|

[comment]: # ({/10a236c0-c25e2be4})

[comment]: # ({d166b99b-d166b99b})
### Valori di ritorno

`(object)` Restituisce un oggetto contenente gli ID degli host aggiornati
sotto la proprietà `hostids`.

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

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

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

[comment]: # ({b2ef6e4f-453a1298})
#### Aggiunta di macro

Aggiungere due nuove macro a due host.

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

```json
{
    "jsonrpc": "2.0",
    "method": "host.massadd",
    "params": {
        "hosts": [
            {
                "hostid": "10160"
            },
            {
                "hostid": "10167"
            }
        ],
        "macros": [
            {
                "macro": "{$TEST1}",
                "value": "MACROTEST1"
            },
            {
                "macro": "{$TEST2}",
                "value": "MACROTEST2",
                "description": "Descrizione di test"
            }
        ]
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "hostids": [
            "10160",
            "10167"
        ]
    },
    "id": 1
}
```

[comment]: # ({/b2ef6e4f-453a1298})

[comment]: # ({ee23c6c9-ae4115e5})
### Vedi anche

-   [host.update](update)
-   [Gruppo host](/manual/api/reference/hostgroup/object#host-group)
-   [Template](/manual/api/reference/template/object#template)
-   [Macro
    utente](/manual/api/reference/usermacro/object#hosttemplate-level-macro)
-   [Interfaccia
    host](/manual/api/reference/hostinterface/object#host-interface)

[comment]: # ({/ee23c6c9-ae4115e5})

[comment]: # ({d5e419cc-d5e419cc})
### Fonte

CHost::massAdd() in *ui/include/classes/api/services/CHost.php*.

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