# Template

This endpoint is used to create, update, search or delete teamplates inside an organization.

### Entity fields:

| Path                       | Type   | Description                                   |
| -------------------------- | ------ | --------------------------------------------- |
| data.type                  | string | Should be "template"                          |
| data.attributes.tcl        | string | Terraform Configuration Language job template |
| data.attribute.name        | string | Template name                                 |
| data.attribute.description | string | Template description                          |
| data.attribute.version     | string | Template version                              |

{% hint style="info" %}
To better understand Terrakube Configuration Language job templates please refer to the following [GitHub repository.](https://github.com/AzBuilder/terrakube-extensions)
{% endhint %}

### Example:

```
{
  "data": {
    "type": "template",
    "attributes": {
      "name": "Some name",
      "description": "Some description",
      "version": "1.0.0",
      "tcl": "{{templateSample}}"
    }
  }
}
```

### Supported Operations

## POST /organization/{organizationId}/template

> Creates an item of type template and adds it to template

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"template"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/template":{"post":{"tags":["template"],"description":"Creates an item of type template and adds it to template","requestBody":{"content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/template"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}},"responses":{"201":{"description":"Successful response","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/template"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}}}}}},"components":{"schemas":{"template":{"type":"object","properties":{"type":{"type":"string","description":"Create Permissions : (team manage template)\nDelete Permissions : (team manage template)"},"id":{"type":"string"},"attributes":{"type":"object","properties":{"createdBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"createdDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"description":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"name":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"tcl":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"version":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"organization":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["organization"]},"id":{"type":"string"}},"description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}}}}}}}}}}
```

## GET /organization/{organizationId}/template/{templateId}

> Returns an instance of type template

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"template"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/template/{templateId}":{"get":{"tags":["template"],"description":"Returns an instance of type template","parameters":[{"name":"fields[template]","in":"query","description":"Selects the set of template fields that should be returned in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["createdBy","createdDate","description","name","tcl","updatedBy","updatedDate","version","organization"]}}},{"name":"include","in":"query","description":"Selects the set of relationships that should be expanded as a compound document in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["organization"]}}}],"responses":{"200":{"description":"Successful response","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/template"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}}}}}},"components":{"schemas":{"template":{"type":"object","properties":{"type":{"type":"string","description":"Create Permissions : (team manage template)\nDelete Permissions : (team manage template)"},"id":{"type":"string"},"attributes":{"type":"object","properties":{"createdBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"createdDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"description":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"name":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"tcl":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"version":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"organization":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["organization"]},"id":{"type":"string"}},"description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}}}}}}}}}}
```

## DELETE /organization/{organizationId}/template/{templateId}

> Deletes an instance of type template

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"template"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/template/{templateId}":{"delete":{"tags":["template"],"description":"Deletes an instance of type template","responses":{"204":{"description":"Successful response"}}}}}}
```

## PATCH /organization/{organizationId}/template/{templateId}

> Modifies an instance of type template

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"template"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/template/{templateId}":{"patch":{"tags":["template"],"description":"Modifies an instance of type template","requestBody":{"content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"$ref":"#/components/schemas/template"},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}},"responses":{"204":{"description":"Successful response"}}}}},"components":{"schemas":{"template":{"type":"object","properties":{"type":{"type":"string","description":"Create Permissions : (team manage template)\nDelete Permissions : (team manage template)"},"id":{"type":"string"},"attributes":{"type":"object","properties":{"createdBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"createdDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"description":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"name":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"tcl":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"version":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"organization":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["organization"]},"id":{"type":"string"}},"description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}}}}}}}}}}
```

## GET /organization/{organizationId}/template

> Returns the relationship template

```json
{"openapi":"3.0.1","info":{"title":"Elide Service","version":"0.0.1"},"tags":[{"name":"template"}],"servers":[{"url":"/api/v1"}],"paths":{"/organization/{organizationId}/template":{"get":{"tags":["template"],"description":"Returns the relationship template","parameters":[{"name":"sort","in":"query","description":"Sorts the collection on the selected attributes.  A prefix of '-' sorts descending","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["createdBy","-createdBy","description","-description","name","-name","tcl","-tcl","updatedBy","-updatedBy","version","-version","id","-id"]}}},{"name":"fields[template]","in":"query","description":"Selects the set of template fields that should be returned in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["createdBy","createdDate","description","name","tcl","updatedBy","updatedDate","version","organization"]}}},{"name":"include","in":"query","description":"Selects the set of relationships that should be expanded as a compound document in the result.","style":"form","explode":false,"schema":{"type":"array","items":{"type":"string","enum":["organization"]}}},{"name":"filter[template]","in":"query","description":"Filters the collection of template using a 'disjoint' RSQL expression","schema":{"type":"string"}},{"name":"page[number]","in":"query","description":"Number of pages to return.  Can be used with page[size]","schema":{"type":"integer","format":"int32"}},{"name":"page[size]","in":"query","description":"Number of elements per page.  Can be used with page[number]","schema":{"type":"integer","format":"int32"}},{"name":"page[offset]","in":"query","description":"Offset from 0 to start paginating.  Can be used with page[limit]","schema":{"type":"integer","format":"int32"}},{"name":"page[limit]","in":"query","description":"Maximum number of items to return.  Can be used with page[offset]","schema":{"type":"integer","format":"int32"}},{"name":"page[totals]","in":"query","description":"For requesting total pages/records be included in the response page meta data","schema":{"type":"string"}}],"responses":{"200":{"description":"Successful response","content":{"application/vnd.api+json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/template"}},"included":{"uniqueItems":true,"type":"array","description":"Included resources","items":{"type":"object","properties":{"type":{"type":"string"},"id":{"type":"string"},"attributes":{"type":"object"},"relationships":{"type":"object"}}}}}}}}}}}}},"components":{"schemas":{"template":{"type":"object","properties":{"type":{"type":"string","description":"Create Permissions : (team manage template)\nDelete Permissions : (team manage template)"},"id":{"type":"string"},"attributes":{"type":"object","properties":{"createdBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"createdDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"description":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"name":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"tcl":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedBy":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"updatedDate":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false},"version":{"type":"string","description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}},"relationships":{"type":"object","properties":{"organization":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"type":{"type":"string","enum":["organization"]},"id":{"type":"string"}},"description":"Read Permissions : (team view template)\nUpdate Permissions : (team manage template)","readOnly":false,"writeOnly":false}}}}}}}}}}}
```

{% hint style="info" %}
For a complete list of organization operation please visit the [OpenAPI specification](https://github.com/AzBuilder/terrakube-server/blob/main/openapi-spec/v1_6.yml)
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.terrakube.io/api/methods/template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
