From f4d9cfe5d719387283faa7caebf380c988d81328 Mon Sep 17 00:00:00 2001 From: Vlad Velici Date: Thu, 24 Jul 2025 09:58:12 +0100 Subject: [PATCH 1/2] add get single message by serial endpoint reference docs --- static/open-specs/chat.yaml | 79 +++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/static/open-specs/chat.yaml b/static/open-specs/chat.yaml index 9cfbef4de1..d28dc22e24 100644 --- a/static/open-specs/chat.yaml +++ b/static/open-specs/chat.yaml @@ -440,6 +440,85 @@ paths: statusCode: 500 href: "https://help.ably.io/error/50001" /chat/{version}/rooms/{roomName}/messages/{serial}: + get: + summary: Retrieve a single message from a room + description: | + Fetches a single message from a specified room. + tags: + - rooms + parameters: + - name: version + in: path + required: true + description: The version of the Chat API endpoint to use. + schema: + type: string + example: v3 + - name: roomName + in: path + required: true + description: The unique identifier of the room to fetch messages from. The `roomName` must be URI-encoded. + schema: + type: string + - name: serial + in: path + required: true + description: The unique identifier of the message to fetch. The `serial` must be URI-encoded. + schema: + type: string + example: "01826232498871-001@abcdefghij:001" + - $ref: '#/components/parameters/ClientIdHeader' + - $ref: '#/components/parameters/AuthorizationHeader' + - $ref: '#/components/parameters/AcceptHeader' + responses: + '200': + description: A single message retrieved from the room. + content: + application/json: + schema: + $ref: '#/components/schemas/Message' + '400': + description: Invalid request. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorInfo' + '401': + description: Unauthorized access. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorInfo' + example: + error: + message: "Unauthorized access." + code: 40005 + statusCode: 401 + href: "https://help.ably.io/error/40101" + '404': + description: Message not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorInfo' + example: + error: + message: "Message not found." + code: 40400 + statusCode: 404 + href: "https://help.ably.io/error/40401" + '500': + description: Server error. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorInfo' + example: + error: + message: "Internal server error." + code: 50001 + statusCode: 500 + href: "https://help.ably.io/error/50001" put: summary: Update a message in a room description: | From 1fb201c3d57a1eb2a419e558029c4e9b030f4374 Mon Sep 17 00:00:00 2001 From: Vlad Velici Date: Thu, 24 Jul 2025 09:58:22 +0100 Subject: [PATCH 2/2] Add section about fetching a single message by serial --- src/pages/docs/chat/rooms/messages.mdx | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/pages/docs/chat/rooms/messages.mdx b/src/pages/docs/chat/rooms/messages.mdx index 17f96bf783..9ce6591c76 100644 --- a/src/pages/docs/chat/rooms/messages.mdx +++ b/src/pages/docs/chat/rooms/messages.mdx @@ -180,6 +180,50 @@ room.messages.send(text = "hello") ``` +## Get a single message + + +Use the [`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#get)[`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messages/get%28serial%3A%29)[`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-messages/get.html) method to get a message in a chat room. + + + +Use the [`getMessage()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseMessagesResponse.html#getMessage) method available from the response of the `useMessages` hook to send a message to the room: + + + +```javascript +await room.messages.get(serial); +``` + +```react +import { useMessages } from '@ably/chat/react'; + +const MyComponent = () => { + const { getMessage } = useMessages(); + + const handleMessageSend = () => { + getMessage(serial); + }; + + return ( +
+ +
+ ); +}; +``` + +```swift +let message = try await room.messages.get(serial: serial) +``` + +```kotlin +room.messages.get(serial = serial) +``` +
+ + + ## Update a message