# tagGroup

```javascript
// Get all tag groups
const tagGroups = (await eagle.tagGroup.get());
```

## Methods <a href="#z1a5y" id="z1a5y"></a>

## get() <a href="#x9nu2" id="x9nu2"></a>

Retrieves all tag groups.

* Returns `Promise<tagGroups: Object[]>` - the query result for tagGroups.

```javascript
const tagGroups = (await eagle.tagGroup.get());
```

## create(options) <a href="#x9nu2" id="x9nu2"></a>

Creates a new tag group.

* Returns `Promise<tagGroup: Object>` - the newly created tag group.

```javascript
await eagle.tagGroup.create({
    name: "new group",
    color: "red",
    tags: ["tag1", "tag2"],
    description: "Group description"  // Eagle 4.0 build18+
});
```

***

**Instance Methods**

## save() <a href="#x9nu2" id="x9nu2"></a>

Saves changes to the tag group.

* Returns `Promise<tagGroup: Object>` - the result of the save operation.

```javascript
const tagGroups = (await eagle.tagGroup.get());
const tagGroup = tagGroups[0];

tagGroup.name = "new name";
tagGroup.color = "red"; // red, orange, yellow, green, aqua, blue, purple, pink
tagGroup.tags = ["tag1", "tag2"];
tagGroup.description = "Group description";  // Eagle 4.0 build18+

await tagGroup.save();
```

## remove() <a href="#x9nu2" id="x9nu2"></a>

Removes the tag group.

* Returns `Promise<result: boolean>` - whether the removal was successful.

```javascript
const tagGroups = (await eagle.tagGroup.get());
const tagGroup = tagGroups[0];

await tagGroup.remove();
```

## addTags(options) <a href="#addtags" id="addtags"></a>

Incrementally adds tags to the group without needing to pass the complete tags array.

* `options` Object - Option parameters
  * `tags` string\[] - Array of tag names to add
  * `removeFromSource` boolean (optional) - Whether to remove tags from their original groups, defaults to `false`
    * `false`: Only add tags (tags can exist in multiple groups)
    * `true`: Move tags (remove from original groups)
* Returns `Promise<tagGroup: Object>` - The updated tag group

```javascript
const tagGroups = (await eagle.tagGroup.get());
const tagGroup = tagGroups[0];

// Add tags (allow to exist in multiple groups)
await tagGroup.addTags({
    tags: ['UI', 'UX', 'Typography']
});

// Move tags (remove from original groups)
await tagGroup.addTags({
    tags: ['Branding'],
    removeFromSource: true
});
```

{% hint style="info" %}
Note: The `addTags()` method requires Eagle 4.0 build18 or higher.
{% endhint %}

## removeTags(options) <a href="#removetags" id="removetags"></a>

Removes specified tags from the group.

* `options` Object - Option parameters
  * `tags` string\[] - Array of tag names to remove
* Returns `Promise<tagGroup: Object>` - The updated tag group

```javascript
const tagGroups = (await eagle.tagGroup.get());
const tagGroup = tagGroups[0];

// Remove tags from group
await tagGroup.removeTags({
    tags: ['Outdated', 'Draft']
});
```

{% hint style="info" %}
Note: The `removeTags()` method requires Eagle 4.0 build18 or higher.
{% endhint %}

{% hint style="warning" %}
Warning: This method only removes tags from the group. It does not delete the tags themselves or affect tags on items.
{% 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://developer.eagle.cool/plugin-api/api/tag-group.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.
