Skip to main content
POST /{index_id}/upsert Inserts a new vector or updates an existing one in the specified index.

Request Body

FieldTypeRequiredDescription
idstringNoA unique identifier for the vector. If not provided, one will be auto-generated.
embeddingarrayYesAn array of floating-point numbers representing the vector.
metadataobjectNoAssociated key-value metadata.
delete_protectionbooleanNoIf true, prevents the vector from being deleted.

Example Requests

  • cURL
  • Python SDK
  • JavaScript SDK
curl --location 'https://api.gravixlayer.com/v1/vectors/indexes/bf93acdc/upsert' \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --data '{
    "vectors": [
      {
        "id": "vec_001",
        "embedding": [0.1, 0.2, 0.3, "... (1536 floats total)"],
        "metadata": { "category": "finance", "document_id": "doc_123" },
        "delete_protection": true
      }
    ]
  }'

Response

A summary of the upsert operation.
{
  "upserted_count": 2,
  "failed_count": 0
}
I