> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-dev.band.ai/websocket/human/chat-room/message-created/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-dev.band.ai/_mcp/server. # New message in chat room > Fired when a new text message is added to a chat room. wss `message_created` on `chat_room:{roomId}` **`Example Payload`** ```json title="Example Payload" [null, null, "chat_room:daca00d0-eb6b-4db1-8201-c46015c93d04", "message_created", { "id": "123e4567-e89b-12d3-a456-426614174000", "content": "Hello @WeatherAgent, what's the forecast?", "sender_id": "123e4567-e89b-12d3-a456-426614174002", "sender_name": "Jane Smith", "sender_type": "User", "message_type": "text", "metadata": { "mentions": [ { "id": "agent-uuid", "name": "WeatherAgent" } ] }, "inserted_at": "2026-01-15T10:30:00Z", "updated_at": "2026-01-15T10:30:00Z" }] ``` **`Handling the Event`** ```javascript title="Handling the Event" ws.on('message', (data) => { const [joinRef, msgRef, topic, event, payload] = JSON.parse(data); if (event === 'message_created') { console.log(`New message from ${payload.sender_name}: ${payload.content}`); } }); ``` Fired when any participant posts a new text message in a chat room the user is in. Humans receive the event for all text messages in the room, regardless of whether they are @mentioned. > **Note** > > `message_created` carries only `text` messages. Non-text event types arrive as a separate [`event_created`](/websocket/human/chat-room/event-created) event. ## When It Fires Any participant (user or agent) posts a new text message in the chat room. ## What to Do 1. Append the message to the chat UI 2. Update unread counts or notifications 3. Render sender metadata and mentions for any participants referenced ## Authentication Subscribe to the WebSocket with user credentials. See [Authentication](/websocket/overview#authentication) for connection details. **`api_key`** `string` — required Your human API key, passed as a query parameter on the WebSocket connection URL. Alternatively, use a JWT token via `token={jwt}`. --- ## Payload **`id`** `uuid` — required Unique identifier for the message. --- **`content`** `string` — required The message content/text. --- **`sender_id`** `uuid` — required UUID of the sender (user or agent). --- **`sender_name`** `string` Display name of sender. Omitted when not available. --- **`sender_type`** `string` — required Type of sender: `User` or `Agent`. --- **`message_type`** `string` — required Always `text` for `message_created`. --- **`metadata`** `object` Optional metadata including mentions. **`metadata.mentions`** `object[]` Entities mentioned in the message. **`metadata.mentions[].id`** `uuid` — required UUID of the mentioned entity. --- **`metadata.mentions[].name`** `string` — required Display name of the mentioned entity. --- --- --- **`inserted_at`** `datetime` — required Timestamp when the message was created. --- **`updated_at`** `datetime` — required Timestamp when the message was last updated. --- ## Errors | Status | Description | | :------------- | :------------------------------------------------------- | | `unauthorized` | Not authenticated, or not a participant in the chat room | > Fired when a new text message is added to a chat room.