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

# Bring your own vectors

> Upsert embeddings you already have into a standalone namespace, search them with a retriever, import an export, manage documents, and promote later.

Search embeddings you computed yourself, with no extractors or collections to set up: create a **standalone** namespace, upsert documents with their vectors and payload, and query them through a retriever. When you later want Mixpeek to embed queries or process files, promote the namespace to managed without reindexing.

## Prerequisites

* A Mixpeek API key with an active plan. Until a plan is chosen, calls return `PlanRequiredError`.
* Your embeddings, and the model that produced them, so query vectors come from the same model.

## Upsert and search your vectors

**1. Create a standalone namespace**

```bash cURL title="Create the namespace" theme={null}
curl -X POST "https://api.mixpeek.com/v1/namespaces/standalone" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"namespace_id": "product-search", "vector_configs": [{"name": "my_text_v1", "dimension": 3, "metric": "cosine"}]}'
```

`namespace_id` is the id you choose: 1 to 128 letters, digits, `_` and `-`, starting with a letter or digit. `vector_configs` is optional. Without it, the first upsert under a vector name creates that index with the dimension it sees and the `cosine` metric, and later writes must match that dimension. Set `metric` to `dot` or `euclidean` up front if your model needs it. Use dimension 1536, 768 or whatever your model outputs; the examples use 3 so they run as shown.

**2. Upsert documents**

```bash cURL theme={null}
curl -X POST "https://api.mixpeek.com/v1/namespaces/product-search/documents/upsert" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "documents": [
      {"document_id": "prod-001", "vectors": {"my_text_v1": [0.12, -0.34, 0.56]},
       "payload": {"title": "Wireless Headphones", "category": "audio", "price": 79.99}},
      {"document_id": "prod-002", "vectors": {"my_text_v1": [0.08, 0.22, -0.41]},
       "payload": {"title": "Bluetooth Speaker", "category": "audio", "price": 59.99}}
    ]
  }'
```

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

HEADERS = {"Authorization": f"Bearer {os.environ['MIXPEEK_API_KEY']}"}
resp = requests.post(
    "https://api.mixpeek.com/v1/namespaces/product-search/documents/upsert",
    headers=HEADERS,
    json={
        "documents": [
            {"document_id": "prod-001", "vectors": {"my_text_v1": [0.12, -0.34, 0.56]},
             "payload": {"title": "Wireless Headphones", "category": "audio", "price": 79.99}},
            {"document_id": "prod-002", "vectors": {"my_text_v1": [0.08, 0.22, -0.41]},
             "payload": {"title": "Bluetooth Speaker", "category": "audio", "price": 59.99}},
        ]
    },
)
print(resp.json())
```

```javascript JavaScript theme={null}
const resp = await fetch(
  "https://api.mixpeek.com/v1/namespaces/product-search/documents/upsert",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.MIXPEEK_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      documents: [
        { document_id: "prod-001", vectors: { my_text_v1: [0.12, -0.34, 0.56] },
          payload: { title: "Wireless Headphones", category: "audio", price: 79.99 } },
        { document_id: "prod-002", vectors: { my_text_v1: [0.08, 0.22, -0.41] },
          payload: { title: "Bluetooth Speaker", category: "audio", price: 59.99 } },
      ],
    }),
  },
);
console.log(await resp.json());
```

Each call takes up to 1,000 documents; repeat it for larger loads. An existing `document_id` is overwritten, vectors and payload together. A document can carry vectors for any subset of indexes, and a new vector name creates a new index.

**3. Create a retriever**

All queries run through [retrievers](https://docs.mixpeek.com/docs/retrieve/retrievers.md); there is no endpoint that searches a namespace directly. For your own vectors, the `feature_search` stage takes `input_mode: vector` and the vector name as `feature_uri`.

```bash cURL title="One-stage vector search" theme={null}
curl -X POST "https://api.mixpeek.com/v1/retrievers" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: product-search" \
  -H "Content-Type: application/json" \
  -d '{
    "retriever_name": "product_search",
    "input_schema": {"query_vector": {"type": "array", "required": true}},
    "stages": [{
      "stage_name": "search",
      "stage_type": "filter",
      "config": {
        "stage_id": "feature_search",
        "parameters": {
          "searches": [{
            "feature_uri": "my_text_v1",
            "query": {"input_mode": "vector", "value": "{{INPUT.query_vector}}"},
            "top_k": 10
          }],
          "final_top_k": 10
        }
      }
    }]
  }'
```

The response carries `retriever_id`.

**4. Execute it**

```bash cURL title="Search with a query vector" theme={null}
curl -X POST "https://api.mixpeek.com/v1/retrievers/$RETRIEVER_ID/execute" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: product-search" \
  -H "Content-Type: application/json" \
  -d '{"inputs": {"query_vector": [0.15, -0.28, 0.44]}}'
```

## Check that it worked

The execute response carries `documents`, each with `document_id`, `score` and your payload fields, plus `status` and `warnings`. A run that degraded answers `200` with `status: "degraded"`. `GET /v1/namespaces/product-search/documents/prod-001` reads one document back.

Upserts become searchable in the background, usually within 10 to 30 seconds. For read-your-writes, send `"options": {"write_token": true}` on the upsert and pass the returned `write_token` to execute. Upserts invalidate the execute cache, so a re-run after a write returns fresh results.

## Search options

| Search | How |
| - | - |
| Dense | `input_mode: vector` with any `cosine`, `dot` or `euclidean` index |
| Keyword (BM25) | Declare a `text` payload index on the fields, then use the `lexical` option of `feature_search`. See [Index the fields you filter on](https://docs.mixpeek.com/docs/manage/namespaces.md#index-the-fields-you-filter-on) |
| Sparse | Sparse vectors from models such as SPLADE |
| Hybrid | Several searches in one `feature_search` stage, fused with `rrf` or `dbsf` |
| Filtered | `filters` with `field`, `operator` and `value`, on any search. Index each filtered field |

Stage parameters are in [Stages](https://docs.mixpeek.com/docs/retrieve/stages.md).

> [!WARNING]
>
> Name vectors after your project or model, such as `my_text_v1`. A few short generic names, `text_embedding` among them, collide with legacy keys in the store: writes succeed and every search then fails with `409`.

## What a document carries

| Field | Notes |
| - | - |
| `document_id` | Top level, your id. Not inside `payload` |
| `vectors` | Map of vector name to array. Length must match the index dimension |
| `payload` | Your fields. `document_id`, `collection_id`, `_internal`, `_mvs_namespace` and `_source_tier` are refused with `422` |
| `collection_id` (request level) | Optional. Tags the documents with a collection; otherwise a namespace-level default collection is used |

Mixpeek writes its own fields under `_internal`. To keep a source system's collection id, store it under another key such as `source_collection_id`.

> [accordion] Carry lineage and a content hash on upsert
>
> A document defaults to `source_type: "direct_upsert"` with no lineage. Send lineage to import derived documents that know where they came from:
>
> | Field | Meaning |
> | - | - |
> | `source_type` | `bucket`, `collection`, `direct_upsert` or `signal` |
> | `root_object_id`, `root_bucket_id` | The source object every derived document shares, and its bucket |
> | `source_object_id` | The parent object, when `source_type` is `bucket` |
> | `source_document_id`, `source_collection_id` | The parent document and collection, when `source_type` is `collection` |
> | `lineage_path`, `lineage_chain` | Materialized path such as `bkt_123/col_456/col_789`, and the ordered steps |
> | `content_hash` | SHA-256 of the source object. A later reprocess uses it to skip work it already did |

> [accordion] Write your own vectors into a managed collection
>
> `POST /v1/collections/{collection_id}/documents` takes `vectors` keyed by the collection's index name. Read names from `vector_indexes` on `GET /v1/collections/{collection_id}`: use the last segment of `feature_uri` (`multilingual_e5_large_instruct_v1`) or the full `index.name` (`text_extractor_v1_embedding`). Both work, and the vector is stored under `index.name`. The array length must match the index `dimensions`. A key the collection does not have returns a 422 that lists the available index names and dimensions.
>
> ```bash cURL theme={null}
> curl -X POST "https://api.mixpeek.com/v1/collections/$COLLECTION_ID/documents" \
>   -H "Authorization: Bearer $MIXPEEK_API_KEY" \
>   -H "X-Namespace: $NAMESPACE_ID" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "metadata": {"title": "Noise-Canceling Headphones"},
>     "vectors": {"multilingual_e5_large_instruct_v1": [0.12, -0.34, 0.56, "...1024 floats"]}
>   }'
> ```

## Import an export from another system

To load another system's export into a collection with vectors and lineage intact, use three calls; the first two write nothing.

| Step | Call | Returns |
| - | - | - |
| 1. Infer a mapping | `POST /v1/collections/import/infer` with `sample_rows` | `fields` and `warnings`, with a suggested source-to-target mapping |
| 2. Validate it | `POST /v1/collections/import/validate-mapping` with `mapping` | `ok` and `errors`: missing root identity, type mismatches, wrong vector dimensions, unknown fields |
| 3. Import | `POST /v1/collections/{collection_id}/import` with `export`, `mapping` and `dry_run` | `reconstructed`, `imported`, `skipped`, `errors`, `warnings` |

Run step 3 with `"dry_run": true` first: it checks every row and writes nothing (`imported` is `0`). A bad row does not stop the batch, so compare `reconstructed` with `imported` and `skipped` rather than looking for an error status. `explode` with `explode_axis` splits one export row into several documents. Import submits no extraction, so a collection with an extractor stores the export's vectors as they are. Moving a whole index from Pinecone or another database is covered in [Migrate from another database](https://docs.mixpeek.com/docs/tools/migrate.md).

## Read, update and delete documents

| Operation | Call | Notes |
| - | - | - |
| Get one | `GET /v1/namespaces/{namespace}/documents/{document_id}` | |
| Get many | `POST /v1/documents/batch-get` with `document_ids` (1 to 1,000) | Order follows the request. Unresolved ids go to `not_found` |
| List | `POST /v1/documents/list` with `collection_ids` and `limit` | `collection_ids` is a list. A singular `collection_id` is ignored and lists the whole namespace with `200` |
| Update fields | `PATCH /v1/collections/{collection_id}/documents/{document_id}` | Partial. A key set to `null` inside `metadata` is removed. Does not re-embed |
| Update many | `PATCH /v1/collections/{collection_id}/documents/bulk` with `update_data` and `filters` | Asynchronous. Omitting `filters` updates every document. Poll `GET /v1/tasks/{task_id}` |
| Replace vectors | Upsert the same `document_id` again | Send the payload too; it is replaced with the vectors |
| Delete one | `DELETE /v1/collections/{collection_id}/documents/{document_id}` | |
| Delete many | `DELETE /v1/collections/{collection_id}/documents/batch` | `document_ids` is synchronous; `filters` is asynchronous with a `task_id`, and `deleted_count` is `null` until the task ends |

The calls without a namespace in the path read it from `X-Namespace`. A top-level key in a `PATCH` body updates the document's top-level field (such as a passthrough `brand_id`); a key inside `metadata` updates `metadata.<key>`.

Deletes cascade. Deleting a bucket object removes every document derived from it; deleting a collection removes its documents; deleting a namespace removes everything in it. Deleting only a document leaves its source object, so a reprocess recreates it. A namespace under a [hold](https://docs.mixpeek.com/docs/manage/namespaces.md#expire-or-hold-a-namespace) refuses every delete.

Stored media fields hold `gs://` or `s3://` URIs. `batch-get` returns signed `https://` URLs by default; `documents/list`, single-document `GET` and retriever execute return them when you send `return_presigned_urls: true` in the body. Signed URLs last 24 hours, or 1 hour from single-document `GET`.

### Set and remove metadata keys

`PUT` and `PATCH` treat `metadata` the same way. Each key you send is set, and keys you omit stay as they are. A key set to `null` is removed. `"metadata": null` returns a 422, so name each key you want to remove.

```bash cURL theme={null}
curl -X PATCH "https://api.mixpeek.com/v1/collections/$COLLECTION_ID/documents/$DOCUMENT_ID" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "X-Namespace: $NAMESPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{ "metadata": { "status": "reviewed", "stale_field": null } }'
```

This sets `metadata.status`, removes `metadata.stale_field` and leaves every other key alone.

> [!NOTE]
>
> **Object metadata vs document metadata are separate.** The calls above edit a document. To edit the source object in its bucket, use [`PATCH /v1/buckets/{bucket_id}/objects/{object_id}`](https://docs.mixpeek.com/docs/api-reference/bucket-objects/partially-update-object) and send the object's custom fields flat at the root of the body, for example `{"campaign_id": "camp_002"}`. Only the fields you send change. Editing one does not change the other, and reprocessing an object regenerates its documents from the object's current state.

## Promote to managed

Promotion maps your existing indexes to inference services so retrievers can take raw text, and lets you add collections with extractors. Existing documents stay in place.

```bash cURL title="Check, then promote" theme={null}
curl -X POST "https://api.mixpeek.com/v1/namespaces/product-search/promote/validate" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vector_mappings": [{"existing_index": "my_text_v1", "inference_service": "openai_text_3_small"}]}'

curl -X POST "https://api.mixpeek.com/v1/namespaces/product-search/promote" \
  -H "Authorization: Bearer $MIXPEEK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vector_mappings": [{"existing_index": "my_text_v1", "inference_service": "openai_text_3_small"}]}'
```

`promote/validate` changes nothing and returns `valid`, `errors` and, per index, `suggestions` of inference services whose dimension matches. `add_vectors` creates new indexes during promotion (`name`, `dimension`, `metric`, optional `inference_service`). Map an index only to the model that produced its vectors.

After promotion, change the retriever's query to `{"input_mode": "text", "value": "{{INPUT.q}}"}` and pass text. Promotion is atomic and one-way: a managed namespace cannot return to standalone.

## System collections

Mixpeek keeps some collections in every namespace for you. They answer filters, retrievers and alerts like any collection, and the `_`, `mxp_` and `mvs_bucket_` prefixes are reserved.

| Collection | Holds |
| - | - |
| `mvs_bucket_<bucket_id>` | One payload-only document per bucket object, written with the object. Object `status` is at `_internal.object.status`. Name the bucket id where a collection id goes to search or alert on objects |
| `mxp_retriever_interactions` | Clicks, dwells and other result feedback |
| `mxp_retriever_queries`, `mxp_retriever_executions`, `mxp_retriever_rollups` | Each query, each run (status, latency, count), and 15-minute health windows |
| `mxp_retriever_evaluations`, `mxp_document_annotations` | Evaluation results and human labels |
| `mxp_platform_events` | Resource lifecycle events, including `namespace_expiring` and `index_adaptation` |
| `mxp_webhook_deliveries` | Each webhook attempt and outcome |
| `mxp_compute_utilization` | Per-batch compute: documents, duration, throughput |

Each `mxp_` collection appears the first time a matching event happens. `mxp_batch_failures`, `mxp_infra_metrics` and `mxp_healing_events` have no writer today and stay empty. Namespaces older than a rename use `mxp_evaluations` and `mxp_resources` instead. For the ordered change feed, read `GET /v1/events`.

## What goes wrong

| Symptom | Cause and fix |
| - | - |
| Writes succeed, searches return `409` | The vector name collides with a legacy key. Use a project-specific name |
| Upsert answers `422` | A reserved key in `payload`, or a vector length that does not match the index |
| Search finds nothing right after upsert | Indexing is still running. Wait, or use a `write_token` |
| A list returns the whole namespace | `collection_id` (singular) was sent; use `collection_ids` |
| A filter returns zero documents with `200` | The field path does not exist on the documents, or is unindexed. Read one document and check |
| Bulk update or filter delete shows `null` counts | The work is asynchronous. Poll the task |
| Media fields are `gs://` URIs | Request presigned URLs on that call |

## Related

* [Namespaces and branches](https://docs.mixpeek.com/docs/manage/namespaces.md): indexes, clones and budgets
* [Storage, tiering and backups](https://docs.mixpeek.com/docs/manage/storage.md): lifecycle states, snapshots and the storage format
* [Retrievers](https://docs.mixpeek.com/docs/retrieve/retrievers.md) and [Stages](https://docs.mixpeek.com/docs/retrieve/stages.md)
* [Upsert API](https://docs.mixpeek.com/docs/api-reference/byo-documents/upsert-documents-byo-vectors.md) and [Promote API](https://docs.mixpeek.com/docs/api-reference/byo-documents/promote-standalone-namespace-managed-mode.md)


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