# 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 %}
