Create kv
Creates a KV bucket and returns it.
POST /v1/kv/{bucket}
| Address | https://api.hanzo.ai/v1/kv/{bucket} |
| Method | POST |
| Operation | post_kv_by_bucket |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Creates a KV bucket and returns it. A bucket is keyed state on the same durable plane as the streams: each key holds up to History revisions, entries can expire by TTL, and watchers on the NATS port see every write. 409 when the org already has a bucket of that name.
Request
5 fields, body application/json (required).
| Field | In | Type | Required | Description |
|---|---|---|---|---|
bucket | path | string | yes | Bucket is the bucket's name within the org, from the path: 1–64 of [A-Za-z0-9_], no dash. |
bucket | body | string | — | Bucket is the bucket's name within the org, from the path: 1–64 of [A-Za-z0-9_], no dash. |
history | body | integer (int64) | — | History is how many revisions each key keeps, 1–64. |
maxValue | body | integer (int64) | — | MaxValue caps one value's size in bytes. |
ttl | body | integer (int64) | — | TTL expires entries after this many SECONDS. |
Response
| Status | Body | Meaning |
|---|---|---|
201 | kv.bucketRecord | created |
default | problem-details | refused |
201 body — 4 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
bucket | body | string | — | Bucket is the bucket's name within the org. |
history | body | integer (int64) | — | History is how many revisions each key keeps. |
ttl | body | integer (int64) | — | TTL is the entry expiry in seconds; 0 means none. |
values | body | integer (uint64) | — | Values is how many values the bucket holds right now. |
Failure carries the platform error shape — see Errors.
Examples
CLI
SDK
HTTP
MCP
hanzo kv add <bucket>.ts
.py
.go
.rs
.java
import { Configuration, KvApi } from 'hanzoai';
const api = new KvApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postKvByBucket({ bucket: 'bucket', bucket: "<bucket>", history: 0 });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import KvApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = KvApi(client).post_kv_by_bucket(bucket='bucket', bucket="<bucket>", history=0)cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.KvAPI.PostKvByBucket(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, kv_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = kv_api::post_kv_by_bucket(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.KvApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new KvApi(client).postKvByBucket();curl -X POST https://api.hanzo.ai/v1/kv/<bucket> \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"bucket": "<bucket>",
"history": 0
}'MCP reaches kv through the kv tool, which names its 6 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_kv"
}
}
}'Was this page useful?