Storage

Apply JSON Patch to Storage

Changed on

Applies a sequence of JSON Patch operations to the room's Storage document, useful for modifying Storage. Operations are applied in order; if any operation fails, the document is not changed and a 422 response with a helpful message is returned.

Paths and data types: Be as specific as possible with your target path. Every parent in the chain of path segments must be a LiveObject, LiveList, or LiveMap. Complex nested objects passed in add or replace operations are automatically converted to LiveObjects and LiveLists. LiveText is a leaf node: only the LiveText node itself is addressable, not fields under its serialized data. Use replace with a string or a LiveTextData array to replace the whole node, for example /text with [["Hello"]]; use remove on /text to remove the node. LiveText versioning is internal and is not part of this API.

Performance: For large Storage documents, applying a patch can be expensive because the full state is reconstructed on the server to apply the operations. Very large documents may not be suitable for this endpoint.

For a full guide with examples, see Modifying storage via REST API with JSON Patch.

patch/rooms/{roomId}/storage/json-patch

Request

  • Base URL: https://api.liveblocks.io/v2
  • URL: https://api.liveblocks.io/v2/rooms/{roomId}/storage/json-patch
  • Auth: none declared

Path parameters

roomIdstring required

ID of the room

Example:my-room-id

Request body

Example request

[
  {
    "op": "add",
    "path": "/score",
    "value": 42
  },
  {
    "op": "remove",
    "path": "/oldKey"
  }
]

Response

Success. All operations were applied; the Storage document was updated.

Changes

    • breaking

      the request property type changed from object to no type

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property /

    • warning

      removed the request property /

    • info

      api operation id patch-rooms-roomId-storage-json-patch removed and replaced with patch-storage-document

    • info

      added subschema #1: AddJsonPatchOperation subschema #2: RemoveJsonPatchOperation subschema #3: ReplaceJsonPatchOperation subschema #4: CopyJsonPatchOperation subschema #5: MoveJsonPatchOperation subschema #6: TestJsonPatchOperation to the request property oneOf list

    • info

      endpoint added