POST
/
v1
/
vectors
/
upsert
Add new vectors or update existing ones in the encrypted index.

Authentication

Required - API key via X-API-Key header:
X-API-Key: cyborg_your_api_key_here
You can get an API key from the CyborgDB Admin Dashboard. For more info, follow this guide.

Request Body

{
  "index_name": "my_index",
  "index_key": "64_character_hex_string_representing_32_bytes",
  "items": [
    {
      "id": "item_1",
      "vector": [0.1, 0.2, 0.3, 0.4],
      "contents": "Hello world!",
      "metadata": {"category": "greeting", "language": "en"}
    },
    {
      "id": "item_2",
      "vector": [0.5, 0.6, 0.7, 0.8],
      "contents": "Bonjour monde!",
      "metadata": {"category": "greeting", "language": "fr"}
    }
  ]
}

Response

{
  "status": "success",
  "message": "2 items upserted successfully"
}

Exceptions

  • 401: Authentication failed (invalid API key)
  • 404: Index not found
  • 422: Invalid request parameters or vector dimensions
  • 500: Internal server error

Example Usage

Basic Upsert:
curl -X POST "http://localhost:8000/v1/vectors/upsert" \
     -H "X-API-Key: cyborg_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{
       "index_name": "my_index",
       "index_key": "your_64_character_hex_key_here",
       "items": [
         {
           "id": "item_1",
           "vector": [0.1, 0.2, 0.3, 0.4],
           "contents": "Hello world!"
         }
       ]
     }'
With Metadata:
curl -X POST "http://localhost:8000/v1/vectors/upsert" \
     -H "X-API-Key: cyborg_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{
       "index_name": "my_index",
       "index_key": "your_64_character_hex_key_here",
       "items": [
         {
           "id": "doc_1",
           "vector": [0.1, 0.2, 0.3, 0.4],
           "contents": "Important document content",
           "metadata": {
             "category": "documentation",
             "author": "admin",
             "created": "2024-01-15",
             "priority": "high"
           }
         }
       ]
     }'
Auto-Generated Embeddings:
# For indexes created with embedding_model
curl -X POST "http://localhost:8000/v1/vectors/upsert" \
     -H "X-API-Key: cyborg_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{
       "index_name": "semantic_index",
       "index_key": "your_64_character_hex_key_here",
       "items": [
         {
           "id": "text_1",
           "contents": "This text will be automatically embedded",
           "metadata": {"type": "auto_embedded"}
         }
       ]
     }'
Batch Upsert:
curl -X POST "http://localhost:8000/v1/vectors/upsert" \
     -H "X-API-Key: cyborg_your_api_key_here" \
     -H "Content-Type: application/json" \
     -d '{
       "index_name": "my_index",
       "index_key": "your_64_character_hex_key_here",
       "items": [
         {"id": "batch_1", "vector": [0.1, 0.2, 0.3]},
         {"id": "batch_2", "vector": [0.4, 0.5, 0.6]},
         {"id": "batch_3", "vector": [0.7, 0.8, 0.9]},
         {"id": "batch_4", "vector": [0.2, 0.3, 0.4]},
         {"id": "batch_5", "vector": [0.5, 0.6, 0.7]}
       ]
     }'
When embedding_model is configured for the index, the vector parameter becomes optional. If provided, it will be used directly; if omitted, a vector will be auto-generated from the contents field.
For large datasets, use batch upserts with multiple items in a single request to improve performance and reduce network overhead.