Appearance
Bulk write records
POST /v4/storage/{storage}/write
Write one or more records to a namespace. The path parameter storage specifies which namespace to write to.
Request body
Array of Record objects:
| Field | Type | Description |
|---|---|---|
| key | string | Required. The key for the record. Writing existing key will overwrite previous key's value. |
| value | any | Optional. The value associated with the key. Omitting value will clear value of the key, returning key without value on reading. |
| binary | boolean | Optional. Whether the value is binary data. Defaults to false. |
Response schema
| Field | Type | Description |
|---|---|---|
| tx | integer<int64> | Transaction ID of the write operation. |
| duration | string | Time taken to process the write request, returned in a human-readable format (e.g., "1.234567ms"). |
Example
sh
curl --location 'https://api.litebase.io/v4/storage/sample/write' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $LITEBASE_API_KEY" \
--data '[
{
"key": "city:1",
"value": {
"name": "Braavos"
}
},
{
"key": "city:2",
"value": {
"name": "Oldtown"
}
}
]'Response:
json
HTTP/1.1 200 OK
Content-Type: application/json
{
"tx": 1,
"duration": "3.370413ms"
}Clear record value
Omitting value will clear value of the key:
sh
curl --location 'https://api.litebase.io/v4/storage/sample/write' \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $LITEBASE_API_KEY" \
--data '[
{
"key": "city:1"
}
]'Response:
json
HTTP/1.1 200 OK
Content-Type: application/json
{
"tx": 2,
"duration": "1.0413ms"
}Supported types of value
Litebase accepts below JSON types:
- string
- number
- JSON object
- array
- boolean
- null