# HostTemplatesResource Resource

### GET /clusters/{clusterName}/hostTemplates

Lists all host templates in a cluster.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplateList (JSON) | List of host templates in the cluster.

### POST /clusters/{clusterName}/hostTemplates

Creates new host templates.

Host template names must be unique across clusters.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a

Request Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplateList (JSON) | The list of host templates to create.

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplateList (JSON) | The created host templates.

### DELETE /clusters/{clusterName}/hostTemplates/{hostTemplateName}

Deletes a host template.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a
hostTemplateName | path | Host template to delete. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplate (JSON) | Deleted host template.

### GET /clusters/{clusterName}/hostTemplates/{hostTemplateName}

Retrieves information about a host template.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a
hostTemplateName | path |  | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplate (JSON) | The requested host template.

### PUT /clusters/{clusterName}/hostTemplates/{hostTemplateName}

Updates an existing host template.

Can be used to update the role config groups in a host template or rename it.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a
hostTemplateName | path | Host template with updated fields. | n/a

Request Body
media type | data type
--- | ---
application/json | ApiHostTemplate (JSON)

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiHostTemplate (JSON) | The updated host template.

### POST /clusters/{clusterName}/hostTemplates/{hostTemplateName}/commands/applyHostTemplate

Applies a host template to a collection of hosts. This will create a role for each role config group on each of the hosts.

The provided hosts must not have any existing roles on them and if the cluster is not using parcels, the hosts must have a CDH version matching that of the cluster version.

Available since API v3.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a
hostTemplateName | path | Host template to apply. | n/a
runConfigRules | query | Whether to run the rules engine to automatically configure roles present on the hosts | false
startRoles | query | Whether to start the newly created roles or not. | n/a

Request Body
media type | data type | description
--- | --- | ---
application/json | ApiHostRefList (JSON) | List of hosts to apply the host template to.

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Synchronous command result.

### POST /clusters/{clusterName}/hostTemplates/{hostTemplateName}/commands/reapplyHostTemplateOnHosts

Reapplies a host template on all the hosts associated with the host template. This will run apply host template command on the all the hosts using the host template .

Set deleteRoles to true to delete the roles on the associated hosts if RCG is missing from host template. Check host tags with name as _cldr_cm_host_template_name to find out hosts using with the host template.

Available since API v46.

Request Parameters
name | type | description | default
--- | --- | --- | ---
clusterName | path |  | n/a
hostTemplateName | path | Host template to apply. | n/a
deleteRoles | query | Whether to delete roles on host if RCG is deleted from host template . | n/a
startRoles | query | Whether to start the newly created roles or not. | n/a

Response Body
media type | data type | description
--- | --- | ---
application/json | ApiCommand (JSON) | Synchronous command result.