Skip to content

Transactions API

The database uses transactions to maintain data consistency during batch operations. Transactions must be explicitly created, managed, and committed or aborted.

Create Transaction

Creates a new transaction for batch operations on a collection.

Endpoint: POST /vectordb/collections/{collection_id}/transactions

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection to create a transaction for.

Response:

{
"transaction_id": "123456789",
"created_at": "2023-08-15T14:30:45.123Z"
}

Response Fields:

FieldTypeDescription
transaction_idstringUnique identifier for the transaction.
created_atstringISO 8601 timestamp when the transaction was created.

Status Codes:

CodeDescription
200Success. Transaction created successfully.
400Bad Request. Collection not found or invalid parameters.
409Conflict. There is already an ongoing transaction for this collection.
500Server Error. Failed to create transaction.

Commit Transaction

Commits a transaction, making all changes permanent.

Endpoint: POST /vectordb/collections/{collection_id}/transactions/{transaction_id}/commit

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction to commit.

Status Codes:

CodeDescription
204No Content. Transaction committed successfully.
400Bad Request. Collection or transaction not found or invalid parameters.
500Server Error. Failed to commit transaction.

Abort Transaction

Aborts a transaction, discarding all changes.

Endpoint: POST /vectordb/collections/{collection_id}/transactions/{transaction_id}/abort

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction to abort.

Status Codes:

CodeDescription
204No Content. Transaction aborted successfully.
400Bad Request. Collection or transaction not found or invalid parameters.
500Server Error. Failed to abort transaction.

Add Vector to Transaction

Adds a single vector to a transaction.

Endpoint: POST /vectordb/collections/{collection_id}/transactions/{transaction_id}/vectors

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction to add the vector to.

Request Body:

{
"id": "vector_id",
"document_id": "optional_document_id",
"dense_values": [0.1, 0.2, 0.3, ...],
"sparse_values": null,
"text": "Optional text content"
}
{
"id": "vector_id",
"document_id": "optional_document_id",
"sparse_indices": [1, 5, 10, 100],
"sparse_values": [0.5, 0.3, 0.2, 0.1],
"text": "Optional text content"
}
{
"id": "vector_id",
"document_id": "optional_document_id",
"text": "Document text content for TF-IDF/BM25 indexing"
}

Request Parameters:

ParameterTypeRequiredDescription
idstringYesUnique identifier for the vector.
document_idstringNoOptional document identifier.
dense_valuesarrayNo*Dense vector values.
sparse_indicesarrayNo*Indices for sparse vector.
sparse_valuesarrayNo*Values for sparse vector.
textstringNo*Text content.

*At least one of dense_values, sparse_indices/sparse_values, or text must be provided for each vector.

Status Codes:

CodeDescription
200Success. Vector added to transaction successfully.
400Bad Request. Collection or transaction not found, or invalid vector data.
500Server Error. Failed to add vector to transaction.

Upsert Vectors in Transaction

Inserts or updates multiple vectors in a transaction in a single batch operation.

Endpoint: POST /vectordb/collections/{collection_id}/transactions/{transaction_id}/upsert

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction to upsert vectors in.

Request Body:

{
"vectors": [
{
"id": "vector_id_1",
"dense_values": [0.1, 0.2, 0.3, ...]
},
{
"id": "vector_id_2",
"sparse_indices": [1, 5, 10],
"sparse_values": [0.5, 0.3, 0.2]
},
{
"id": "vector_id_3",
"text": "Document text content"
}
]
}

Request Parameters:

ParameterTypeRequiredDescription
vectorsarrayYesArray of vector objects to upsert.
vectors[].idstringYesUnique identifier for each vector.
vectors[].document_idstringNoOptional document identifier for each vector.
vectors[].dense_valuesarrayNo*Dense vector values.
vectors[].sparse_indicesarrayNo*Indices for sparse vector.
vectors[].sparse_valuesarrayNo*Values for sparse vector.
vectors[].textstringNo*Text content.

*At least one of dense_values, sparse_indices/sparse_values, or text must be provided for each vector.

Status Codes:

CodeDescription
200Success. Vectors upserted successfully.
400Bad Request. Collection or transaction not found, or invalid vector data.
500Server Error. Failed to upsert vectors.

Delete Vector in Transaction

Deletes a vector from a transaction.

Endpoint: DELETE /vectordb/collections/{collection_id}/transactions/{transaction_id}/vectors/{vector_id}

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction containing the vector.
vector_idstringYesID of the vector to delete.

Status Codes:

CodeDescription
204No Content. Vector deleted successfully.
400Bad Request. Collection, transaction, or vector not found.
500Server Error. Failed to delete vector.