I’d like to subscribe to transaction events using the Ledger JSON API’s /v2/updates/flats
websocket endpoint. Can you give me a sample request payload?
The following works using 3.2.0-snapshot.20250206.0
. It is likely to change with 3.3+. And eventually the docs will have a sample. But, for now, in bash…
echo '
{
"verbose": false,
"beginExclusive": "0",
"filter": {
"filtersByParty" : {
"'${PARTY_ID}'": {
"cumulative": [
{
"identifierFilter": {
"TemplateFilter": {
"value": {
"includeCreatedEventBlob": false,
"templateId": "'${PACKAGE_NAME}':'${MODULE_NAME}':'${ENTITY_NAME}'"
}
}
}
}
]
}
}
}
}
' | jq --compact-output \
| websocat \
--header "Authorization: Bearer ${PARTY_TOKEN}" \
-n1 \
ws://${LEDGER_HOST}:${LEDGER_JSON}/v2/updates/flats \
| jq
Sample result
{
"update": {
"Transaction": {
"value": {
"update_id": "12201c4cd506a5dd6ddc1723c6a4490eee6cdb80fcc27c3632219e5a76d622a6cbfe",
"command_id": "somecommandid04",
"workflow_id": "",
"effective_at": "2025-05-01T14:43:30.554452Z",
"events": [
{
"CreatedEvent": {
"event_id": "#12201c4cd506a5dd6ddc1723c6a4490eee6cdb80fcc27c3632219e5a76d622a6cbfe:0",
"contract_id": "006885c5198349c44273cf1c49895ea16fb81ebcd20496387ff8a2112d5025b9e2ca101220cc5b4f27ec2f13f3bdb7948d96a8f5060f3895bf31018017c93afc49c87d5e42",
"template_id": "98e04bc228e72e9b21685287533df601555be5513ba1e113cc0b460ca4922a83:Main:Asset",
"contract_key": null,
"create_argument": {
"issuer": "alice::1220869f8fa122836b7410abb29a48d16b4710e28e03f1911fe61ddc80b8977d77c9",
"owner": "alice::1220869f8fa122836b7410abb29a48d16b4710e28e03f1911fe61ddc80b8977d77c9",
"name": "my asset",
"category": "Stock"
},
"created_event_blob": "",
"interface_views": [],
"witness_parties": [
"alice::1220869f8fa122836b7410abb29a48d16b4710e28e03f1911fe61ddc80b8977d77c9"
],
"signatories": [
"alice::1220869f8fa122836b7410abb29a48d16b4710e28e03f1911fe61ddc80b8977d77c9"
],
"observers": [],
"created_at": "2025-05-01T14:43:30.554452Z",
"package_name": "ledger-api-samples"
}
}
],
"offset": 13,
"domain_id": "mydomain::12205f417a08971783cd23ea40afc4c98f767229ae3e3bb7018c1cd034521943426c",
"trace_context": {
"traceparent": "00-63543e3dbf98217dd7e1d204b9778bb4-9e2b11a4560c0ec4-01",
"tracestate": null
},
"record_time": "2025-05-01T14:43:31.167995Z"
}
}
}
}
2 Likes