episode.closed
When Signals sends episode.closed, its payload and how to handle it in Node.js, Python and Java.
An episode ends. closeReason is one of the reasons in How an episode behaves.
Payload
Every delivery is the envelope type, timestamp, sequence and data; the delivery's id is the webhook-id header. See Verify webhooks.
{
"type": "episode.closed",
"timestamp": "2026-10-25T08:00:02.000Z",
"sequence": 1050,
"data": {
"id": "e7a1b2c3-d4e5-4f60-8a9b-0c1d2e3f4a5b",
"patient": "6f1c2a8e-3b7d-4c55-9a0e-2d4b8f6e1a90",
"patientRefId": "resident-001",
"code": "8867-4",
"system": "http://loinc.org",
"display": "Heart rate",
"status": "CLOSED",
"openedAt": "2026-10-25T08:00:00.000Z",
"closedAt": "2026-10-25T08:20:00.000Z",
"closeReason": "RECOVERED",
"firstObservationRefId": "reading-0001",
"lastObservationRefId": "reading-0005",
"lastAlertId": "0b9d7e52-1f3a-4e8c-b6a2-7c4d9e1f2a35"
}
}The fields are those of episode.opened.
Handle the event
Verify the delivery first (Verify webhooks), then act on the verified event as in Handle an event.
export async function handle(webhookId, event) {
if (!(await firstTime(webhookId))) return;
const { data } = event;
switch (event.type) {
case 'episode.closed':
await closeEpisode(data.id, data.closeReason, data.closedAt);
break;
default:
break;
}
}Related
Last updated on