Create indexes

Creates an index.

POST /v1/index/indexes

Addresshttps://api.hanzo.ai/v1/index/indexes
MethodPOST
Operationpost_index_indexes
AuthAuthorization: Bearer $HANZO_API_KEY

Creates an index.

Registers a named index in the caller's own org and answers the dialect's EnqueuedTask. It is idempotent: creating an index that already exists returns the same receipt and changes nothing, which is what lets a client create on startup without checking first.

primaryKey is optional — the first write establishes one when it is omitted. An index is a ROW here rather than a table, so an unusual uid is stored verbatim instead of being sanitised into a schema name.

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

Request

2 fields, body application/json (required).

FieldInTypeRequiredDescription
primaryKeybodystring—PrimaryKey is the document field that identifies a row.
uidbodystring—UID is the index's name within the org.

Response

StatusBodyMeaning
202index.indexEnqueuedaccepted
defaultproblem-detailsrefused

202 body — 5 fields.

FieldInTypeAlwaysDescription
enqueuedAtbodystring—EnqueuedAt is when the task was recorded, RFC 3339 — which is also when it completed.
indexUidbodystring—IndexUID names the index the write landed in.
statusbodystring—Status is always enqueued, for dialect compatibility.
taskUidbodyinteger (int64)—TaskUID identifies the task for a client that polls it.
typebodystring—Type is the dialect's name for the kind of write: indexCreation, indexDeletion, settingsUpdate, documentAdditionOrUpdate, documentDeletion.

Failure carries the platform error shape — see Errors.

Examples

hanzo index indexes create
import { Configuration, IndexApi } from 'hanzoai';

const api = new IndexApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postIndexIndexes({ primaryKey: "<primaryKey>", 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(primary_key="<primaryKey>", uid="<uid>")
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.IndexAPI.PostIndexIndexes(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(&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).postIndexIndexes();
curl -X POST https://api.hanzo.ai/v1/index/indexes \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "primaryKey": "<primaryKey>",
       "uid": "<uid>"
     }'

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?