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

# Ingest video from S3

> Point a continuous sync at an S3 prefix and every new video becomes searchable segments without another API call.

Point a continuous sync at an S3 prefix and every new video becomes searchable segments without another API call. Sample videos are seeded so the first query works before you connect S3.

> [card] [Jump to the manifest](#the-manifest)
>
> `ingest-video-from-s3.namespace.yaml`: apply it with one API call, then read the walkthrough below to change it.

## At a glance

| | |
| - | - |
| **Creates** | 1 namespace, 1 bucket, 1 collection, 1 retriever |
| **Extractors** | [`multimodal_extractor`](https://docs.mixpeek.com/docs/extract/extractors#multimodal) v1 |
| **Daily spend budget** | 1 USD, set on the namespace. Queries are not capped. |
| **Sample data** | 3 objects, uploaded to `s3-videos` when you apply |

## How the pieces connect

Buckets hold what you upload, collections turn it into searchable documents, and retrievers answer queries over the collections.

```mermaid theme={null}
flowchart LR
  b0[("s3-videos")]
  c1["video-segments<br/>multimodal_extractor v1"]
  r2{{"s3-video-search"}}
  b0 --> c1
  c1 --> r2
```

## Deploy it

**1. Get the manifest**

```bash theme={null}
# Copy the manifest from the bottom of this page into ingest-video-from-s3.namespace.yaml
```

**2. Validate it**

Validate runs every check apply runs and creates nothing. Fix each entry in `errors`, then run it again.

```bash theme={null}
curl -X POST https://api.mixpeek.com/v1/manifest/validate \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -F "manifest_file=@ingest-video-from-s3.namespace.yaml"
```

**3. Apply it**

Apply creates every resource in one call. `wait_for_seed=true` also waits until the sample objects are processed, so the first query below has documents to return.

```bash theme={null}
curl -X POST "https://api.mixpeek.com/v1/manifest/apply?wait_for_seed=true" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -F "manifest_file=@ingest-video-from-s3.namespace.yaml"
```

The response lists each resource with its outcome in `resources`. Apply refuses a resource that already exists and rolls the whole apply back, so to apply the file again over this namespace add `?mode=create_missing`, which creates only what is missing.

## Run the first query

Look up the namespace id by name, then run `s3-video-search`. Check `status` and `warnings` along with `documents`: a run that times out still answers 200, with `status` `degraded`.

```bash cURL theme={null}
NAMESPACE_ID=$(curl -s https://api.mixpeek.com/v1/namespaces/ingest-video-from-s3 \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" | jq -r .namespace_id)

curl -X POST https://api.mixpeek.com/v1/retrievers/s3-video-search/execute \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"query": "washing clothes with laundry detergent"}}' \
  | jq '{status, warnings, documents: [.documents[] | {document_id, score}]}'
```

```python Python theme={null}
import os, requests

AUTH = {"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}"}
ns = requests.get("https://api.mixpeek.com/v1/namespaces/ingest-video-from-s3", headers=AUTH).json()

run = requests.post(
    "https://api.mixpeek.com/v1/retrievers/s3-video-search/execute",
    headers={**AUTH, "X-Namespace": ns["namespace_id"]},
    json={"inputs": {"query": "washing clothes with laundry detergent"}},
).json()

print(run["status"], run["warnings"])  # "completed" on a clean run
for doc in run["documents"]:
    print(doc["document_id"], doc["score"])
```

```javascript JavaScript theme={null}
const auth = { Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}` };
const ns = await fetch("https://api.mixpeek.com/v1/namespaces/ingest-video-from-s3", { headers: auth }).then((r) => r.json());

const run = await fetch("https://api.mixpeek.com/v1/retrievers/s3-video-search/execute", {
  method: "POST",
  headers: { ...auth, "X-Namespace": ns.namespace_id, "Content-Type": "application/json" },
  body: JSON.stringify({"inputs": {"query": "washing clothes with laundry detergent"}}),
}).then((r) => r.json());

console.log(run.status, run.warnings); // "completed" on a clean run
for (const doc of run.documents) console.log(doc.document_id, doc.score);
```

## Add your own data

Each object you add to a bucket is processed by every collection that reads it. This adds one object to `s3-videos`. `NAMESPACE_ID` is the id from the namespace lookup above.

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/s3-videos/objects?auto_process=true" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"category": "example", "blobs": [{"property": "video", "type": "video", "data": "https://example.com/clip.mp4"}]}'
```

```python Python theme={null}
import os, requests

HEADERS = {"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}", "X-Namespace": os.environ["NAMESPACE_ID"]}

obj = requests.post(
    "https://api.mixpeek.com/v1/buckets/s3-videos/objects",
    params={"auto_process": "true"},
    headers=HEADERS,
    json={
        "category": "example",
        "blobs": [
            {
                "property": "video",
                "type": "video",
                "data": "https://example.com/clip.mp4"
            }
        ]
    },
).json()
print(obj["object_id"], obj["status"])  # PENDING until processing finishes
```

```javascript JavaScript theme={null}
const headers = {
  Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
  "X-Namespace": process.env.NAMESPACE_ID,
  "Content-Type": "application/json",
};

const obj = await fetch("https://api.mixpeek.com/v1/buckets/s3-videos/objects?auto_process=true", {
  method: "POST",
  headers,
  body: JSON.stringify({
    "category": "example",
    "blobs": [
      {
        "property": "video",
        "type": "video",
        "data": "https://example.com/clip.mp4"
      }
    ]
  }),
}).then((r) => r.json());
console.log(obj.object_id, obj.status); // PENDING until processing finishes
```

The object is `PENDING` until processing finishes, then `COMPLETED` or `FAILED`. [Buckets and objects](https://docs.mixpeek.com/docs/ingest/buckets.md) covers object states, retries and duplicates.

## Retrievers

### `s3-video-search`

Type what a moment shows or what someone says in it, and get the matching segments from every video the sync has ingested.

**Stages:** [`feature_search`](https://docs.mixpeek.com/docs/retrieve/stages#feature-search)

**Searches:** `video-segments`

| Input | Type | Required | Description |
| - | - | - | - |
| `query` | text | yes | What the moment shows or what is said in it, in plain words |

## Collections

Each collection runs one extractor over a bucket, or over another collection's documents.

> [accordion] video-segments
>
> multimodal\_extractor\@v1 over bucket s3-videos: one document per 10-second segment, with a visual embedding and a transcript embedding. Feeds s3-video-search.
>
> **Reads** bucket `s3-videos` with [`multimodal_extractor`](https://docs.mixpeek.com/docs/extract/extractors#multimodal) v1.
>
> **Inputs:** `video` ← `video`
>
> **Copied onto each document:** `category`

## The manifest

Every resource above comes from this file. Change it and apply it again with `?mode=upsert` to update what exists. [Manifests](https://docs.mixpeek.com/docs/manage/manifests.md) documents each field.

```yaml ingest-video-from-s3.namespace.yaml expandable theme={null}
# ingest-video-from-s3: a namespace whose video bucket is fed by a continuous sync from an
# S3 prefix, processed into searchable 10-second segments as each file lands.
# Platform manifest schema (GET /v1/discovery/schema). Validate with POST /v1/manifest/validate,
# apply with POST /v1/manifest/apply?wait_for_seed=true.
# As published, the S3 connection and the sync below are commented out, because apply
# live-tests a connection and needs real credentials. The seed objects fill the bucket
# from Mixpeek's sample set instead, so the first query works before S3 is connected.
# Applying a SECOND time, over a namespace this file already created: use
# POST /v1/manifest/apply?mode=create_missing to create only what is missing, or
# mode=upsert to also patch resources that have drifted from this file. The default,
# create_only, fails the whole apply and rolls it back if any resource already exists.
version: '1.0'
metadata:
  name: ingest-video-from-s3
  description: "An S3 prefix synced continuously into a video bucket, processed into segments searchable by what they show or say."
namespaces:
  - name: ingest-video-from-s3
    description: "Everything below lives in this namespace."
    feature_extractors:
      - name: multimodal_extractor
        version: v1
    # Daily spend budget, in dollars of what you are charged (1,000 credits a dollar).
    # New batches pause once the namespace has spent this much today; queries are not capped.
    # A continuous sync submits a batch for every new file, so raise this to cover a
    # day of new video at 0.20 USD a minute:
    # PATCH /v1/namespaces/<id> {"spend_budget": {"daily_usd": N}}.
    budget:
      daily_usd: 1

buckets:
  - name: s3-videos
    namespace: ingest-video-from-s3
    description: "Meant to be fed by the s3-videos-sync below (s3, continuous). Until the sync is connected it holds the seed objects, and accepts direct uploads."
    schema:
      properties:
        video:
          type: video
        category:
          type: string

# Connect your own S3 bucket. Create the two secrets named below in your organization,
# uncomment both blocks, set region and source_path, and apply again with ?mode=create_missing.
# Apply live-tests the connection, so it fails until the credentials are real.
# storage_connections:
#   - name: s3-videos-connection
#     provider: s3
#     description: "Read-only access to the S3 bucket that holds your videos."
#     config:
#       region: us-east-1
#       credentials:
#         type: access_key
#         access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
#         secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

# bucket_syncs:
#   - name: s3-videos-sync
#     bucket: s3-videos
#     connection: s3-videos-connection
#     # Starts with the S3 bucket name. Files directly under it and in subfolders sync.
#     source_path: "my-video-bucket/videos/"
#     sync_mode: continuous
#     polling_interval_seconds: 300
#     skip_duplicates: true
#     file_filters:
#       include_patterns: ["*.mp4", "*.mov", "*.webm"]
#     schema_mapping:
#       mappings:
#         video:
#           target_type: blob
#           source: {type: file}
#           blob_type: video
#         # videos/<category>/<file>.mp4: the folder under videos/ becomes the category.
#         category:
#           target_type: field
#           source: {type: folder_path, segment: -1}

collections:
  - name: video-segments
    namespace: ingest-video-from-s3
    description: "multimodal_extractor@v1 over bucket s3-videos: one document per 10-second segment, with a visual embedding and a transcript embedding. Feeds s3-video-search."
    source:
      type: bucket
      bucket: s3-videos
    feature_extractor:
      name: multimodal_extractor
      version: v1
      parameters:
        split_method: time
        time_split_interval: 10
        run_multimodal_embedding: true
        # Both default to false; without them the speech index stays empty.
        run_transcription: true
        run_transcription_embedding: true
      input_mappings:
        video: video
      field_passthrough:
        - source_path: category
    enabled: true

retrievers:
  - name: s3-video-search
    namespace: ingest-video-from-s3
    description: "Type what a moment shows or what someone says in it, and get the matching segments from every video the sync has ingested."
    collections:
      - video-segments
    input_schema:
      query:
        type: text
        required: true
        description: "What the moment shows or what is said in it, in plain words"
    stages:
      - stage_name: search
        stage_id: feature_search
        parameters:
          searches:
            - feature_uri: "mixpeek://multimodal_extractor@v1/vertex_multimodal_embedding"
              query:
                input_mode: text
                value: "{{INPUT.query}}"
              top_k: 50
              weight: 0.6
            - feature_uri: "mixpeek://multimodal_extractor@v1/multilingual_e5_large_instruct_v1"
              query:
                input_mode: text
                value: "{{INPUT.query}}"
              top_k: 50
              weight: 0.4
          fusion: dbsf
          final_top_k: 20
    tags:
      - guide:ingest-video-from-s3

# Three public-domain television commercials (61, 60 and 20 seconds) from the starter
# sample set, standing in for files the sync would bring from S3. category is what the
# folder_path mapping above would write for videos/household/ and videos/breakfast/.
seed:
  - bucket: s3-videos
    max_objects: 3
    objects:
      - blobs: {video: samples/starter/videos/tide-detergent.mp4}
        category: household
      - blobs: {video: samples/starter/videos/ivory-soap.mp4}
        category: household
      - blobs: {video: samples/starter/videos/kelloggs-variety-pak.mp4}
        category: breakfast
acceptance:
  max_cost_usd: 0.5
  steps:
    - name: segments-indexed
      kind: documents
      collection: video-segments
      expect: {min_documents: 3}
    - name: segments-answer-a-typed-search
      kind: query
      retriever: s3-video-search
      inputs: {query: washing clothes with laundry detergent}
      expect: {min_results: 1}
```

## Hand it to an agent

Paste this prompt into Claude Code, Cursor or another coding agent. To give the agent this whole page instead, use **Copy page** in the menu at the top of the page, or point it at the page's Markdown at `https://mixpeek.com/docs/templates/ingest-video-from-s3.md`.

```text Prompt theme={null}
Set up the Mixpeek "Ingest video from S3" template in my organization. My API key is in MIXPEEK_API_KEY.
1. Save the manifest at the bottom of https://mixpeek.com/docs/templates/ingest-video-from-s3 as ingest-video-from-s3.namespace.yaml.
2. POST it to https://api.mixpeek.com/v1/manifest/validate as the multipart field manifest_file, with the header Authorization: Bearer $MIXPEEK_API_KEY. Fix every entry in errors and validate again.
3. POST the same file to https://api.mixpeek.com/v1/manifest/apply?wait_for_seed=true. Every entry in resources should be created.
4. GET https://api.mixpeek.com/v1/namespaces/ingest-video-from-s3 and keep namespace_id. Send it as the X-Namespace header on every call below.
5. POST {"inputs": {"query": "washing clothes with laundry detergent"}} to https://api.mixpeek.com/v1/retrievers/s3-video-search/execute. Read documents, check that status is completed, and print warnings.
Reference for this template: https://mixpeek.com/docs/templates/ingest-video-from-s3.md
```

## How it works

The manifest declares four parts:

1. A **storage connection** holds read access to your S3 bucket. It belongs to the organization, so other namespaces can reuse it.
2. A **bucket sync** watches one S3 prefix through that connection. With `sync_mode: continuous` it checks for new files every `polling_interval_seconds` and creates one object in `s3-videos` per new file.
3. The sync submits each new batch of objects for processing, so `video-segments` runs `multimodal_extractor` on them with no extra call. Each 10-second segment gets a visual and a transcript embedding.
4. `s3-video-search` searches both embeddings with one text query and fuses the two lists with `dbsf`.

As published, the connection and the sync are commented out, because apply tests a connection before it saves it and placeholder credentials would fail. The seed's sample commercials make the first query work before you connect anything. Synced files land in the same bucket and go through the same collection.

> [!NOTE]
>
> `run_transcription` and `run_transcription_embedding` both default to `false`; without them the speech search finds nothing. The manifest sets both to `true`.

## Connect your S3 bucket

**1. Grant read access**

Mixpeek needs to list and read objects under your prefix. [Object storage](https://docs.mixpeek.com/docs/ingest/object-storage.md) has the IAM policy, and the role trust policy if you use a role.

**2. Store the keys as organization secrets**

The connection reads its keys from `${{ secrets.AWS_ACCESS_KEY_ID }}` and `${{ secrets.AWS_SECRET_ACCESS_KEY }}`, so the manifest file never holds them. Create both once per organization, with these exact names. This takes an admin API key.

```bash cURL theme={null}
curl -X POST https://api.mixpeek.com/v1/organizations/secrets \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"secret_name\": \"AWS_ACCESS_KEY_ID\", \"secret_value\": \"$AWS_ACCESS_KEY_ID\"}"

curl -X POST https://api.mixpeek.com/v1/organizations/secrets \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"secret_name\": \"AWS_SECRET_ACCESS_KEY\", \"secret_value\": \"$AWS_SECRET_ACCESS_KEY\"}"
```

**3. Uncomment the connection and the sync**

In the manifest, remove the `# ` in front of the `storage_connections:` and `bucket_syncs:` blocks. Set `region` to your bucket's region. Set `source_path` to your bucket name and prefix, written as `my-video-bucket/videos/` or `s3://my-video-bucket/videos/`.

**4. Apply again**

`create_missing` creates the connection and the sync and leaves everything else as it is.

```bash theme={null}
curl -X POST "https://api.mixpeek.com/v1/manifest/apply?mode=create_missing" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -F "manifest_file=@ingest-video-from-s3.namespace.yaml"
```

Credentials that cannot reach the bucket fail the apply with the connection named.

## Run the sync now

To start the first run without waiting for the polling interval, look up the sync's id and trigger it:

```bash cURL theme={null}
SYNC_ID=$(curl -s -X POST https://api.mixpeek.com/v1/buckets/s3-videos/syncs/list \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{}' | jq -r '.results[] | select(.sync_name == "s3-videos-sync") | .sync_config_id')

curl -X POST "https://api.mixpeek.com/v1/buckets/s3-videos/syncs/$SYNC_ID/trigger" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID"

curl -s "https://api.mixpeek.com/v1/buckets/s3-videos/syncs/$SYNC_ID/metrics" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  | jq '{healthy, total_files_discovered, total_files_synced, total_files_failed, last_error}'
```

`healthy` is `false` when the sync is inactive or paused, has consecutive failures, or has not progressed for two of its polling intervals. Files that fail after every retry are counted in `dlq_total`.

| Operation | Endpoint |
| - | - |
| Run now | `POST /v1/buckets/{bucket_id}/syncs/{sync_config_id}/trigger` |
| Pause, resume | `POST .../pause`, `POST .../resume` |
| One run's status | `GET .../jobs/{sync_job_id}` |
| Files that failed every retry | `POST .../dlq` |

## Change what the sync reads

Edit the `bucket_syncs` entry and apply with `?mode=upsert`. Upsert updates `source_path`, `file_filters`, `polling_interval_seconds`, `schema_mapping`, `reconcile` and `batch_collection_ids`. It does not change `sync_mode`, so choose that before the first apply.

> [tab] One-time backfill
>
> `initial_only` imports what is under the prefix once and then stops. Use it for an archive that does not grow.
>
> ```yaml ingest-video-from-s3.namespace.yaml theme={null}
> bucket_syncs:
>   - name: s3-videos-sync
>     bucket: s3-videos
>     connection: s3-videos-connection
>     source_path: "my-video-bucket/archive/"
>     sync_mode: initial_only
> ```

> [tab] File filters
>
> This takes MP4 files up to 2 GB and skips files whose names end in `_draft.mp4`.
>
> ```yaml ingest-video-from-s3.namespace.yaml theme={null}
>     file_filters:
>       include_patterns: ["*.mp4"]
>       exclude_patterns: ["*_draft.mp4"]
>       max_size_bytes: 2147483648
> ```

> [tab] Poll less often
>
> The interval accepts 30 to 86400 seconds.
>
> ```yaml ingest-video-from-s3.namespace.yaml theme={null}
>     polling_interval_seconds: 3600
> ```

## Map S3 metadata onto each object

`schema_mapping` decides what each synced file writes into the bucket object. The published mapping writes the parent folder's name as `category`, so `videos/household/tide.mp4` gets `category: household`, which `field_passthrough` copies onto every segment. Other sources for a field:

```yaml ingest-video-from-s3.namespace.yaml theme={null}
        schema_mapping:
          mappings:
            video:
              target_type: blob
              source: {type: file}
              blob_type: video
            # An S3 object tag, set with put-object-tagging
            category:
              target_type: field
              source: {type: tag, key: category}
            # User metadata (x-amz-meta-campaign), set at upload
            campaign:
              target_type: field
              source: {type: metadata, key: campaign}
            # The first capture group of a regex over the file name
            shoot_date:
              target_type: field
              source: {type: filename_regex, pattern: "^(\\d{4}-\\d{2}-\\d{2})_"}
```

Every key under `mappings` must be a property in the bucket schema, so add `campaign` and `shoot_date` to `s3-videos` as `type: string` in the same edit. To filter segments on a new field, append it to the collection's `field_passthrough`; segments extracted after the change carry it. To filter a run to one folder:

```bash cURL theme={null}
curl -X POST https://api.mixpeek.com/v1/retrievers/s3-video-search/execute \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {"query": "a bowl of cereal with milk"},
    "filters": {"AND": [{"field": "category", "operator": "eq", "value": "breakfast"}]}
  }' \
  | jq '{status, warnings, documents: [.documents[] | {category, start_time, end_time, score}]}'
```

## Use an IAM role instead of keys

A role keeps long-lived keys out of Mixpeek. Replace the connection's `credentials` block; its trust policy must allow Mixpeek to assume it with your `external_id`, as [Object storage](https://docs.mixpeek.com/docs/ingest/object-storage.md) describes.

```yaml ingest-video-from-s3.namespace.yaml theme={null}
storage_connections:
  - name: s3-videos-connection
    provider: s3
    description: "Read-only access to the S3 bucket that holds your videos."
    config:
      region: us-east-1
      credentials:
        type: iam_role
        role_arn: "arn:aws:iam::123456789012:role/mixpeek-storage-sync-role"
        external_id: "mixpeek-my-organization"
```

Use your own account id, role name and external id. For S3-compatible storage such as MinIO, keep `access_key` credentials and add `endpoint_url` to `config`.

## Seed from your own bucket

A seed blob written as `{connection, path}` reads one object through the connection, which gives you a first query on your own footage at apply time:

```yaml ingest-video-from-s3.namespace.yaml theme={null}
seed:
  - bucket: s3-videos
    max_objects: 2
    objects:
      - blobs:
          video: {connection: s3-videos-connection, path: "s3://my-video-bucket/videos/household/launch.mp4"}
        category: household
      - blobs:
          video: {connection: s3-videos-connection, path: "s3://my-video-bucket/videos/breakfast/teaser.mp4"}
        category: breakfast
```

The seed runs once, at apply, and every seeded minute is billed like a synced one.

## Control cost

Processing costs 0.20 USD per minute of video, for every collection that reads the bucket. The namespace's `budget.daily_usd` pauses new batches once a day's spend reaches it. Raise it to cover a normal day of new video:

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/namespaces/$NAMESPACE_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"spend_budget": {"daily_usd": 20}}'
```

At 20 USD a day the namespace processes up to 100 minutes of new video a day. To ingest objects now and process them later, set `skip_batch_submission: true` on the sync: it creates objects and submits nothing, so nothing is searchable until you trigger the collection.

## Other storage providers

The same bucket, sync and collection work with GCS, Azure Blob, R2 and other object stores. Change `provider` and `config` on the connection; [Object storage](https://docs.mixpeek.com/docs/ingest/object-storage.md) lists each provider's `config` fields. For fusion, moments, reranking and image queries on this kind of collection, see [Video understanding](https://docs.mixpeek.com/docs/templates/video-understanding.md).


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