Skip to content

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:

FieldTypeDescription
keystringRequired. The key for the record. Writing existing key will overwrite previous key's value.
valueanyOptional. The value associated with the key. Omitting value will clear value of the key, returning key without value on reading.
binarybooleanOptional. Whether the value is binary data. Defaults to false.

Response schema ​

FieldTypeDescription
txinteger<int64>Transaction ID of the write operation.
durationstringTime 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