[comment]: # translation:outdated

[comment]: # ({7f5b147d-7f5b147d})
# template.create

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

[comment]: # ({82525ddb-d9142f8c})
### Descrizione

`object template.create(object/array templates)`

Questo metodo consente di creare nuovi template.

::: 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]: # ({/82525ddb-d9142f8c})

[comment]: # ({0309410d-95e9c6ad})
### Parametri

`(object/array)` Template da creare.

Oltre alle [proprietà standard del template](object#template), il
metodo accetta i seguenti parametri.

|Parametro|[Tipo](/manual/api/reference_commentary#data-types)|Descrizione|
|--|--|------|
|groups|object/array|[Gruppi di template](/manual/api/reference/templategroup/object) a cui aggiungere il template.<br><br>I gruppi di template devono avere definita solo la proprietà `groupid`.<br><br>[Comportamento del parametro](/manual/api/reference_commentary#parameter-behavior):<br>- *obbligatorio*|
|tags|object/array|[Tag del template](/manual/api/reference/template/object#template-tag).|
|templates|object/array|[Template](/manual/api/reference/template/object) da collegare al template.<br><br>I template devono avere definita solo la proprietà `templateid`.|
|macros|object/array|[Macro utente](/manual/api/reference/usermacro/object) da creare per il template.|

[comment]: # ({/0309410d-95e9c6ad})

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

`(object)` Restituisce un oggetto contenente gli ID dei modelli creati
sotto la proprietà `templateids`. L'ordine degli ID restituiti corrisponde all'ordine dei modelli passati.

[comment]: # ({/68ed5aa8-68ed5aa8})

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

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

[comment]: # ({47ddcd78-104d61d1})
#### Creazione di un template

Creare un template con tag e collegare due template a questo template.

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

```json
{
    "jsonrpc": "2.0",
    "method": "template.create",
    "params": {
        "host": "Linux template",
        "groups": {
            "groupid": 1
        },
        "templates": [
            {
                "templateid": "11115"
            },
            {
                "templateid": "11116"
            }
        ],
        "tags": [
            {
                "tag": "host-name",
                "value": "{HOST.NAME}"
            }
        ]
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "templateids": [
            "11117"
        ]
    },
    "id": 1
}
```

[comment]: # ({/47ddcd78-104d61d1})

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

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

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