Initialize Storage document
Changed onThis endpoint initializes or reinitializes a room’s Storage. The room must already exist. Calling this endpoint will disconnect all users from the room if there are any, triggering a reconnect. Corresponds to liveblocks.initializeStorageDocument.
The format of the request body is the same as what’s returned by the get Storage endpoint.
For each Liveblocks data structure that you want to create, you need a JSON element having two properties:
- "liveblocksType" => "LiveObject" | "LiveList" | "LiveMap" | "LiveFile"
- "data" => contains the nested data structures (children) and data.
The root’s type can only be LiveObject.
A utility function, toPlainLson is included in @liveblocks/client from 1.0.9 to help convert LiveObject, LiveList, LiveMap, and LiveFile to the structure expected by the endpoint.
Request
- Base URL: https://api.liveblocks.io/v2
- URL: https://api.liveblocks.io/v2/rooms/{roomId}/storage
- Auth: none declared
Path parameters
ID of the room
Request body
Response
Success. The Storage is initialized. Returns the room’s Storage as JSON.
Example response
{
"liveblocksType": "LiveObject",
"data": {
"aLiveObject": {
"liveblocksType": "LiveObject",
"data": {
"a": 1
}
},
"aLiveList": {
"liveblocksType": "LiveList",
"data": [
"a",
"b"
]
},
"aLiveFile": {
"liveblocksType": "LiveFile",
"data": {
"id": "fl_abc123456789012345678",
"name": "photo.png",
"size": 12345,
"mimeType": "image/png"
}
}
}
}Changes
- breaking
request body became required
- breaking
the request property
became required - breaking
the request property
became required
- breaking
- breaking
the
request property const valueLiveObjectwas added - breaking
the
response's property type changed fromstringobjecttoobjectfor status - info
api operation id
post-rooms-roomId-storageremoved and replaced withinitialize-storage-document - info
the
response property const valueLiveObjectwas added for the status
- breaking