Liveblocks REST API
Liveblocks REST API allows developers to interact programmatically with their Liveblocks account and services using HTTP requests. With the API, developers can retrieve, set, and update room-related data, users, permissions, schemas, and more. The Liveblocks API is organized around REST.
The API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
To use the API endpoints, you need to add your secret key to the request’s authorization header. Except for the public authorization endpoint.
Auth
This endpoint lets your application server (your back end) obtain a token that one of its clients (your frontend) can use to enter a Liveblocks room. You use this endpoint to implement your own application’s custom authentication endpoint. When making this request, you’ll have to use your secret key.
Important: The difference with an ID token is that an access token holds all the permissions, and is the source of truth. With ID tokens, permissions are set in the Liveblocks back end (through REST API calls) and "checked at the door" every time they are used to enter a room.
Note: When using the @liveblocks/node package, you can use Liveblocks.prepareSession in your back end to build this request.
You can pass the property userId in the request’s body. This can be whatever internal identifier you use for your user accounts as long as it uniquely identifies an account. The property userId is used by Liveblocks to calculate your account’s Monthly Active Users. One unique userId corresponds to one MAU.
Additionally, you can set custom metadata to the token, which will be publicly accessible by other clients through the user.info property. This is useful for storing static data like avatar images or the user’s display name.
Lastly, you’ll specify the exact permissions to give to the user using the permissions field. This is done in an object where the keys are room names, or room name patterns (ending in a *), and a list of permissions to assign the user for any room that matches that name exactly (or starts with the pattern’s prefix). For tips, see Manage permissions with access tokens.
Request body
Response
Success. Returns an access token that can be used to enter one or more rooms.
Get ID token with secret key
This endpoint lets your application server (your back end) obtain a token that one of its clients (your frontend) can use to enter a Liveblocks room. You use this endpoint to implement your own application’s custom authentication endpoint. When using this endpoint to obtain ID tokens, you should manage your permissions by assigning user and/or group permissions to rooms explicitly, see our Manage permissions with ID tokens section.
Important: The difference with an access token is that an ID token doesn’t hold any permissions itself. With ID tokens, permissions are set in the Liveblocks back end (through REST API calls) and "checked at the door" every time they are used to enter a room. With access tokens, all permissions are set in the token itself, and thus controlled from your back end entirely.
Note: When using the @liveblocks/node package, you can use Liveblocks.identifyUser in your back end to build this request.
You can pass the property userId in the request’s body. This can be whatever internal identifier you use for your user accounts as long as it uniquely identifies an account. The property userId is used by Liveblocks to calculate your account’s Monthly Active Users. One unique userId corresponds to one MAU.
If you want to use group permissions, you can also declare which groupIds this user belongs to. The group ID values are yours, but they will have to match the group IDs you assign permissions to when assigning permissions to rooms, see Manage permissions with ID tokens).
Additionally, you can set custom metadata to the token, which will be publicly accessible by other clients through the user.info property. This is useful for storing static data like avatar images or the user’s display name.
Request body
Response
Success. Returns an ID token that can be used to enter one or more rooms.
Room
Get rooms
This endpoint returns a list of your rooms. The rooms are returned sorted by creation date, from newest to oldest. You can filter rooms by room ID prefixes, metadata, users accesses, and groups accesses. Corresponds to liveblocks.getRooms.
There is a pagination system where the cursor to the next page is returned in the response as nextCursor, which can be combined with startingAfter.
You can also limit the number of rooms by query.
Filtering by metadata works by giving key values like metadata.color=red. Of course you can combine multiple metadata clauses to refine the response like metadata.color=red&metadata.type=text. Notice here the operator AND is applied between each clauses.
Filtering by groups or userId works by giving a list of groups like groupIds=marketing,GZo7tQ,product or/and a userId like userId=user1.
Notice here the operator OR is applied between each groupIds and the userId.
Parameters
limitoptionalA limit on the number of rooms to be returned. The limit can range between 1 and 100, and defaults to 20.
- Minimum: 1
- Maximum: 100
- Default: 20
startingAfteroptionalA cursor used for pagination. Get the value from the
nextCursorresponse of the previous page.organizationIdoptionalA filter on organization ID.
queryoptionalQuery to filter rooms. You can filter by
roomIdandmetadata, for example,metadata["roomType"]:"whiteboard" AND roomId^"liveblocks:engineering". Learn more about filtering rooms with query language.userIdoptionalA filter on users accesses.
groupIdsoptionalA filter on groups accesses. Multiple groups can be used.
Request
Response
Success. Returns the list of rooms, the next page cursor, and the next page URL.
Create room
This endpoint creates a new room. id and defaultAccesses are required. When provided with a ?idempotent query argument, will not return a 409 when the room already exists, but instead return the existing room as-is. Corresponds to liveblocks.createRoom, or to liveblocks.getOrCreateRoom when ?idempotent is provided.
defaultAccessesis the default room permission list, for example[],["*:read"],["*:write"], or a more granular permission list.metadatacould be key/value asstringorstring[].metadatasupports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 256 characters maximum.metadatais optional field.usersAccessescontains user-specific permission lists. It can contain 1000 ids maximum. Id length has a limit of 256 characters.usersAccessesis optional field.groupsAccessescontains group-specific permission lists and is optional.
Parameters
idempotentoptionalWhen provided, will not return a 409 when the room already exists, but instead return the existing room as-is. Corresponds to
liveblocks.getOrCreateRoom.
Request body
Response
Success. Returns the created room.
Get room
This endpoint returns a room by its ID. Corresponds to liveblocks.getRoom.
Parameters
roomIdrequiredID of the room
Request
Response
Success. Returns the room.
Update room
This endpoint updates specific properties of a room. Corresponds to liveblocks.updateRoom.
It’s not necessary to provide the entire room’s information.
Setting a property to null means to delete this property. For example, if you want to remove access to a specific user without losing other users:
{ "usersAccesses": { "john": null } }
defaultAccesses, metadata, usersAccesses, groupsAccesses can be updated.
defaultAccessesis the default room permission list, for example[],["*:read"],["*:write"], or a more granular permission list.metadatacould be key/value asstringorstring[].metadatasupports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 256 characters maximum.metadatais optional field.usersAccessescontains user-specific permission lists. It can contain 1000 ids maximum. Id length has a limit of 256 characters.usersAccessesis optional field.groupsAccessescontains group-specific permission lists and is optional.
Parameters
roomIdrequiredID of the room
Request body
Response
Success. Returns the updated room.
Delete room
This endpoint deletes a room. A deleted room is no longer accessible from the API or the dashboard and it cannot be restored. Corresponds to liveblocks.deleteRoom.
Parameters
roomIdrequiredID of the room
Request
Prewarm room
Speeds up connecting to a room for the next 10 seconds. Use this when you know a user will be connecting to a room with RoomProvider or enterRoom within 10 seconds, and the room will load quicker. Corresponds to liveblocks.prewarmRoom.
Parameters
roomIdrequiredID of the room
Request
Upsert (update or create) room
This endpoint updates specific properties of a room. Corresponds to liveblocks.upsertRoom.
It’s not necessary to provide the entire room’s information.
Setting a property to null means to delete this property. For example, if you want to remove access to a specific user without losing other users:
{ "usersAccesses": { "john": null } }
defaultAccesses, metadata, usersAccesses, groupsAccesses can be updated.
defaultAccessesis the default room permission list, for example[],["*:read"],["*:write"], or a more granular permission list.metadatacould be key/value asstringorstring[].metadatasupports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 256 characters maximum.metadatais optional field.usersAccessescontains user-specific permission lists. It can contain 1000 ids maximum. Id length has a limit of 256 characters.usersAccessesis optional field.groupsAccessescontains group-specific permission lists and is optional.
Parameters
roomIdrequiredID of the room
Request body
Response
Success. Returns the updated or created room.
Update room ID
This endpoint permanently updates the room’s ID. All existing references to the old room ID will need to be updated. Returns the updated room. Corresponds to liveblocks.updateRoomId.
Parameters
roomIdrequiredThe new ID for the room
Request body
Response
Success. Returns the updated room with the new ID.
Update room organization ID
This endpoint updates the room's organization ID. The fromOrganizationId must match the room's current organization ID. Returns the updated room.
Parameters
roomIdrequiredThe ID of the room
Request body
Response
Success. Returns the updated room with the new organization ID.
Get active users
This endpoint returns a list of users currently present in the requested room. Corresponds to liveblocks.getActiveUsers.
For optimal performance, we recommend calling this endpoint no more than once every 10 seconds. Duplicates can occur if a user is in the requested room with multiple browser tabs opened.
Parameters
roomIdrequiredID of the room
Request
Response
Success. Returns the list of active users for the specified room.
Set ephemeral presence
This endpoint sets ephemeral presence for a user in a room without requiring a WebSocket connection. The presence data will automatically expire after the specified TTL (time-to-live). This is useful for scenarios like showing an AI agent's presence in a room. The presence will be broadcast to all connected users in the room. Corresponds to liveblocks.setPresence.
Parameters
roomIdrequiredID of the room
Request body
Broadcast event to a room
This endpoint enables the broadcast of an event to a room without having to connect to it via the client from @liveblocks/client. It takes any valid JSON as a request body. The connectionId passed to event listeners is -1 when using this API. Corresponds to liveblocks.broadcastEvent.
Parameters
roomIdrequiredID of the room
Request body
Storage
Get Storage document
Returns the contents of the room’s Storage tree. Corresponds to liveblocks.getStorageDocument.
The default outputted format is called “plain LSON”, which includes information on the Live data structures in the tree. These nodes show up in the output as objects with two properties, for example:
If you’re not interested in this information, you can use the simpler ?format=json query param, see below.
Parameters
roomIdrequiredID of the room
formatoptionalUse the
jsonformat to output a simplified JSON representation of the Storage tree. In that format, each LiveObject and LiveMap becomes a simple JSON object, each LiveList becomes a simple JSON array, and each LiveFile becomes its metadata object. This is a lossy format because information about the original data structures is not retained, but it may be easier to work with.Allowed values:plain-lson,json
Request
Response
Success. Returns the room’s Storage as JSON.
Initialize Storage document
This 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.
Parameters
roomIdrequiredID of the room
Request body
Response
Success. The Storage is initialized. Returns the room’s Storage as JSON.
Delete Storage document
This endpoint deletes all of the room’s Storage data. Calling this endpoint will disconnect all users from the room if there are any. Corresponds to liveblocks.deleteStorageDocument.
Parameters
roomIdrequiredID of the room
Request
Apply JSON Patch to Storage
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.
Parameters
roomIdrequiredID of the room
Request body
Get Storage file
Returns an uploaded Storage file's metadata and a presigned download URL. The URL expires after one hour.
Parameters
roomIdrequiredID of the room
fileIdrequiredID of the Storage file
Request
Response
Success. Returns the file metadata and presigned download URL.
Upload Storage file
Uploads a file's bytes to a room and returns the metadata needed to create a LiveFile. For large files, use the multipart upload operations instead. Repeating the request with the same file ID, name, and file size returns the existing upload.
Parameters
roomIdrequiredID of the room
fileIdrequiredID for the Storage file
namerequiredName of the file
fileSizeoptionalExpected file size in bytes.
- Minimum: 0
- Maximum:
- Default:
Request body
Response
Success. Returns the uploaded file metadata.
Create Storage file multipart upload
Starts a multipart upload for a Storage file.
Parameters
roomIdrequiredID of the room
fileIdrequiredID for the Storage file
namerequiredName of the file
fileSizeoptionalExpected file size in bytes
- Minimum: 0
- Maximum:
- Default:
Request
Response
Success. Returns identifiers for the multipart upload.
Upload Storage file multipart part
Uploads one part of a Storage file multipart upload.
Parameters
roomIdrequiredID of the room
fileIdrequiredID of the Storage file
uploadIdrequiredID returned when the multipart upload was created
partNumberrequiredOne-based part number
- Minimum: 1
- Maximum:
- Default:
Request body
Response
Success. Returns the uploaded part's number and ETag.
Complete Storage file multipart upload
Completes a multipart upload and returns the metadata needed to create a LiveFile.
Parameters
roomIdrequiredID of the room
fileIdrequiredID of the Storage file
uploadIdrequiredID returned when the multipart upload was created
Request body
Response
Success. Returns the uploaded file metadata.
Abort Storage file multipart upload
Aborts a multipart upload and discards its uploaded parts.
Parameters
roomIdrequiredID of the room
fileIdrequiredID of the Storage file
uploadIdrequiredID returned when the multipart upload was created
Request
Yjs
Get Yjs document
This endpoint returns a JSON representation of the room’s Yjs document. Corresponds to liveblocks.getYjsDocument.
Parameters
roomIdrequiredID of the room
formattingoptionalIf present, YText will return formatting.
keyoptionalReturns only a single key’s value, e.g.
doc.get(key).toJSON().typeoptionalUsed with key to override the inferred type, i.e.
"ymap"will returndoc.get(key, Y.Map).Allowed values:ymap,ytext,yxmltext,yxmlfragment,yarray
Request
Response
Success. Returns the room’s Yjs document as JSON.
Send a binary Yjs update
This endpoint is used to send a Yjs binary update to the room’s Yjs document. You can use this endpoint to initialize Yjs data for the room or to update the room’s Yjs document. To send an update to a subdocument instead of the main document, pass its guid. Corresponds to liveblocks.sendYjsBinaryUpdate.
The update is typically obtained by calling Y.encodeStateAsUpdate(doc). See the Yjs documentation for more details. When manually making this HTTP call, set the HTTP header Content-Type to application/octet-stream, and send the binary update (a Uint8Array) in the body of the HTTP request. This endpoint does not accept JSON, unlike most other endpoints.
Parameters
roomIdrequiredID of the room
guidoptionalID of the subdocument
Request body
Get Yjs document encoded as a binary Yjs update
This endpoint returns the room's Yjs document encoded as a single binary update. This can be used by Y.applyUpdate(responseBody) to get a copy of the document in your back end. See Yjs documentation for more information on working with updates. To return a subdocument instead of the main document, pass its guid. Corresponds to liveblocks.getYjsDocumentAsBinaryUpdate.
Parameters
roomIdrequiredID of the room
guidoptionalID of the subdocument
Request
Version History
Get Version History
This endpoint returns a list of version history snapshots for the room. The versions are returned sorted by creation date, from newest to oldest. Corresponds to liveblocks.getVersionHistory.
Parameters
roomIdrequiredID of the room
limitoptionalA limit on the number of versions to be returned. The limit can range between 1 and 100, and defaults to 20.
- Minimum: 1
- Maximum: 100
- Default: 20
cursoroptionalA cursor used for pagination. Get the value from the
nextCursorresponse of the previous page.
Request
Response
Success. Returns the list of version history snapshots and the next page cursor.
Create version history snapshot
This endpoint creates a new version history snapshot of the room, capturing both its Storage and Yjs documents. Corresponds to liveblocks.createVersionHistorySnapshot.
Parameters
roomIdrequiredID of the room
Request
Response
Success. Returns the created version ID.
Get Yjs document version
This endpoint returns a specific version of the room's Yjs document encoded as a binary Yjs update. Corresponds to liveblocks.getYjsVersion.
Parameters
roomIdrequiredID of the room
versionIdrequiredID of the version
Request
Delete a version
This endpoint permanently deletes a version from the room's history. Corresponds to liveblocks.deleteVersion.
Parameters
roomIdrequiredID of the room
versionIdrequiredID of the version
Request
Comments
Get room threads
This endpoint returns the threads in the requested room. Corresponds to liveblocks.getThreads.
Parameters
roomIdrequiredID of the room
queryoptionalQuery to filter threads. You can filter by
metadata,resolved, andvisibility, for example,metadata["status"]:"open" AND metadata["color"]:"red" AND resolved:true AND visibility:"private". Learn more about filtering threads with query language.
Request
Response
Success. Returns list of threads in a room.
Create thread
This endpoint creates a new thread and the first comment in the thread. Corresponds to liveblocks.createThread.
A comment’s body is an array of paragraphs, each containing child nodes. Here’s an example of how to construct a comment’s body, which can be submitted under comment.body.
metadata supports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 4000 characters maximum for strings.
Parameters
roomIdrequiredID of the room
Request body
Response
Success. Returns the created thread.
Get thread
This endpoint returns a thread by its ID. Corresponds to liveblocks.getThread.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request
Response
Success. Returns requested thread.
Delete thread
This endpoint deletes a thread by its ID. Corresponds to liveblocks.deleteThread.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request
Get thread participantsDeprecated
Deprecated. Prefer using thread subscriptions instead.
This endpoint returns the list of thread participants. It is a list of unique user IDs representing all the thread comment authors and mentioned users in comments. Corresponds to liveblocks.getThreadParticipants.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request
Response
Success. Returns the thread’s participants
Edit thread metadata
This endpoint edits the metadata of a thread. The metadata is a JSON object that can be used to store any information you want about the thread, in string, number, or boolean form. Set a property to null to remove it. Corresponds to liveblocks.editThreadMetadata.
metadata supports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 4000 characters maximum for strings.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request body
Response
Success. Returns the updated metadata.
Mark thread as resolved
This endpoint marks a thread as resolved. The request body must include a userId to identify who resolved the thread. Returns the updated thread. Corresponds to liveblocks.markThreadAsResolved.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request body
Response
Success. Returns the updated thread.
Mark thread as unresolved
This endpoint marks a thread as unresolved. The request body must include a userId to identify who unresolved the thread. Returns the updated thread. Corresponds to liveblocks.markThreadAsUnresolved.
Parameters
roomIdrequiredID of the room
threadIdrequiredID of the thread
Request body
Response
Success. Returns the updated thread.