> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nomadicml.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Export a Studio selection

> Include and exclude search matches, preview counts, and export MCAP sessions

Build an event-level selection from [Deep Search](/sdk/studio-search), then remove
unwanted matches. Excluding one event leaves other events from the same video
selected.

```python theme={null}
import os
from nomadic import NomadicAI

client = NomadicAI(api_key=os.environ["NOMADIC_API_KEY"])
studio = client.studio.get("STUDIO_ID")
matches = client.studio.search(studio.id, "robot picks up an object", top_k=50)

selection = client.studio.select(studio.id).include(matches)
selection = selection.exclude(matches.first(2))
selection = selection.exclude(video_ids=[matches.first(1)[0].video_id])
print(selection.count())  # {'events': ..., 'videos': ...}

job = selection.export()
job.wait()  # Prints status as MCAP sessions are built.
job.download("./studio-export")
```

`include(matches)` selects **only the events returned** by that search; it
does not silently select beyond `top_k`. Each call returns a new selection,
so `matches` and the earlier `selection` remain available. You can also pass
individual events, such as `selection.include(matches.first(1))`. Calling
`include` again reselects an event you previously excluded. Use
`exclude(video_ids=[...])` to remove every currently selected event from a
source video; it does not affect events from other videos.

For an exact taxonomy condition, the SDK fetches every filter page before
exporting:

```python theme={null}
selection = client.studio.select(studio.id)
selection = selection.include(filters={"robot_action": "grasp"})
selection = selection.exclude(filters={"gripper_closed": False})
```

To resolve a text query on the server instead of selecting a displayed result
list, use `include(query="robot picks up an object")` or `exclude(query=...)`.
This uses Deep Search. If the reranker caps its results, the SDK raises an
error instead of claiming it selected every match; refine the query or select
the returned results explicitly.

`selection.count()` previews the selected events and distinct source videos.
Snapshot, caption, and legacy inline results cannot be exported as MCAP events;
the SDK rejects them when you try to include them. Choose externalized events
from your results instead.
The export API checks that the videos and event IDs are still available and
that you can access them. The resulting manifest references MCAP sessions,
source videos, and event indexes; it may report skipped items if the source
changed after you built the selection. Dataset export requires an eligible plan
and an API key with `write` or `datasets:write` scope.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.