Create documents

Writes documents into the caller's own index, keyed by the index's primary key: a document whose key is already present is REPLACED whole.

POST /v1/index/indexes/{uid}/documents

Addresshttps://api.hanzo.ai/v1/index/indexes/{uid}/documents
MethodPOST
Operationpost_index_indexes_by_uid_documents
AuthAuthorization: Bearer $HANZO_API_KEY

Writes documents into the caller's own index, keyed by the index's primary key: a document whose key is already present is REPLACED whole. The body is the dialect's own — an array of documents, or a single document — and each is stored verbatim, so a read gives back exactly what was written.

The index is CREATED when it is missing rather than refused, because a Meilisearch client writes before it configures.

The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header, so two orgs may both hold an index named "messages" and neither can see the other's documents. Without a validated principal the answer is 403 carrying the dialect's invalid_api_key body.

The 202 and its enqueued task are DIALECT COMPATIBILITY, not a promise of later work: the documents are searchable when this answers, and a client that polls waitForTask resolves immediately.

Request

2 fields, body application/json.

FieldInTypeRequiredDescription
uidpathstringyes
(body)bodyany[] | objectyes

Response

StatusBodyMeaning
2XXindexEnqueuedSuccess

2XX body — 5 fields.

FieldInTypeAlwaysDescription
enqueuedAtbodystring—
indexUidbodystring—
statusbodystring—
taskUidbodyinteger—
typebodystring—

Failure carries the platform error shape — see Errors.

Examples

hanzo index indexes documents create <uid>
import { Configuration, IndexApi } from 'hanzoai';

const api = new IndexApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postIndexIndexesByUidDocuments({ uid: 'uid' });
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import IndexApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = IndexApi(client).post_index_indexes_by_uid_documents(uid='uid')
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.IndexAPI.PostIndexIndexesByUidDocuments(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, index_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = index_api::post_index_indexes_by_uid_documents(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.IndexApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new IndexApi(client).postIndexIndexesByUidDocuments();
curl -X POST https://api.hanzo.ai/v1/index/indexes/<uid>/documents \
  -H "Authorization: Bearer $HANZO_API_KEY"

MCP reaches index through the index tool, which names its 14 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "get_index_health"
         }
       }
     }'

Index API · All Hanzo APIs · Interactive reference

Was this page useful?