# Tag captured data

Tags are short labels you attach to captured items. Use them to mark which items have been reviewed, group items by source or condition, build a dataset for ML training, or narrow the scope of a delete operation.

A few important boundaries:

- **Binary data only.** You can tag images, point clouds, audio, and other binary uploads. Tabular data (sensor readings) does not support post-capture tagging.
- **Different from bounding boxes and labels.** Tags apply to a whole item. Bounding boxes mark regions of an image and are used for object-detection training. See [Annotate images](https://docs.viam.com/train/annotate-images/) for both classification tags and bounding boxes in the ML training context.
- **Different from tabular `tags` capture attributes.** The `tags` field in a [data capture method config](https://docs.viam.com/data/reference/#data-capture-method-attributes) attaches a fixed list of tags at capture time. The operations on this page apply tags after data is captured.

## Apply tags to binary data

- [Viam app](https://docs.viam.com/data/tag-data/#tabset-datatag-data-1-0)
- [CLI](https://docs.viam.com/data/tag-data/#tabset-datatag-data-1-1)
- [Python](https://docs.viam.com/data/tag-data/#tabset-datatag-data-1-2)
- [Go](https://docs.viam.com/data/tag-data/#tabset-datatag-data-1-3)

The in-app tag UI works for images. For other binary types (files, point clouds, audio), tag with the CLI or the SDK.

1. On the **DATA** page, click an image (the **Images** sub-tab is the default view). A side panel slides in from the right with the **ACTIONS** tab selected.
2. In the side panel, scroll to the **Tags** section.
3. Type a tag name and press Enter. Click the **x** next to a tag to remove it.

The Viam app applies tags one image at a time. To tag many items in one operation, or to tag non-image binary data, use the CLI or the SDK.

Tag specific items by their binary data IDs:

```sh
viam data tag ids add --tags=reviewed,approved --binary-data-ids=<id1>,<id2>
```

Remove tags from specific items:

```sh
viam data tag ids remove --tags=reviewed --binary-data-ids=<id1>,<id2>
```

Tag every item that matches a filter (organization, location, MIME type, time range, and more):

```sh
viam data tag filter add --tags=reviewed,approved --org-ids=<org-id> --location-ids=<location-id> --mime-types=image/jpeg
```

#### Note

The filter-based tag commands (`tag filter add` and `tag filter remove`) use deprecated underlying APIs. They still work but may be removed in a future release. Prefer the ID-based commands when possible.

For the full list of flags, see the [`viam data tag` CLI reference](https://docs.viam.com/cli/manage-data/#tag-data).

To find binary data IDs, run `viam data export binary filter` and read the IDs from the JSON metadata file each download produces, or query through the SDK with `BinaryDataByFilter`.

```python
binary_ids = ["binary-data-id-1", "binary-data-id-2"]

await data_client.add_tags_to_binary_data_by_ids(
    tags=["reviewed", "approved"],
    binary_ids=binary_ids,
)
```

The [data client API](https://docs.viam.com/reference/apis/data-client/) also supports adding and removing tags by filter, removing tags by ID, and listing the distinct tags that match a filter.

```go
binaryIDs := []string{"binary-data-id-1", "binary-data-id-2"}

err := dataClient.AddTagsToBinaryDataByIDs(
    ctx,
    []string{"reviewed", "approved"},
    binaryIDs,
)
```

## Use tags downstream

Once data is tagged, you can use those tags to:

- **Filter the DATA page.** Use the tag filter at the top of the page to view only items with a given tag.
- **Build a dataset.** Add tagged items to a dataset for ML training. See [Create a dataset](https://docs.viam.com/train/create-a-dataset/).
- **Scope an export.** Pass `--tags` to [`viam data export binary filter`](https://docs.viam.com/cli/manage-data/#export-data) to download only items with a given tag, or `--tags=tagged` and `--tags=untagged` to scope to all tagged or all untagged items.
