tag¶
Tag operations list, inspect, rename, merge, recolor and delete tags across a library. Tag references (tag or elements of sources) accept either the tag's exact trimmed name (string) or its integer database ID (number). To add or remove tags on specific items, use item.addTags and item.removeTags. To organize tags into groups, see Tag groups.
Every operation in this namespace targets a single library (see Choose a library or window).
| Operation | HTTP Endpoint | Permission | MCP Tool | Summary |
|---|---|---|---|---|
tag.list |
POST /api/v1/tag/list |
metadata.read |
tag_list |
List every tag with its item count, color and groups. |
tag.get |
POST /api/v1/tag/get |
metadata.read |
tag_get |
Fetch one tag by name or ID. |
tag.rename |
POST /api/v1/tag/rename |
organize |
tag_rename |
Rename a tag, merging automatically if the target name exists. |
tag.merge |
POST /api/v1/tag/merge |
organize |
tag_merge |
Merge one or more tags into a single target tag name. |
tag.delete |
POST /api/v1/tag/delete |
organize |
tag_delete |
Delete a tag and remove it from every item. |
tag.setColor |
POST /api/v1/tag/setColor |
organize |
tag_setColor |
Set or clear a tag's own color override. |
tag.list¶
Returns every tag in the library ordered alphabetically (case-insensitive) by name. Each entry includes the count of non-trashed items carrying the tag, the tag's own color (if set), its primary groupId (used for inherited color) and all groupIds it belongs to.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Tag[] — array of all tags in the library.
Example request
Example response
[
{
"id": 12,
"name": "lighting",
"groupId": 2,
"color": null,
"count": 37,
"starred": false,
"groupIds": [2]
},
{
"id": 15,
"name": "sky",
"groupId": 1,
"color": "#3b82f6",
"count": 84,
"starred": true,
"groupIds": [1, 3]
}
]
Events and errors
- Events emitted: None (read-only). Subscribe to
tags.changedto refresh when tags change. - Errors:
unauthorized,not_allowed(missingmetadata.read),unknown_library,library_offline. - Related:
tag.get,tagGroup.list.
tag.get¶
Returns a single tag record by its name or integer ID. Name lookup trims surrounding whitespace and matches exact tag spelling.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
tag |
string \| number |
Yes | — | Tag name or integer tag ID. |
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Tag — matching tag object.
Example request
Example response
{
"id": 15,
"name": "sky",
"groupId": 1,
"color": "#3b82f6",
"count": 84,
"starred": true,
"groupIds": [1, 3]
}
Events and errors
- Events emitted: None (read-only).
- Errors:
not_found(There is no tag <tag>),bad_request(missingtag),not_allowed(missingmetadata.read). - Related:
tag.list,view.show.
tag.rename¶
Renames a tag and refreshes the full-text search index for every item carrying it. If another tag with newName (after trimming) already exists, the two tags are merged: all items carrying tag receive the existing target tag, and the old tag row is deleted. Always pass a non-empty newName.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
tag |
string \| number |
Yes | — | Existing tag name or integer tag ID. |
newName |
string |
Yes | — | Replacement tag name (trimmed before matching or saving). |
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Done — { success: true }.
Example request
Example response
Events and errors
- Events emitted:
tags.changed. - Errors:
not_found(There is no tag <tag>),bad_request(missingtagornewName),not_allowed(missingorganize),failed(database error). - Related:
tag.merge,tag.delete.
tag.merge¶
Merges one or more existing tags (sources) into a single target tag name in one transaction. If target does not yet exist, the first source tag is renamed to target and each remaining source is merged into it; if target already exists, every source is merged into it and deleted. The full-text search index is refreshed for affected items. Every entry in sources must already exist.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
sources |
(string \| number)[] |
Yes | — | Existing tag names or integer IDs to merge into target. |
target |
string |
Yes | — | Destination tag name; created automatically if it does not exist. |
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Done — { success: true }.
Example request
Example response
Events and errors
- Events emitted:
tags.changedandtagGroups.changed. - Errors:
not_found(any entry insourcesdoes not exist),bad_request(missingsourcesortarget),not_allowed(missingorganize),failed(database error). - Related:
tag.rename,tag.list.
tag.delete¶
Permanently deletes a tag from the library, removes it from all items and tag groups and refreshes the full-text search index for items that previously carried it.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
tag |
string \| number |
Yes | — | Tag name or integer tag ID to delete. |
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Done — { success: true }.
Example request
Example response
Events and errors
- Events emitted:
tags.changedandtagGroups.changed. - Errors:
not_found(There is no tag <tag>),bad_request(missingtag),not_allowed(missingorganize),failed(database error). - Related:
item.removeTags,tag.merge.
tag.setColor¶
Sets or clears a tag's own color override. When a tag has no color of its own (null), it inherits the color of its primary tag group (groupId). Passing null, "" or omitting color clears the tag's individual override.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
tag |
string \| number |
Yes | — | Tag name or integer tag ID. |
color |
string |
No | null |
CSS color string (for example "#3b82f6"); omit, pass null or pass "" to clear the override. |
library |
string |
No | Active window's library | Library ID from library.list, folder path or library name. |
Returns
Done — { success: true }.
Example request
Example response
Events and errors
- Events emitted:
tags.changed. - Errors:
not_found(There is no tag <tag>),bad_request(missingtag),not_allowed(missingorganize). - Related:
tag.get,tagGroup.update.