Skip to main content

Upsert Vector

Insert or update a single vector. If a vector with the same external_id already exists in the collection, it is updated.

POST /v1/collections/{name}/upsert

Request

Headers:

x-api-key: your-api-key
Content-Type: application/json

Path Parameters:

ParameterDescription
nameCollection name

Body:

FieldTypeRequiredDescription
external_idstringUnique identifier for this vector within the collection
vectorfloat[]Array of floats. Length must match the collection's dim. Either vector or text must be provided. If both are given, vector takes precedence.
textstringPlain text to embed. The backend generates a vector using the configured embedding model. Either text or vector must be provided. If both are given, vector takes precedence.
metadataobjectArbitrary JSON metadata attached to the vector
include_timingbooleanDefault: false. When true, the response includes a timing_ms object with embedding_ms, storage_ms, and total_ms breakdowns.

Examples

With vector:

curl -X POST http://localhost:8000/v1/collections/articles/upsert \
-H "x-api-key: test-key" \
-H "Content-Type: application/json" \
-d '{
"external_id": "doc-1",
"vector": [0.1, 0.2, 0.3, 0.4],
"metadata": {"title": "Hello World", "author": "Alice"}
}'

With text and timing:

curl -X POST http://localhost:8000/v1/collections/articles/upsert \
-H "x-api-key: test-key" \
-H "Content-Type: application/json" \
-d '{
"external_id": "doc-1",
"text": "Getting started with vector databases",
"metadata": {"title": "Getting started", "author": "Alice"},
"include_timing": true
}'

Response

{
"status": "success",
"data": {
"external_id": "doc-1",
"status": "inserted"
}
}

With timing:

{
"status": "success",
"data": {
"external_id": "doc-1",
"status": "inserted",
"timing_ms": {
"embedding_ms": 12.4,
"storage_ms": 3.1,
"total_ms": 15.5
}
}
}

The status field is "inserted" for new vectors and "updated" for existing ones.

Errors

CodeReason
400Vector dimension doesn't match collection dimension
404Collection not found
401Missing or invalid API key
403API key does not have write permission