> For the complete documentation index, see [llms.txt](https://docs.api.intratool.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.api.intratool.de/api-reference/tags/tag-groups.md).

# TagGroups

## Introduction

`TagGroups` are used to organize and group [Tags](/api-reference/tags/tags.md) within the system. They allow for hierarchical structuring of [Tags](/api-reference/tags/tags.md), assignment of [Tags](/api-reference/tags/tags.md) to groups, and restriction of [Tag](/api-reference/tags/tags.md) usage in specific [TaggableSections](/api-reference/tags/taggable-sections.md).

A `TagGroup` can have a parent group, child groups, and can be assigned to one or more [TaggableSections](/api-reference/tags/taggable-sections.md).

## Model Definition

### Alias

`tagGroup`

### Relations

| Key                          | Relation                                                    | Type            | Relation Field(s)                                                                                |
| ---------------------------- | ----------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------ |
| `user`                       | [User](/api-reference/users.md)                             | Belongs to      | `user_id`                                                                                        |
| `parent`                     | [TagGroup](/api-reference/tags/tag-groups.md)               | Belongs to      | `parent_id`                                                                                      |
| `children`                   | [TagGroup](/api-reference/tags/tag-groups.md)               | Has many        | `tag_groups.parent_id`                                                                           |
| `tags`                       | [Tag](/api-reference/tags/tags.md)                          | Belongs to many | `tag_tag_group.tag_group_id`                                                                     |
| `taggableSections`           | [TaggableSection](/api-reference/tags/taggable-sections.md) | Has many        | `taggable_sections.default_tag_group_id`                                                         |
| `restrictedTaggableSections` | [TaggableSection](/api-reference/tags/taggable-sections.md) | Morph to many   | `taggable_section_restrictbale.restrictable_type, taggable_section_restrictbale.restrictable_id` |

## List by section

Get a list of all `TagGroups` by [TaggableSection](/api-reference/tags/taggable-sections.md).

**Definition**

<mark style="color:green;">`GET`</mark> `/api/tags/groups/allowed/{taggableSection}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 2,
    "title": "General",
    "parent_id": null,
    "sort_number": 1,
    "created_at": "2019-06-15 12:00:00",
    "updated_at": "2019-06-15 12:00:00",
    "deleted_at": null
  },
  {
    "id": 2,
    "user_id": 2,
    "title": "Important",
    "parent_id": 1,
    "sort_number": 2,
    "created_at": "2019-06-15 13:00:00",
    "updated_at": "2019-06-15 13:00:00",
    "deleted_at": null
  }
]
```

## \[Adm.] List

Get a list of all `TagGroups`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/tags/groups`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
[
  {
    "id": 1,
    "user_id": 2,
    "title": "General",
    "parent_id": null,
    "sort_number": 1,
    "created_at": "2019-06-15 12:00:00",
    "updated_at": "2019-06-15 12:00:00",
    "deleted_at": null
  },
  {
    "id": 2,
    "user_id": 2,
    "title": "Important",
    "parent_id": null,
    "sort_number": 2,
    "created_at": "2019-06-15 13:00:00",
    "updated_at": "2019-06-15 13:00:00",
    "deleted_at": null
  }
]
```

## \[Adm.] Show

Show a single `TagGroup` by `id`.

**Definition**

<mark style="color:green;">`GET`</mark> `/api/administration/tags/groups/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

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

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "id": 1,
  "user_id": 2,
  "title": "General",
  "parent_id": null,
  "sort_number": 1,
  "created_at": "2019-06-15 12:00:00",
  "updated_at": "2019-06-15 12:00:00",
  "deleted_at": null
}
```

## Create

Create a new `TagGroup`.

**Definition**

<mark style="color:yellow;">`POST`</mark> `/api/administration/tags/groups`

**Request Keys**

| Key           | Type    | Default            | Description                                                              |
| ------------- | ------- | ------------------ | ------------------------------------------------------------------------ |
| `title` \*    | string  | -                  | The name of the `TagGroup`.                                              |
| `parent_id`   | int     | -                  | The ID of the parent `TagGroup`.                                         |
| `sort_number` | integer | Current highest +1 | The index of the `TagGroup` related to the parent `TagGroup`.            |
| `tag_ids`     | array   | -                  | Array of [Tag](/api-reference/tags/tags.md) IDs to assign to this group. |

Keys with `*` are required.

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('POST', '/api/administration/tags/groups', [
    'headers' => ['Authorization' => 'Bearer {accessToken}'],
    'json' => [
        'title' => 'Common',
        'tag_ids' => [5, 6]
    ],
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 2,
    "title": "Common",
    "parent_id": null,
    "sort_number": 3,
    "created_at": "2019-06-15 14:00:00",
    "updated_at": "2019-06-15 14:00:00",
    "deleted_at": null
  }
}
```

## Update

Update an existing `TagGroup` by `id`.

**Definition**

<mark style="color:blue;">`PUT`</mark> `/api/administration/tags/groups/{id}`

**Request Keys**

| Key           | Type   | Description                                                              |
| ------------- | ------ | ------------------------------------------------------------------------ |
| `title`       | string | The name of the `TagGroup`.                                              |
| `parent_id`   | int    | The ID of the parent `TagGroup`.                                         |
| `sort_number` | int    | The index of the `TagGroup` related to the parent `TagGroup`.            |
| `tag_ids`     | array  | Array of [Tag](/api-reference/tags/tags.md) IDs to assign to this group. |

**Example Request**

{% tabs %}
{% tab title="PHP" %}

```php
$client = new GuzzleHttp\Client(['base_uri' => 'https://{tenant}.intratool.de']);
$response = $client->request('PUT', '/api/administration/tags/groups/3', [
    'headers' => ['Authorization' => 'Bearer {accessToken}'],
    'json' => [
        'tag_ids' => [5, 6, 7]
    ],
]);
```

{% endtab %}
{% endtabs %}

**Example Response**

```json
{
  "status": "success",
  "data": {
    "id": 3,
    "user_id": 2,
    "title": "Common",
    "parent_id": null,
    "sort_number": 3,
    "created_at": "2019-06-15 14:00:00",
    "updated_at": "2019-06-15 14:30:00",
    "deleted_at": null
  }
}
```

## Delete

Delete an existing `TagGroup` by `id`.

**Definition**

<mark style="color:red;">`DELETE`</mark> `/api/administration/tags/groups/{id}`

**Example Request**

{% tabs %}
{% tab title="PHP" %}

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

{% endtab %}
{% endtabs %}

**Example Response**

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.api.intratool.de/api-reference/tags/tag-groups.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
