Comments

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.

{
  "version": 1,
  "content": [
    {
      "type": "paragraph",
      "children": [{ "text": "Hello " }, { "text": "world", "bold": true }]
    }
  ]
}

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.

post/rooms/{roomId}/threads

Request

  • Base URL: https://api.liveblocks.io/v2
  • URL: https://api.liveblocks.io/v2/rooms/{roomId}/threads
  • Auth: none declared

Path parameters

roomIdstring required

ID of the room

Example:my-room-id

Request body

metadataThreadMetadata

Custom metadata attached to a thread. Supports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 4000 characters maximum for strings.

visibility'public' | 'private'

Example request

{
  "comment": {
    "userId": "alice",
    "createdAt": "2022-07-13T14:32:50.697Z",
    "body": {
      "version": 1,
      "content": []
    },
    "metadata": {
      "tag": "important",
      "spam": false
    }
  },
  "metadata": {
    "color": "blue"
  },
  "visibility": "private"
}

Response

Success. Returns the created thread.

type'thread' required
idstring required
roomIdstring required
createdAtstring date-time required
metadataThreadMetadata required

Custom metadata attached to a thread. Supports maximum 50 entries. Key length has a limit of 40 characters maximum. Value length has a limit of 4000 characters maximum for strings.

resolvedboolean required
visibility'public' | 'private' required
updatedAtstring date-time required

Example response

{
  "type": "thread",
  "id": "th_abc123",
  "roomId": "my-room-id",
  "comments": [
    {
      "type": "comment",
      "threadId": "th_abc123",
      "roomId": "my-room-id",
      "id": "cm_abc123",
      "userId": "alice",
      "createdAt": "2022-07-13T14:32:50.697Z",
      "body": {
        "version": 1,
        "content": []
      },
      "metadata": {},
      "reactions": [],
      "attachments": []
    }
  ],
  "createdAt": "2022-07-13T14:32:50.697Z",
  "updatedAt": "2022-07-13T14:32:50.697Z",
  "metadata": {
    "color": "blue"
  },
  "resolved": false,
  "visibility": "public"
}

Changes