Skip to content

Transactions API

Cosdata uses transactions (atomic operations) for batch operations. This is ideal for importing large, logically cohesive datasets where partial imports would compromise data integrity.

Transactions are managed resources with a defined lifecycle: open → operate → commit/abort. They provide all-or-nothing semantics with rollback capability. All data modifications within a transaction are buffered and applied in a single atomic operation upon commit.

Commit = atomic

Indexing = background process

Once a transaction is committed, the system begins indexing the data in the background. You can monitor the progress of a transaction using the status endpoint.

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 an ongoing transaction for this collection.
500Server Error. Failed to create transaction.

Get Transaction Status

Gets the current status of a transaction, which is useful for monitoring the progress of background indexing after commit.

Endpoint: GET /vectordb/collections/{collection_id}/transactions/{transaction_id}/status

URL Parameters:

ParameterTypeRequiredDescription
collection_idstringYesID (name) of the collection containing the transaction.
transaction_idstringYesID of the transaction to get the status for.

Response:

{
"status": {
"Complete": {
"started_at": "2023-01-01T12:00:00Z",
"completed_at": "2023-01-01T12:00:00Z",
"stats": {
"records_upserted": 1000,
"records_deleted": 0,
"total_operations": 5,
"percentage_complete": 100.0,
"processing_time_seconds": 120,
"average_throughput": 8.33,
"version_created": 42
}
}
}
}

Status Codes:

CodeDescription
200Success. Transaction status retrieved successfully.
400Bad Request. Collection or transaction not found.
404Not Found. Transaction not found.
500Server Error. Failed to get transaction status.

Commit Transaction

Commits a transaction, making all changes permanent. The commit is atomic. Use the Get Transaction Status endpoint to monitor background indexing progress.

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 commit accepted for processing.
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",
"metadata": { "key": "value" }
}
{
"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",
"metadata": { "key": "value" }
}
{
"id": "vector_id",
"document_id": "optional_document_id",
"text": "Document text content for TF-IDF/BM25 indexing",
"metadata": { "key": "value" }
}

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.
metadataobjectNoOptional key-value metadata.

*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.
vectors[].metadataobjectNoOptional key-value metadata for each vector.

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