Creates a KV bucket and returns it.
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…
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 | — | History is how many revisions each key keeps, 1–64. |
maxValue | body | integer | — | MaxValue caps one value's size in bytes. |
ttl | body | integer | — | TTL expires entries after this many SECONDS. |
Response
| Status | Body | Meaning |
|---|---|---|
201 | bucketRecord | created |
201 body — 4 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
bucket | body | string | — | Bucket is the bucket's name within the org. |
history | body | integer | — | History is how many revisions each key keeps. |
ttl | body | integer | — | TTL is the entry expiry in seconds; 0 means none. |
values | body | integer | — | Values is how many values the bucket holds right now. |
Failure carries the platform error shape — see Errors.
Examples
hanzo has no subcommand for this operation — the CLI serves only what cloud's live route table confirms. Use HTTP or an SDK.
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 := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.KvAPI.PostKvByBucket(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::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.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new KvApi(client).postKvByBucket();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
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
}'The door declares no tool for kv — tools/list on https://api.hanzo.ai/v1/mcp names the products it does reach. Use HTTP or an SDK.
How is this guide?