Liveblocks icon

Liveblocks

Call the Liveblocks REST API (rooms, comments, feeds, Yjs, AI, and more)

Room → Upsert

AI-generated

Summary

Create or update a Liveblocks room by specifying its ID, access permissions, and metadata. Optionally, define default accesses and specify access entries for users and groups during update.

Inputs

  • Room ID (required) — Identifier of the Liveblocks room to upsert.
  • Clear Default Accesses — Whether to clear existing default accesses for the room.
  • Default Accesses — Set default permissions for the room such as read, write, presence write, and comments write.
  • Users Access (update) — List of user or group access entries specifying user/group IDs, permissions to grant, or flags to clear access for each ID on update.
  • Groups Access (update) — List of group access entries similar to user access for granting or clearing permissions on update.
  • Metadata (update) — JSON object containing metadata fields to update on the room.
  • Create Branch — Optional JSON object with fields used only when creating a new room. Must include an array of default accesses and may include organizationId, usersAccesses, groupsAccesses, and metadata.
  • Include Request in Error — Whether to include detailed request data in error messages to aid debugging.

Output shape

a JSON object representing the created or updated Liveblocks room resource.

If the room exists, its properties and access controls update according to provided parameters; otherwise, a new room is created using the specified 'Create Branch' data. Returned data structure follows the Liveblocks API response for room upsert operations. Errors can optionally include request context if enabled.

Examples

Example 1: Upsert a room to set default accesses and update specific user permissions.

Provide roomId, clearDefaultAccesses set to true, specify defaultAccesses array, and add entries in usersAccessEntries with subjectId and permissions.

Links

Discussion