Skip to content
Hoody.com

KV Store: Batch Operations

Batch operations let you read, write, and delete up to 100 keys in a single round trip. Use these endpoints when you need to populate a cache, hydrate many records at once, or tear down a set of related keys atomically. Each operation runs inside a single transaction, so partial failures are not possible: either all keys are processed or the request is rejected.

All endpoints accept a db query parameter to target a specific SQLite database file and an optional table query parameter (default kv_store) for directory-mode stores.

POST /api/v1/sqlite/kv/batch/get

Retrieve values for multiple keys in a single request (max 100 keys).

NameInTypeRequiredDescription
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)

The request body references the kvBatchGetRequest schema.

FieldTypeRequiredDescription
keysarray of stringYesKeys to retrieve. 1-100 entries; no entry may be empty or whitespace-only.
{
"values": {
"user:1": "Alice",
"user:2": "Bob",
"session:abc": null
}
}
Terminal window
curl -X POST 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com/api/v1/sqlite/kv/batch/get?db=app.db' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"keys": ["user:1", "user:2", "session:abc"]}'
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.batchGet(
{ keys: ['user:1', 'user:2', 'session:abc'] },
{ db: 'app.db' }
);

POST /api/v1/sqlite/kv/batch/set

Store values for multiple keys in a single transaction (max 100 items).

NameInTypeRequiredDescription
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)

The request body references the kvBatchSetRequest schema. The top-level shape is:

FieldTypeRequiredDescription
itemsarray of objectYesItems to write in a single transaction. 1-100 entries.

Each entry in items follows the kvBatchSetItem schema:

FieldTypeRequiredDescription
keystringYesKey to write. Must not be empty or whitespace-only.
valuestringNoValue to store.
content_typestringNoContent type recorded alongside the value. Defaults to application/octet-stream.
ttlintegerNoLifetime in seconds from now. 0 or omitted stores without expiry; negative is rejected. Minimum: 0.
{
"stored": 3
}
Terminal window
curl -X POST 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com/api/v1/sqlite/kv/batch/set?db=app.db' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
"items": [
{ "key": "user:1", "value": "Alice", "content_type": "text/plain" },
{ "key": "user:2", "value": "Bob", "ttl": 3600 },
{ "key": "config:theme", "value": "dark" }
]
}'
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.batchSet(
{
items: [
{ key: 'user:1', value: 'Alice', content_type: 'text/plain' },
{ key: 'user:2', value: 'Bob', ttl: 3600 },
{ key: 'config:theme', value: 'dark' }
]
},
{ db: 'app.db' }
);

POST /api/v1/sqlite/kv/batch/delete

Delete multiple keys in a single transaction (max 100 keys).

NameInTypeRequiredDescription
dbquerystringYesDatabase file path
tablequerystringNoCustom table name (default: kv_store)

The request body references the kvBatchDeleteRequest schema.

FieldTypeRequiredDescription
keysarray of stringYesKeys to delete. 1-100 entries; no entry may be empty or whitespace-only.
{
"deleted": 3
}
Terminal window
curl -X POST 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com/api/v1/sqlite/kv/batch/delete?db=app.db' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{"keys": ["user:1", "user:2", "session:abc"]}'
import { HoodyClient } from 'hoody-sdk';
const client = new HoodyClient({ baseURL: 'https://{projectId}-{containerId}-sqlite-1.{server}.containers.hoody.com', token: process.env.HOODY_TOKEN });
await client.sqlite.kvStore.batchDelete(
{ keys: ['user:1', 'user:2', 'session:abc'] },
{ db: 'app.db' }
);