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

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

[comment]: # ({887683dd-887683dd})
### Description

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

This method allows to create new templates.

[comment]: # ({/887683dd-887683dd})

[comment]: # ({4eafa2b4-08a9efdc})
### Parameters

`(object/array)` Templates to create.

Additionally to the [standard template properties](object#template), the
method accepts the following parameters.

|Parameter|Type|Description|
|---------|----|-----------|
|**groups**<br>(required)|object/array|Host groups to add the template to.<br><br>The host groups must have the `groupid` property defined.|
|templates|object/array|Templates to be linked to the template.<br><br>The templates must have the `templateid` property defined.|
|macros|object/array|User macros to be created for the template.|
|hosts|object/array|Hosts to link the template to.<br><br>The hosts must have the `hostid` property defined.|

[comment]: # ({/4eafa2b4-08a9efdc})

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

`(object)` Returns an object containing the IDs of the created templates
under the `templateids` property. The order of the returned IDs matches
the order of the passed templates.

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

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

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

[comment]: # ({7406890a-7406890a})
#### Creating a template

Create a template and link it to two hosts.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "template.create",
    "params": {
        "host": "Linux template",
        "groups": {
            "groupid": 1
        },
        "hosts": [
            {
                "hostid": "10084"
            },
            {
                "hostid": "10090"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "templateids": [
            "10086"
        ]
    },
    "id": 1
}
```

[comment]: # ({/7406890a-7406890a})

[comment]: # ({2fe7e3e7-2fe7e3e7})
### Source

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

[comment]: # ({/2fe7e3e7-2fe7e3e7})
