Topic Operations
resource: topic — Hedera Consensus Service (HCS) messages
What is HCS? The Hedera Consensus Service gives you a totally-ordered, timestamped
message log — useful as an audit trail, an event bus between systems, or a tamper-evident record of
anything you submit to it.
getMessages
Returns messages published to a topic, in consensus sequence order.
| Field | Type | Required | Description |
|---|---|---|---|
topicId | text | ✓ Yes | HCS topic ID, e.g. 0.0.55555 |
limit | number | No | 1–100, default 25 |
sequenceFrom | number | No | Only return messages with sequence number ≥ this value — use for pagination/polling. |
decodeUtf8 | boolean | No | Default true. Decodes message content from base64 to a UTF-8 string; set false to receive raw base64. |
network | select | No | See Networks. |
{
"topicId": "0.0.55555",
"messages": [
{
"sequenceNumber": 41,
"consensusTimestamp": "1690000012.345678900",
"message": "{\"event\":\"order-placed\",\"orderId\":\"A-1042\"}",
"runningHash": "9f2a...e711"
},
{
"sequenceNumber": 42,
"consensusTimestamp": "1690000019.001122300",
"message": "{\"event\":\"order-shipped\",\"orderId\":\"A-1042\"}",
"runningHash": "1cd0...aa42"
}
]
}
Pagination / Polling Pattern
To poll a topic for new messages as a workflow trigger, remember the highest
sequenceNumber you've already processed, then call again with
sequenceFrom set to that number + 1:
- Call
topic.getMessageswith nosequenceFromthe first time (or start at 1). - Record the last
sequenceNumberseen. - On the next poll, set
sequenceFromtolastSeen + 1— only new messages come back.
See Examples for a full worked polling workflow.
decodeUtf8 and binary payloads: If a topic carries binary (non-text) message data,
set
decodeUtf8 to false and decode it yourself downstream — forcing UTF-8
decoding on binary content can corrupt or garble the payload.