Manage data with the CLI

Export captured data to your local machine, organize it with tags, delete old data, and configure database access for direct queries.

Prerequisites
You need the Viam CLI installed and authenticated. See Viam CLI overview for installation and authentication instructions.

Find your IDs

Many data commands require an organization ID, location ID, or part ID. To look up these values:

viam organizations list
viam locations list
viam machines list --organization=<org-id> --location=<location-id>
viam machines part list --machine=<machine-id>

Export data

Export images and binary files

Export all binary data from an organization:

viam data export binary filter \
  --destination=./my-data \
  --org-ids=<org-id>

The CLI downloads files into the destination directory and prints progress as it goes.

Narrow the export with filters:

viam data export binary filter \
  --destination=./my-data \
  --org-ids=<org-id> \
  --mime-types=image/jpeg,image/png \
  --machine-id=<machine-id> \
  --start=2026-01-01T00:00:00Z \
  --end=2026-02-01T00:00:00Z

Available filters:

FilterFlagExample
By machine--machine-id or --machine-name--machine-id=abc123
By part--part-id or --part-name--part-id=def456
By location--location-ids--location-ids=loc1,loc2
By time range--start, --end--start=2026-01-01T00:00:00Z
By component--component-name, --component-type--component-name=my-camera
By MIME type--mime-types--mime-types=image/jpeg,image/png
By tag--tags--tags=defective,reviewed
By bounding box label--bbox-labels--bbox-labels=screw,bolt

Export specific files by their binary data IDs:

viam data export binary ids \
  --destination=./my-data \
  --binary-data-ids=aaa,bbb,ccc

Export sensor and tabular data

Tabular exports require a part ID and resource identifier:

viam data export tabular \
  --destination=./sensor-data \
  --part-id=<part-id> \
  --resource-name=my-sensor \
  --resource-subtype=rdk:component:sensor \
  --method=Readings

Output is written to a data.ndjson file (one JSON object per line). You can also filter by time range with --start and --end.

Tag data

Tags help you organize data for filtering, dataset creation, and search.

Add tags by ID

Add tags to specific files by their binary data IDs:

viam data tag ids add \
  --tags=reviewed,approved \
  --binary-data-ids=aaa,bbb

Remove tags from specific files:

viam data tag ids remove \
  --tags=reviewed \
  --binary-data-ids=aaa,bbb

Add tags by filter

Add tags to all data matching a filter:

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

Remove tags by filter:

viam data tag filter remove \
  --tags=reviewed \
  --org-ids=<org-id>

Delete data

Delete binary data

Delete binary data matching a filter. Both --start and --end are required:

viam data delete binary \
  --org-ids=<org-id> \
  --mime-types=image/jpeg \
  --start=2026-01-01T00:00:00Z \
  --end=2026-02-01T00:00:00Z

Delete tabular data

Delete tabular data older than a specified number of days. Pass 0 to delete all tabular data for your organization.

viam data delete tabular --delete-older-than-days=90

Configure database access

To query synced data directly with MongoDB-compatible tools like mongosh or Grafana, set up a database user:

viam data database configure --org-id=<org-id> --password=<password>

Get the connection hostname:

viam data database hostname --org-id=<org-id>

Use the returned hostname with your MongoDB client. See Visualize data for Grafana setup instructions.

Manage data indexes

Create custom indexes to speed up queries on large datasets. The --collection-type flag specifies the target: hot-storage for hot data store collections, or pipeline-sink for data pipeline output collections (requires --pipeline-name).

The --index-path flag takes a JSON file defining the index using MongoDB index specification format:

{
  "key": { "meta.captured_at": 1, "tags": 1 },
  "name": "captured-at-tags"
}
viam data index create \
  --collection-type=hot-storage \
  --index-path=./my-index.json

List existing indexes:

viam data index list --collection-type=hot-storage

Delete an index:

viam data index delete --collection-type=hot-storage --index-name=my-index

Related pages