# Vector stores API

## GET /api/v1/admin/vector-stores

`GET /api/v1/admin/vector-stores` · operation `listVectorStoresAdmin`

Requires vector_stores and vector_stores:read. Administrators and viewers see every store; team roles see stores of their teams and stores shared with them. Includes the effective vector_stores settings.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Stores and limits | `application/json`: object |
| `404` | Feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `stores` (array of [VectorStoreAdmin](/docs/api/schemas/v/#vectorstoreadmin), required)
  - `vector_stores` ([VectorStoresSettings](/docs/api/schemas/v/#vectorstoressettings), required)


## POST /api/v1/admin/vector-stores

`POST /api/v1/admin/vector-stores` · operation `createVectorStoreAdmin`

Requires vector_stores:manage (admin, or team_admin of the owner team). Documents are added later with a key of that team.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `team` (string, required)
  - `name` (string, required, min length 1, max length 80)
  - `embedding_model` (string, required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | Created | `application/json`: [VectorStoreAdmin](/docs/api/schemas/v/#vectorstoreadmin) |
| `400` | Invalid body, or team_not_found | — |
| `403` | Team outside the session administration | — |
| `404` | Feature disabled | — |
| `409` | vector_store_limit | — |


## PUT /api/v1/admin/vector-stores/{id}/sharing

`PUT /api/v1/admin/vector-stores/{id}/sharing` · operation `shareVectorStoreAdmin`

Requires vector_stores:manage on the owner team. Replaces the list of teams that may list and search the store; they never write. Teams must be active and different from the owner.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `shared_with` (array of string, required, max items 64)
  - `version` (integer (int64), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Updated | `application/json`: [VectorStoreAdmin](/docs/api/schemas/v/#vectorstoreadmin) |
| `400` | team_not_found | — |
| `404` | Feature disabled or store not visible | — |
| `409` | version_conflict or vector_store_declared | — |


## DELETE /api/v1/admin/vector-stores/{id}

`DELETE /api/v1/admin/vector-stores/{id}` · operation `deleteVectorStoreAdmin`

Requires vector_stores:manage on the owner team. Audited.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Deleted | — |
| `404` | Feature disabled or store not visible | — |
| `409` | version_conflict or vector_store_declared | — |


## GET /api/v1/admin/vector-stores/{id}/documents

`GET /api/v1/admin/vector-stores/{id}/documents` · operation `listVectorStoreDocumentsAdmin`

Requires vector_stores:read.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Documents (same shape as the key API) | — |
| `404` | Feature disabled or store not visible | — |


## DELETE /api/v1/admin/vector-stores/{id}/documents/{doc_id}

`DELETE /api/v1/admin/vector-stores/{id}/documents/{doc_id}` · operation `deleteVectorStoreDocumentAdmin`

Requires vector_stores:manage on the owner team. Audited.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `doc_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Deleted | — |
| `404` | Feature disabled, store or document not visible | — |


## GET /v1/vector_stores

`GET /v1/vector_stores` · operation `listVectorStores`

Requires vector_store:read. Stores owned by the key team and stores shared with it; nothing else is listed.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Visible stores | `application/json`: object |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `object` (string, required, one of `"list"`)
  - `data` (array of [VectorStoreObject](/docs/api/schemas/v/#vectorstoreobject), required)
  - `has_more` (boolean)


## POST /v1/vector_stores

`POST /v1/vector_stores` · operation `createVectorStore`

Requires vector_stores and vector_store:write. Creates a store owned by the key team with a fixed embedding alias the key may use (ADR 0093). The id is generated (vs_ + 128 random bits). Unsupported OpenAI fields (file_ids, chunking_strategy, expires_after, metadata) are refused, not ignored.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |

**Request body** (required)

- `application/json`: object
  - `name` (string, required, min length 1, max length 80)
  - `embedding_model` (string, required) — Enabled alias with the embeddings capability
  - `file_ids` (array of string, max items 20) — Files (assistants or user_data) indexed into the new store as one batch; needs the batches flag. file_counts reports failures.
  - `chunking_strategy` ([VectorChunkingStrategy](/docs/api/schemas/v/#vectorchunkingstrategy))

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Vector store | `application/json`: [VectorStoreObject](/docs/api/schemas/v/#vectorstoreobject) |
| `400` | Invalid body or embedding model | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled | — |
| `409` | vector_store_limit: max_stores_per_team | — |


## GET /v1/vector_stores/{id}

`GET /v1/vector_stores/{id}` · operation `getVectorStore`

Requires vector_store:read. Sharing details are shown only to the owner team.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Vector store | `application/json`: [VectorStoreObject](/docs/api/schemas/v/#vectorstoreobject) |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |


## DELETE /v1/vector_stores/{id}

`DELETE /v1/vector_stores/{id}` · operation `deleteVectorStore`

Requires vector_store:write and the owner team. Removes documents and chunks. Stores declared in YAML answer 409 vector_store_declared.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Deleted (object vector_store.deleted) | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |
| `409` | vector_store_declared | — |


## POST /v1/vector_stores/{id}/file_batches

`POST /v1/vector_stores/{id}/file_batches` · operation `createVectorStoreFileBatch`

OpenAI-compatible. Requires vector_stores, batches, vector_store:write and the owner team. Indexes up to 20 files within the request, one by one as the caller; each file is a document or a failure with its error code (file_not_found, unsupported_file, file_too_large, quota_exceeded...). Returns completed with file_counts.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Request body** (required)

- `application/json`: object
  - `file_ids` (array of string, required, min items 1, max items 20)
  - `attributes` (object)
  - `chunking_strategy` ([VectorChunkingStrategy](/docs/api/schemas/v/#vectorchunkingstrategy))

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Finished batch | `application/json`: [VectorStoreFilesBatch](/docs/api/schemas/v/#vectorstorefilesbatch) |
| `400` | Invalid body, duplicate IDs or more than 20 files | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden or team_required | — |
| `404` | Feature disabled or store not writable by the key's team | — |


## GET /v1/vector_stores/{id}/file_batches/{batch_id}

`GET /v1/vector_stores/{id}/file_batches/{batch_id}` · operation `getVectorStoreFileBatch`

OpenAI-compatible. Requires vector_store:read.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `batch_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Batch | `application/json`: [VectorStoreFilesBatch](/docs/api/schemas/v/#vectorstorefilesbatch) |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled, store not visible or unknown batch | — |


## POST /v1/vector_stores/{id}/file_batches/{batch_id}/cancel

`POST /v1/vector_stores/{id}/file_batches/{batch_id}/cancel` · operation `cancelVectorStoreFileBatch`

OpenAI-compatible. Batches finish within their request, so nothing is ever left to cancel; returns the final batch. Requires vector_store:write.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `batch_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Batch | `application/json`: [VectorStoreFilesBatch](/docs/api/schemas/v/#vectorstorefilesbatch) |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled, store not visible or unknown batch | — |


## GET /v1/vector_stores/{id}/file_batches/{batch_id}/files

`GET /v1/vector_stores/{id}/file_batches/{batch_id}/files` · operation `listVectorStoreFileBatchFiles`

OpenAI-compatible. Files of a batch: completed ones as vector_store.file, failed ones with last_error.code. Requires vector_store:read.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `batch_id` | path | string, required, max length 64 |  |
| `filter` | query | string, one of `"completed"`, `"failed"` |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | List of vector_store.file | — |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled, store not visible or unknown batch | — |


## GET /v1/vector_stores/{id}/files

`GET /v1/vector_stores/{id}/files` · operation `listVectorStoreFiles`

OpenAI-compatible. Requires vector_store:read; documents that came from files.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | List of vector_store.file | `application/json`: object |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled or store not visible | — |

Response `200` fields:

- `application/json`: object
  - `object` (`"list"`)
  - `data` (array of [VectorStoreFile](/docs/api/schemas/v/#vectorstorefile))
  - `first_id` (string or null)
  - `last_id` (string or null)
  - `has_more` (boolean)


## POST /v1/vector_stores/{id}/files

`POST /v1/vector_stores/{id}/files` · operation `attachVectorStoreFile`

OpenAI-compatible. Requires vector_stores, batches (files), vector_store:write and the owner team. Indexes a file of the key team uploaded with purpose assistants or user_data: text formats (txt, md, csv, json, html with scripts and tags removed, source code) up to 1 MiB, or PDF and images up to 20 MiB through vector_stores.ocr_model, called as the same key (route:ocr and the OCR alias needed); without an OCR model they return 415. Chunked and embedded as the caller like a text document. Attaching the same file again returns the existing object without new embeddings.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Request body** (required)

- `application/json`: object
  - `file_id` (string, required)
  - `attributes` (object)
    - any other key: string or number or boolean
      - One of (1): string
      - One of (2): number
      - One of (3): boolean
  - `chunking_strategy` ([VectorChunkingStrategy](/docs/api/schemas/v/#vectorchunkingstrategy))

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | vector_store.file with status completed | `application/json`: [VectorStoreFile](/docs/api/schemas/v/#vectorstorefile) |
| `400` | Invalid body or chunking strategy | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required or model_forbidden | — |
| `404` | Feature disabled, store not visible, or file_not_found (another team's file, wrong purpose or expired get the same answer) | — |
| `409` | vector_store_limit or embedding_dimension_mismatch | — |
| `413` | file_too_large: more than 1 MiB | — |
| `415` | unsupported_file: not a text format, not UTF-8 or empty | — |


## GET /v1/vector_stores/{id}/files/{file_id}

`GET /v1/vector_stores/{id}/files/{file_id}` · operation `getVectorStoreFile`

OpenAI-compatible. Requires vector_store:read.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `file_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | vector_store.file | `application/json`: [VectorStoreFile](/docs/api/schemas/v/#vectorstorefile) |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled, store not visible or file not in the store | — |


## DELETE /v1/vector_stores/{id}/files/{file_id}

`DELETE /v1/vector_stores/{id}/files/{file_id}` · operation `deleteVectorStoreFile`

OpenAI-compatible. Requires vector_store:write and the owner team. Removes the document and its chunks; the uploaded file itself stays in /v1/files.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `file_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Deletion | `application/json`: object |
| `401` | Missing or invalid key | — |
| `404` | Feature disabled, store not visible to a writer or file not in the store | — |

Response `200` fields:

- `application/json`: object
  - `id` (string)
  - `object` (`"vector_store.file.deleted"`)
  - `deleted` (`true`)


## GET /v1/vector_stores/{id}/documents

`GET /v1/vector_stores/{id}/documents` · operation `listVectorStoreDocuments`

Requires vector_store:read.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Documents | `application/json`: object |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |

Response `200` fields:

- `application/json`: object
  - `object` (string, required, one of `"list"`)
  - `data` (array of [VectorStoreDocument](/docs/api/schemas/v/#vectorstoredocument), required)
  - `has_more` (boolean)


## POST /v1/vector_stores/{id}/documents

`POST /v1/vector_stores/{id}/documents` · operation `addVectorStoreDocument`

Requires vector_store:write and the owner team (shared teams never write). Chunks the text in the gateway and embeds it through this gateway's /v1/embeddings with the same key, so model allowlist, quotas, budgets and the usage ledger apply; a refusal there is returned as is. Limits are checked before any embedding is spent and again under the store lock.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Request body** (required)

- `application/json`: object
  - `title` (string, required, min length 1, max length 200)
  - `text` (string, required) — UTF-8, at most 1 MiB
  - `attributes` (object)
    - any other key: string or number or boolean
      - One of (1): string
      - One of (2): number
      - One of (3): boolean

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Stored document | `application/json`: [VectorStoreDocument](/docs/api/schemas/v/#vectorstoredocument) |
| `400` | Invalid body | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |
| `409` | vector_store_limit, or embedding_dimension_mismatch when the alias now returns another dimension | — |
| `502` | embedding_invalid: unexpected, zero or non-finite vectors | — |


## DELETE /v1/vector_stores/{id}/documents/{doc_id}

`DELETE /v1/vector_stores/{id}/documents/{doc_id}` · operation `deleteVectorStoreDocument`

Requires vector_store:write and the owner team.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |
| `doc_id` | path | string, required, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Deleted (object vector_store.document.deleted) | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |


## POST /v1/vector_stores/{id}/search

`POST /v1/vector_stores/{id}/search` · operation `searchVectorStore`

Requires vector_store:read; owner or shared team. Embeds the query with the store model through /v1/embeddings (same key, ledger and quotas) and ranks chunks by cosine similarity in PostgreSQL; the visibility check is part of the ranking query. Response shape follows the OpenAI vector store search. filters and rewrite_query are refused (422) rather than ignored.

**Authentication:** `bearerAuth`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-Request-Id` | header | string, max length 128 | Correlation ID echoed in the response and forwarded upstream when valid. |
| `traceparent` | header | string | W3C trace context. Invalid values create a new trace. |
| `id` | path | string, required, max length 64 |  |

**Request body** (required)

- `application/json`: object
  - `query` (string, required, min length 1, max length 2000)
  - `max_num_results` (integer, default `10`, min 1, max 20)
  - `rewrite_query` (boolean, one of `false`)
  - `filters` (null)
  - `ranking_options` (object)
    - `ranker` (string, one of `"auto"`, `"none"`)
    - `score_threshold` (number, min 0, max 1)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Search results | `application/json`: object |
| `400` | Invalid query | — |
| `401` | Missing or invalid key | — |
| `403` | scope_forbidden, team_required (key without team) or model_forbidden | — |
| `404` | Feature disabled, or a store that does not exist or is not visible to the key's team (same answer) | — |
| `409` | embedding_dimension_mismatch | — |
| `422` | unsupported_search_option | — |

Response `200` fields:

- `application/json`: object
  - `object` (string, required, one of `"vector_store.search_results.page"`)
  - `search_query` (array of string, required)
  - `has_more` (boolean)
  - `next_page` (null)
  - `data` (array of object, required)
    - `file_id` (string, required)
    - `filename` (string, required)
    - `score` (number, required)
    - `attributes` (object)
    - `content` (array of object, required)
      - `type` (string, one of `"text"`)
      - `text` (string)

