> ## 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.

# Buckets and objects

> Create a bucket with a schema, upload objects, check whether they processed, avoid duplicates, and submit batches of any size.

A **bucket** holds your raw inputs. Each item you put in it is an **object**: the metadata fields your bucket schema declares, plus one or more **blobs** (an image, a video, a PDF, a piece of text). A bucket stores objects and does nothing else with them. A [collection](https://docs.mixpeek.com/docs/extract/collections.md) that names the bucket as its source runs extractors over the objects and writes searchable documents. A **batch** is the unit of that processing: a set of objects submitted to the bucket's collections.

## Create a bucket and upload an object

Create a bucket whose schema has a `product_id` string and an `image` blob:

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "bucket_name": "products",
    "bucket_schema": {
      "properties": {
        "product_id": {"type": "string", "required": true},
        "image": {"type": "image"}
      }
    },
    "unique_key": {"fields": ["product_id"], "default_policy": "upsert"}
  }'
```

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

HEADERS = {
    "Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}",
    "X-Namespace": os.environ["NAMESPACE_ID"],
}
bucket = requests.post(
    "https://api.mixpeek.com/v1/buckets",
    headers=HEADERS,
    json={
        "bucket_name": "products",
        "bucket_schema": {
            "properties": {
                "product_id": {"type": "string", "required": True},
                "image": {"type": "image"},
            }
        },
        "unique_key": {"fields": ["product_id"], "default_policy": "upsert"},
    },
).json()
print(bucket["bucket_id"])
```

```javascript JavaScript theme={null}
const headers = {
  Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
  "X-Namespace": process.env.NAMESPACE_ID,
  "Content-Type": "application/json",
};
const bucket = await (
  await fetch("https://api.mixpeek.com/v1/buckets", {
    method: "POST",
    headers,
    body: JSON.stringify({
      bucket_name: "products",
      bucket_schema: {
        properties: {
          product_id: { type: "string", required: true },
          image: { type: "image" },
        },
      },
      unique_key: { fields: ["product_id"], default_policy: "upsert" },
    }),
  })
).json();
console.log(bucket.bucket_id);
```

Then create an object. Put schema fields at the top level of the body, beside `blobs`. `auto_process=true` creates a batch for the object and submits it in the same call:

```bash cURL title="Create an object and process it" theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/products/objects?auto_process=true" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "sku_1001",
    "blobs": [{
      "property": "image",
      "type": "image",
      "data": "https://mixpeek-public-demo.s3.us-east-2.amazonaws.com/starter/aussie_jumping.jpg"
    }]
  }'
```

The response is the object with `status: "PENDING"`. The bucket path accepts the bucket name or its `bucket_id`. Processing needs at least one collection sourced from the bucket; see [Collections and features](https://docs.mixpeek.com/docs/extract/collections.md).

## Bucket schema

`bucket_schema` is required. Its `properties` map each field name to a type. A field is either metadata, stored on the object and passed through to documents, or a blob, which extractors read.

| Kind | Types |
| - | - |
| Metadata | `string`, `number`, `integer`, `float`, `boolean`, `object`, `array`, `date`, `datetime` |
| Blob | `text`, `image`, `audio`, `video`, `pdf`, `excel` |

Use these Mixpeek type names. JSON Schema types such as `keyword` are rejected. Each field also takes `required`, `description`, `enum`, `default` and `examples`.

An object is checked against the schema when you create it. A field the schema does not declare, or a value of the wrong type, answers `422`. A schema with only metadata fields takes objects with no `blobs`.

A collection maps schema fields to extractor inputs, so name blob fields after what they hold. The standard names (`image`, `video`, `audio`, `text`) let a collection created with `features` wire itself to the bucket without an explicit mapping.

## Objects and blobs

Each blob in `blobs` names the schema `property` it fills and its `type`, and carries its content in one of two ways:

| Field | Use it for |
| - | - |
| `data` | An `https://` or `s3://` URL, base64 content, or, for a `text` blob, the text itself |
| `upload_id` | A file you uploaded to a presigned URL from [`POST /v1/buckets/{bucket}/uploads`](https://docs.mixpeek.com/docs/api-reference/bucket-uploads/create-upload). Use it for large files |

**Inline text.** A `text` blob takes the text itself in `data`: `"data": "Wireless headphones"`, or `"data": {"text": "Wireless headphones"}`. A string that starts with `http://`, `https://` or `s3://` is read as a URL. A bare base64 string that decodes to readable text is rejected with a 422; to send encoded text, use `"data": "data:text/plain;base64,<encoded_data>"`. For a bucket whose schema declares `title` and `description` as `text`:

```bash cURL title="Create an object with inline text" theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/articles/objects" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "blobs": [
      {"property": "title", "type": "text", "data": "Wireless headphones"},
      {"property": "description", "type": "text", "data": {"text": "Over-ear, 30-hour battery, active noise cancellation"}}
    ]
  }'
```

The upload flow is three calls: create the upload with `filename` and `content_type`, `PUT` the file to the returned `presigned_url`, then [confirm the upload](https://docs.mixpeek.com/docs/api-reference/bucket-uploads/confirm-upload.md). Confirm creates the object for you unless you set `create_object_on_confirm: false`. The presigned URL is valid for `presigned_url_expiration` seconds: 3,600 by default, 60 to 86,400.

Other ways in:

* [`POST /v1/buckets/{bucket}/objects/batch`](https://docs.mixpeek.com/docs/api-reference/bucket-objects/create-objects-in-batch) creates up to 100 objects in one call.
* A [sync](https://docs.mixpeek.com/docs/ingest/object-storage.md) copies files from S3, GCS, Azure, Google Drive and other stores into the bucket and keeps it current.
* [Streams, databases and the web](https://docs.mixpeek.com/docs/ingest/other-sources.md) covers RTSP cameras, warehouses, RSS and similar sources.

Mixpeek fingerprints every blob with a SHA-256 content hash, stored on the object and on every document made from it (`content_hash`). Identical bytes give the same hash regardless of filename or path, and changed bytes give a new one.

> [accordion] Content hash (checksum)
>
> Every blob carries `details.hash` as `sha256:<hex>`. Send `checksum` on a blob to set it yourself; a bare 64-character hex string is normalized to `sha256:<hex>`, and a malformed value answers 422. Leave it out and the platform computes the hash for inline text on write and for every object a storage sync brings in. Objects written before content addressing existed can carry `details.hash: null`, which means the hash was never computed.
>
> ```json Blob with a pinned checksum theme={null}
> {
>   "property": "hero_image",
>   "type": "image",
>   "data": "https://example.com/photo.jpg",
>   "checksum": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
> }
> ```

> [accordion] Storage class
>
> Set `storage_class` on bucket create or update to choose the cost tier objects are written with. It applies to objects a storage sync writes; direct object creates and presigned uploads do not set it, and existing objects keep their tier.
>
> | `storage_class` | GCS | S3 / MinIO | Use for |
> | - | - | - | - |
> | `standard` (default) | STANDARD | STANDARD | Buckets retrievers read often |
> | `nearline` | NEARLINE | STANDARD\_IA | Occasional access |
> | `coldline` | COLDLINE | GLACIER\_IR | Rare access |
> | `archive` | ARCHIVE | GLACIER | Long-term retention |

## Object states

An object's `status` says where processing stands.

| Status | Meaning | What to do |
| - | - | - |
| `PENDING` | Created and not processed yet, including while its batch waits or runs | Look it up again later |
| `COMPLETED` | Processed. Its documents are searchable | Read its documents |
| `FAILED` | Processing failed. `error` says why | Fix the input and submit again |

`PENDING` covers both an object no batch has picked up and one inside a running batch. The object's `last_batch_id` names the batch that last processed it; [get that batch](https://docs.mixpeek.com/docs/api-reference/bucket-batches/get-batch-configuration.md) to see its status and failures. Treat any other object status as still processing.

Look an item up by your own id with a filter on the object list:

```bash cURL title="Look up an object by product_id" theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/products/objects/list" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"filters": {"AND": [{"field": "product_id", "operator": "eq", "value": "sku_1001"}]}}'
```

Each entry in `results` has `object_id`, `status`, `error`, `document_count`, `created_at` and `updated_at`. `document_count` stays `0` until a collection has processed the object. Combined with a retriever read, an item is in one of four states:

| Item state | Object lookup returns | Retriever read returns |
| - | - | - |
| Never submitted | `results: []` | `documents: []` |
| Submitted, not ready | One object, `status: "PENDING"` | `documents: []` |
| Ready | One object, `status: "COMPLETED"` | The item's documents |
| Failed | One object, `status: "FAILED"`, `error` set | `documents: []` |

A retriever read alone cannot tell "never submitted" from "not ready", because both return an empty list. The object lookup can. To read every document made from one object across all collections, call `GET /v1/objects/{object_id}/documents`.

## Duplicates and idempotency

Each create makes a new object, even when its fields match an object you created before. Two creates of one item give two objects, two processing charges, and a retriever read that returns the documents of both. Pick one of these to prevent it:

| Approach | What it does | When to use it |
| - | - | - |
| Look up before you create | The lookup above. Create only when it returns nothing | One worker handles each id |
| `idempotency_key` in the create body | A create whose key matches a live object in the bucket returns that object | Retrying a create after a timeout |
| `skip_duplicates: true` in the create body | A create whose content hash matches a live object returns that object | The same file arrives under different names |
| A bucket `unique_key` | A second create with the same key follows the bucket's policy | Several workers may create the same id at once |

`idempotency_key` protects a retry that follows the first call. Two creates with the same key sent at the same moment can both succeed, so use a unique key when creates can race. A deleted object does not match either key; a create after a delete makes a fresh object.

### Unique keys and policies

Set `unique_key` when you create the bucket. You cannot add or change it later. `fields` names one or more scalar schema fields; with several, all must match (for example `["sensor_id", "timestamp"]`). Every object must carry a non-empty value for each.

| Policy | Key is new | Key exists |
| - | - | - |
| `insert` | Creates the object | `409 Conflict` |
| `update` | `404 Not Found` | Updates the object |
| `upsert` | Creates the object | Updates the object |

`?policy=` on the create call wins over the bucket's `default_policy`. With neither, the create answers `400`.

A unique key also makes reprocessing idempotent. With one, documents get deterministic ids, so triggering a collection again overwrites them. Without one, documents get random ids and a second trigger creates duplicates.

## Batches

A batch submits objects to the bucket's collections. It is created in `DRAFT`, then submitted, queued, and run.

| Path | What it does | Use it for |
| - | - | - |
| `?auto_process=true` on object create | One batch per object, submitted at once | Single uploads |
| [`POST /v1/buckets/{bucket}/batches`](https://docs.mixpeek.com/docs/api-reference/bucket-batches/create-batch), then [`/submit`](https://docs.mixpeek.com/docs/api-reference/bucket-batches/submit-batch-for-processing) | A batch from `object_ids` or `filters` (up to 50,000 objects from a filter). Pass `auto_submit: true` to skip the second call | A chosen set of objects |
| [`POST /v1/buckets/{bucket}/batches/bulk-submit`](https://docs.mixpeek.com/docs/api-reference/bucket-batches/bulk-submit-whole-bucket-n-auto) | Splits the whole bucket, or a filtered part, into batches of `chunk_size` objects and submits each | Anything over a few thousand objects |
| [`POST /v1/collections/{collection_id}/trigger`](https://docs.mixpeek.com/docs/api-reference/collections/trigger-collection-processing) | One batch with every object in the source bucket | Small buckets |

A collection trigger does no splitting. Over a large bucket its single batch runs as one job with a fixed worker ceiling and a 24-hour deadline, so it under-parallelizes and can time out. Use bulk-submit instead:

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/buckets/products/batches/bulk-submit" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{"chunk_size": 20000, "dedup_strategy": "skip"}'
```

```python Python theme={null}
resp = requests.post(
    "https://api.mixpeek.com/v1/buckets/products/batches/bulk-submit",
    headers=HEADERS,
    json={"chunk_size": 20000, "dedup_strategy": "skip"},
)
print(resp.json())
```

```javascript JavaScript theme={null}
const submitted = await fetch(
  "https://api.mixpeek.com/v1/buckets/products/batches/bulk-submit",
  {
    method: "POST",
    headers,
    body: JSON.stringify({ chunk_size: 20000, dedup_strategy: "skip" }),
  },
);
console.log(await submitted.json());
```

Omit `collection_ids` to process every collection sourced from the bucket, plus collections downstream of them.

### Reprocessing and dedup strategy

`dedup_strategy` decides what happens to objects the target collection already has documents for. It is scoped to the (bucket, collection) pair.

| Strategy | Behavior | Cost |
| - | - | - |
| `skip` (default) | Reprocesses an object only if its content or the collection's extractor configuration changed since its last extraction. Skips the rest | Nothing for unchanged content |
| `replace` | Reprocesses every object, then deletes its earlier documents once the new ones are written. If processing fails, the earlier documents stay | Full extraction |
| `force` | Reprocesses every object and overwrites its documents in place. Documents a re-run no longer produces stay behind | Full extraction. Prefer `replace` |

`skip` does not delete documents a re-run no longer produces, such as extra chunks left after a chunking change that yields fewer chunks. Use `replace` for a clean rebuild. An organization whose documents are protected from re-extraction gets a `409` naming the reason for `replace` or `force`.

When a source file changes, its hash changes. The next batch or [sync](https://docs.mixpeek.com/docs/ingest/object-storage.md) reprocesses that object and rebuilds the documents derived from it, and skips objects whose hash did not change.

### Sizing and concurrency

Each batch runs as its own job. A job adds about one CPU worker per 500 objects up to a per-job ceiling, so 16,000 to 20,000 objects saturate one job. Larger batches do not run faster, and smaller ones each pay a cluster cold start and queue behind your concurrency limit.

| Corpus size | `chunk_size` | Batches |
| - | - | - |
| Under 5,000 | One trigger or one batch | 1 |
| 5,000 to 100,000 | 5,000 to 10,000 | 1 to 20 |
| 100,000 to 1M | 20,000 | 5 to 50 |
| Over 1M | 20,000 to 50,000 | 20 or more |

`chunk_size` defaults to 1,000, accepts up to 50,000, and is clamped to your plan's maximum batch size. Price a batch before submitting it with [estimate cost](https://docs.mixpeek.com/docs/api-reference/bucket-batches/estimate-batch-cost.md), which runs the submit calculation without charging.

Submission is accept-and-queue. Batches past your concurrency limit wait as `QUEUED` and start as running batches finish, highest priority first, then oldest. Priority comes from your plan (Enterprise 9, Scale and Team 7, Build and Pro 6, Free 4). Batches submitted with [`submit-all`](https://docs.mixpeek.com/docs/api-reference/bucket-batches/submit-all-draft-batches) run at priority 2, so a backfill created as drafts and submitted that way stays behind new uploads from a sync. A running batch is never pre-empted.

> [accordion] Batch limits by plan
>
> | Plan | Max objects per batch | Concurrent running batches |
> | - | - | - |
> | Free | 10,000 | 1 |
> | Build, Pro | 50,000 | 5 |
> | Scale, Team | 500,000 | 10 |
> | Enterprise | 5,000,000 | 50 |
>
> Submission answers `429` only when a queue is full. Each running job has a 24-hour execution deadline. See [Limits and billing](https://docs.mixpeek.com/docs/production/limits-and-billing.md).

> [accordion] Automatic recovery
>
> * Failed tasks retry 3 times with exponential backoff.
> * Work from a worker that dies mid-task goes to another worker.
> * Sweeps every 1 to 10 minutes re-drive orphaned, stuck or stalled batches with bounded retries and mark the rest failed.
> * Batches that failed on transient errors retry hourly, up to 3 times, with 1, 2 and 4 hour backoff.
>
> Progress is recorded per object. Resubmitting a partly failed batch skips finished objects, so you do not pay for their extraction twice. Authentication errors, schema validation errors and exhausted provider quotas do not retry; they end the batch in `FAILED` or `COMPLETED_WITH_ERRORS` until you fix the cause and [resubmit](https://docs.mixpeek.com/docs/api-reference/bucket-batches/resubmit-failed-batch.md).

> [accordion] Backfill plus new uploads
>
> Most libraries need a one-time backfill and a steady trickle of new files, against the same bucket and collection. Run the backfill with bulk-submit, or a sync with `sync_mode: "initial_only"`. Feed new files with a `continuous` [sync](https://docs.mixpeek.com/docs/ingest/object-storage.md) or `auto_process` per upload. A backfill fills your concurrent-batch slots, and a new upload waits for a free slot even at higher priority, so keep the backfill in chunks small enough that slots free up often.
>
> For a latency target on single uploads, Mixpeek can keep warm processing capacity running for your account. There is no API for it; ask your account team, with expected uploads per hour and target processing time.

## Check a batch and handle errors

`GET /v1/buckets/{bucket}/batches/{batch_id}` returns the batch status, per-tier progress, `documents_written`, `failed_object_count` and `error_summary`. [`/failed-documents`](https://docs.mixpeek.com/docs/api-reference/bucket-batches/get-failed-documents-for-batch) lists every failed object with its error. Pass `webhook_url` on submit to get a POST when the batch reaches `COMPLETED`, `FAILED` or `CANCELED`.

A batch that ends `COMPLETED_WITH_ERRORS` is a work list: read the failed documents, fix the cause, and resubmit. Before a large run, create the `batch_failed`, `batch_stalled` and `batch_error_rate` [alerts](https://docs.mixpeek.com/docs/enrich/alerts-and-triggers.md) so a failure reaches you without polling. [Monitoring and troubleshooting](https://docs.mixpeek.com/docs/production/monitoring.md) covers deeper batch diagnosis.

| Response | Cause |
| - | - |
| `400` on object create | The bucket has a `unique_key`, and neither `?policy=` nor `default_policy` is set |
| `404` on object create | `policy=update` and no object has that key |
| `409` on object create | `policy=insert` and an object already has that key |
| `409` on batch submit | `replace` or `force` on an organization whose documents are protected from re-extraction |
| `422` on object create | A field the schema does not declare, or a value of the wrong type |
| `429` on batch submit | Your batch queue is full |

## Related

* [Object storage and syncs](https://docs.mixpeek.com/docs/ingest/object-storage.md): keep a bucket in step with S3, GCS, Azure and other stores
* [Collections and features](https://docs.mixpeek.com/docs/extract/collections.md): turn objects into documents
* [Retrievers](https://docs.mixpeek.com/docs/retrieve/retrievers.md): read documents back
* [Create object API](https://docs.mixpeek.com/docs/api-reference/bucket-objects/create-object.md) and [Create bucket API](https://docs.mixpeek.com/docs/api-reference/buckets/create-bucket.md)


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