# TaskTemplates

## Introduction

`TaskTemplates` store what a task is and how progress is reported.

Templates can have related [TaskFields](/api-reference/tasks-2/task-fields.md) that define which values are captured into [TaskProgressFields](/api-reference/tasks-2/task-progress-fields.md).

[TaskAssignments](/api-reference/tasks-2/task-assignments.md) use template data to create concrete [TaskExecutions](/api-reference/tasks-2/task-executions.md).

## Model Definition

**Alias**

`taskTemplate`

**Relations**

| Relation                                                      | Key               | Type             | Relation Field(s)                                  |
| ------------------------------------------------------------- | ----------------- | ---------------- | -------------------------------------------------- |
| [TaskTemplate](/api-reference/tasks-2/task-templates.md)      | `parent`          | Belongs to       | `parent_id`                                        |
| [TaskTemplates](/api-reference/tasks-2/task-templates.md)     | `children`        | Has many         | `parent_id`                                        |
| [TaskAssignments](/api-reference/tasks-2/task-assignments.md) | `taskAssignments` | Has many         | `parent_id`                                        |
| [TaskExecutions](/api-reference/tasks-2/task-executions.md)   | `tasks`           | Has many through | `tasks.task_assignment_id`                         |
| [TaskFields](/api-reference/tasks-2/task-fields.md)           | `formFields`      | Has many         | `form_fields.form_id`, `form_fields.form_type`     |
| [User](/api-reference/users.md)                               | `user`            | Belongs to       | `user_id`                                          |
| [Layouts](/api-reference/layouts/layouts.md)                  | `layouts`         | Has many         | `layouts.layoutable_type`, `layouts.layoutable_id` |

## \[Adm.] List

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/tasks-2/templates`

**Request Keys**

No additional request keys.

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/administration/tasks-2/templates', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

**Example Response**

```json
[
  {
    "id": 6,
    "title": "Safety Checklist",
    "description": "<p>Describe your template</p>",
    "parent_id": null,
    "sort_number": 39,
    "user_id": 144,
    "grade_scale": null,
    "tour_enabled": true,
    "quick_assignable": false
  }
]
```

## List quick assignable templates

**Definition**

<mark style="color:green;">`GET`</mark> `/api/tasks-2/templates/quick-assignable`

**Request Keys**

No additional request keys.

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/tasks-2/templates/quick-assignable', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

**Example Response**

```json
[
  {
    "id": 6,
    "title": "Safety Checklist",
    "quick_assignable": true
  }
]
```

## \[Adm.] Show

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/tasks-2/templates/{taskTemplate}`

**Request Keys**

| Key            | Type    | Default | Description      |
| -------------- | ------- | ------- | ---------------- |
| `taskTemplate` | integer | -       | TaskTemplate ID. |

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('GET', '/api/administration/tasks-2/templates/6', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

**Example Response**

```json
{
  "id": 6,
  "title": "Safety Checklist",
  "description": "<p>Describe your template</p>",
  "parent_id": null,
  "sort_number": 39,
  "user_id": 144,
  "grade_scale": null,
  "tour_enabled": true,
  "quick_assignable": false
}
```

## \[Adm.] Create

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tasks-2/templates`

**Request Keys**

| Key                | Type    | Default         | Description                                          |
| ------------------ | ------- | --------------- | ---------------------------------------------------- |
| `title`\*          | string  | -               | Template title.                                      |
| `description`      | string  | `null`          | Template description.                                |
| `parent_id`        | integer | `null`          | Parent template ID.                                  |
| `lang_id`          | string  | system language | Language key.                                        |
| `sort_number`      | integer | auto            | Sort number.                                         |
| `grade_scale`      | integer | `null`          | Grade scale.                                         |
| `tour_enabled`     | boolean | `false`         | Enables user tour for executions from this template. |
| `quick_assignable` | boolean | `false`         | Enables quick-assignment usage.                      |

Keys with `*` are required.

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tasks-2/templates', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'title' => 'Safety Checklist',
        'description' => '<p>Describe your template</p>',
        'quick_assignable' => true
    ]
]);
```

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 6,
    "title": "Safety Checklist",
    "description": "<p>Describe your template</p>",
    "parent_id": null,
    "sort_number": 39,
    "quick_assignable": true,
    "tour_enabled": false
  }
}
```

## \[Adm.] Update

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/administration/tasks-2/templates/{taskTemplate}`

**Request Keys**

| Key                | Type    | Default | Description                  |
| ------------------ | ------- | ------- | ---------------------------- |
| `taskTemplate`     | integer | -       | Route parameter. Template ID |
| `title`            | string  | -       | Template title.              |
| `description`      | string  | -       | Template description.        |
| `parent_id`        | integer | -       | Parent template ID.          |
| `lang_id`          | string  | -       | Language key.                |
| `sort_number`      | integer | -       | Sort number.                 |
| `grade_scale`      | integer | -       | Grade scale.                 |
| `tour_enabled`     | boolean | -       | Tour-enabled flag.           |
| `quick_assignable` | boolean | -       | Quick-assignable flag.       |

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/administration/tasks-2/templates/6', [
    'headers' => ['Authorization' => "Bearer {accessToken}"],
    'json' => [
        'title' => 'Safety Checklist (updated)'
    ]
]);
```

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 6,
    "title": "Safety Checklist (updated)",
    "quick_assignable": true
  }
}
```

## \[Adm.] Delete

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/administration/tasks-2/templates/{taskTemplate}`

**Request Keys**

| Key            | Type    | Default | Description      |
| -------------- | ------- | ------- | ---------------- |
| `taskTemplate` | integer | -       | TaskTemplate ID. |

**Example Request**

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('DELETE', '/api/administration/tasks-2/templates/6', [
    'headers' => ['Authorization' => "Bearer {accessToken}"]
]);
```

**Example Response**

```json
{
  "status": "success",
  "data": null
}
```


---

# 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.api.intratool.de/api-reference/tasks-2/task-templates.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.
