Esc
ZeroIndex
GuidesAPI referenceSDKsChangelogOverviewBuy ZeroIndex

Add documents

View as MarkdownThe page as plain text

Add documents to an index. Documents with an existing primary key are replaced in full.

POST/v1/indexes/{uid}/documents

If the index does not exist, it is created with the default settings. Requires an admin key.

Path parameters

uidstringrequired

The name of the index.

Body

An array of documents, up to 1,000 documents or 10 MB per request.

[].idstring | integerrequired

The primary key. Use the field name you chose for the index if it is not id.

[].*any

Any other fields. Nested objects are flattened, so dimensions.width becomes its own field.

Errors

payload_too_large413

The request is over 10 MB. Split the documents into smaller batches.

invalid_request400

The body is not an array, or a document has no primary key.

Request

curl https://api.zeroindex.test/v1/indexes/products/documents \
  -H "Authorization: Bearer $ZEROINDEX_KEY" \
  -d '[
    { "id": 1042, "name": "Wireless headphones", "price": 129 },
    { "id": 1043, "name": "Desk lamp", "price": 59 }
  ]'
const task = await client.index("products").addDocuments([
  { id: 1042, name: "Wireless headphones", price: 129 },
  { id: 1043, name: "Desk lamp", price: 59 },
]);
task = client.index("products").add_documents([
    {"id": 1042, "name": "Wireless headphones", "price": 129},
    {"id": 1043, "name": "Desk lamp", "price": 59},
])

Response

202
{
  "taskUid": 8812,
  "indexUid": "products",
  "status": "enqueued",
  "type": "documentAdditionOrUpdate",
  "enqueuedAt": "2026-10-14T09:14:02Z"
}