Skip to content
Get started
Integration
AutoScribe
Webhooks

TypeScript

Handle AutoScribe webhooks in TypeScript (Express).

This page is the TypeScript (Express) implementation guide: verify signatures, then handle only the events you enabled.

All webhook requests from Avara are signed using HMAC-SHA256 with Standard Webhooks headers (webhook-id, webhook-timestamp, webhook-signature). Copy the webhook secret from API Config (View Webhook Secret) and set it as the AVARA_WEBHOOK_KEY environment variable. The SDK’s unwrap() method reads that variable, verifies the signature, and returns a typed event. Every Avara→partner POST expects HTTP 200 with a JSON body matching that event’s response schema. Synchronous hooks should respond within about 30 seconds.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara(); // reads AVARA_WEBHOOK_KEY from env
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "study.access_requested") {
// Handle study access request
const { studyId, studyInstanceUid } = event.data;
// ...
}
if (event.type === "secondary_capture.access_requested") {
// Handle secondary capture upload request
const { studyId, studyInstanceUid } = event.data;
// ...
}
if (event.type === "report.delivered") {
// Handle report delivery
const { reportId, studyId, presignedUrl, isCritical } = event.data;
// ...
}
if (event.type === "modality_worklist.requested") {
// Handle modality worklist request
const { clinicId, callingAe, dateStart, dateEnd } = event.data;
// ...
}
if (event.type === "patient_study.enrichment_requested") {
// Handle patient/study enrichment
const { clinicId, studyInstanceUid } = event.data;
// ...
}
if (event.type === "clinical_context.enrichment_requested") {
// Handle clinical context enrichment
const { clinicId, studyInstanceUid, studyId } = event.data;
// ...
}
});

The study.access_requested webhook is sent when Avara needs presigned URLs for DICOM images (and optional non-DICOM media). This is a synchronous (hard) webhook — you must respond within about 30 seconds. This webhook is sent before a study can be viewed in the Avara interface.

When Avara needs to access study images, it sends a POST request to your webhook endpoint. Your endpoint must respond with presigned GET URLs. The SDK’s unwrap() method returns a typed StudyAccessRequestedWebhookEvent that you can use directly.

Return authorized: false with an error when the caller must not access the study. Returning authorized: true with an empty urls array (and omitted or empty mediaUrls) is treated as no data available, not as a denial.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "study.access_requested") {
const { studyId, studyInstanceUid } = event.data;
// This is your internal business logic
const presignedUrls = await generatePresignedUrlsForStudy(studyInstanceUid);
if (presignedUrls.length === 0) {
return res.status(200).json({
authorized: false,
error: "Study not found in PACS",
});
}
res.status(200).json({
authorized: true,
urls: presignedUrls,
});
}
});
// This is your internal business logic
async function generatePresignedUrlsForStudy(
studyInstanceUid: string
): Promise<string[]> {
// Query your PACS/RIS system for the study
// Generate presigned URLs for each DICOM image
// Return a flat list of all image URLs
return [
"https://storage.example.com/dicom/image1.dcm?token=abc123",
"https://storage.example.com/dicom/image2.dcm?token=def456",
];
}

Response Format

interface StudyAccessRequestedWebhookResponse {
authorized: boolean;
urls: string[]; // Flat list of DICOM GET URLs (may be empty)
mediaUrls?: Array<{ url: string; mimeType: string; fileName?: string }>;
error?: string; // Error message if authorization failed
}

The secondary_capture.access_requested webhook is sent when a viewer user creates a secondary capture. This is a synchronous (hard) webhook — you must return presigned PUT URLs in-request, within about 30 seconds.

Avara asks for upload URLs before writing the generated DICOM to your storage. The SDK’s unwrap() method returns a typed SecondaryCaptureAccessRequestedWebhookEvent. Respond authorized: false with an error if the study cannot be written. uploadUrls must be PUT-capable; the client uploads with Content-Type: application/dicom and writes the same object to every URL. Series and SOP UIDs are provided when available so you can pre-compute object keys. If you send contentCreatorName, Avara ignores it and derives the creator name server-side.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "secondary_capture.access_requested") {
const { studyId, studyInstanceUid, seriesInstanceUid, sopInstanceUid } =
event.data;
// This is your internal business logic
const uploadUrls = await generateSecondaryCaptureUploadUrls({
studyInstanceUid,
seriesInstanceUid,
sopInstanceUid,
});
if (uploadUrls.length === 0) {
return res.status(200).json({
authorized: false,
error: "Study cannot be written",
});
}
res.status(200).json({
authorized: true,
uploadUrls,
});
}
});
// This is your internal business logic
async function generateSecondaryCaptureUploadUrls(params: {
studyInstanceUid: string;
seriesInstanceUid?: string;
sopInstanceUid?: string;
}): Promise<string[]> {
// Generate presigned PUT URLs for the secondary capture DICOM
return [
"https://storage.example.com/dicom/sc/image.dcm?token=abc123",
];
}

Response Format

interface SecondaryCaptureAccessRequestedWebhookResponse {
authorized: boolean;
uploadUrls: string[]; // Presigned PUT URLs; the viewer uploads the same object to every URL
contentCreatorName?: string; // Ignored if provided — Avara derives creator name server-side
error?: string; // When authorized is false
}

The report.delivered webhook is sent when a report is completed and delivered. This is an asynchronous notification — respond with a simple success acknowledgment. The webhook includes plain text content, a presigned URL for PDF download, and isCritical (whether the report was marked critical at sign-off).

When a report is completed, Avara sends a POST request to your webhook endpoint. Your endpoint should process the report and respond with a success acknowledgment. The SDK’s unwrap() method returns a typed ReportDeliveredWebhookEvent that you can use directly.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "report.delivered") {
const { reportId, studyId, plainText, presignedUrl, isCritical } = event.data;
// This is your internal business logic
await processCompletedReport({
reportId,
studyId,
plainText,
presignedUrl,
isCritical,
});
res.status(200).json({
success: true,
});
}
});
// This is your internal business logic
async function processCompletedReport(data: {
reportId: string;
studyId: string;
plainText?: string;
presignedUrl: string;
isCritical: boolean;
}): Promise<void> {
// Download the PDF from the presigned URL
// Store the report in your system
// Update your PACS/RIS with the completed report
// Notify relevant users or systems
}

Response Format

interface ReportDeliveredWebhookResponse {
success: boolean;
}

The modality_worklist.requested webhook is sent when an on-prem modality (via an Avara PACS box) issues a C-FIND MWL. This is a synchronous (hard) webhook — the C-FIND path waits on your response, which should return within about 30 seconds.

Avara forwards the query window to your endpoint. Only one active API key per organization may have the Modality Worklist Webhook Endpoint set. The SDK’s unwrap() method returns a typed ModalityWorklistRequestedWebhookEvent. Return authorized: false with an error to surface a worklist failure to the modality. items is required and may be empty when there are no scheduled exams.

Item field names are PascalCase DICOM-style (not camelCase). StudyInstanceUID is required from the partner RIS today — do not omit it. PatientName, PatientID, and Modality must be non-empty. ScheduledProcedureStepSequence must contain at least one step.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "modality_worklist.requested") {
const { clinicId, callingAe, sourceIp, dateStart, dateEnd, modality } =
event.data;
// This is your internal business logic
const items = await queryModalityWorklist({
clinicId,
callingAe,
sourceIp,
dateStart,
dateEnd,
modality,
});
res.status(200).json({
authorized: true,
items,
});
}
});
// This is your internal business logic
async function queryModalityWorklist(params: {
clinicId: string;
callingAe: string;
sourceIp: string;
dateStart: string;
dateEnd: string;
modality?: string;
}): Promise<ModalityWorklistItem[]> {
return [
{
PatientName: "DOE^JANE",
PatientID: "MRN12345",
PatientBirthDate: "19800115",
PatientSex: "F",
PatientSize: "1.65",
PatientWeight: "62",
Modality: "CT",
AccessionNumber: "ACC-1001",
StudyInstanceUID: "1.2.840.113619.2.55.3.604688119.868.1234567890.123",
RequestedProcedureDescription: "CT CHEST WO CONTRAST",
StudyDescription: "CT CHEST WO CONTRAST",
ProtocolName: "CHEST_WO",
ScheduledProcedureStepSequence: [
{
ScheduledProcedureStepStartDate: "20260813",
ScheduledProcedureStepStartTime: "090000",
ScheduledProcedureStepID: "SPSID-1",
Modality: "CT",
ScheduledProcedureStepDescription: "CT CHEST WO CONTRAST",
},
],
},
];
}

Response Format

interface ModalityWorklistRequestedWebhookResponse {
authorized: boolean;
items: ModalityWorklistItem[]; // Required; may be empty if authorized and no scheduled exams
error?: string;
}
interface ModalityWorklistItem {
PatientName: string; // Required, non-empty
PatientID: string; // Required, non-empty
PatientBirthDate: string; // Required (may be empty string)
PatientSex: string; // Required (may be empty string)
PatientSize: string; // Required (may be empty string)
PatientWeight: string; // Required (may be empty string)
Modality: string; // Required, non-empty
AccessionNumber: string; // Required (may be empty string)
StudyInstanceUID: string; // Required valid DICOM UID
RequestedProcedureDescription: string;
StudyDescription: string;
ProtocolName: string;
ScheduledProcedureStepSequence: Array<{
ScheduledProcedureStepStartDate: string; // Non-empty
ScheduledProcedureStepStartTime: string; // Non-empty
ScheduledProcedureStepID: string; // Non-empty
Modality: string; // Non-empty
ScheduledProcedureStepDescription: string;
}>; // Min 1
}

The patient_study.enrichment_requested webhook is sent after Avara PACS receives the first C-STORE and seeds the study. This is a synchronous (soft) webhook — failures, timeouts, and invalid bodies are treated as empty enrichment and do not hard-fail study creation.

Avara asks your EHR/RIS for demographic and study header fields to merge into AutoScribe study creation. The SDK’s unwrap() method returns a typed PatientStudyEnrichmentRequestedWebhookEvent. There is no authorized field; HTTP 2xx plus JSON that parses is enough. Returning {} is valid. Avara merges per-field with DICOM light metadata, then defaults. Do not rely on this webhook for hard access control.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "patient_study.enrichment_requested") {
const { clinicId, studyInstanceUid, patientId, accessionNumber } =
event.data;
// This is your internal business logic
const enrichment = await enrichPatientStudy({
clinicId,
studyInstanceUid,
patientId,
accessionNumber,
});
res.status(200).json(enrichment);
}
});
// This is your internal business logic
async function enrichPatientStudy(params: {
clinicId: string;
studyInstanceUid: string;
patientId?: string;
accessionNumber?: string;
}): Promise<PatientStudyEnrichmentRequestedWebhookResponse> {
// Look up demographics and study headers in your EHR/RIS
// Return any subset of fields — or {}
return {
patientName: "Jane Doe",
dateOfBirth: "1980-01-15",
sex: "female",
height: { value: 165, unit: "cm" },
weight: { value: 62, unit: "kg" },
mrn: "MRN12345",
externalPatientId: "EHR-PT-1001",
procedure: "CT CHEST WO CONTRAST",
studyDescription: "CT CHEST WO CONTRAST",
facilityName: "South Tampa Imaging",
referringPhysicianName: "Dr. Alan Smith",
studyDate: "2026-08-13",
studyTime: "09:00",
severity: "normal",
};
}

Response Format

interface PatientStudyEnrichmentRequestedWebhookResponse {
patientName?: string;
dateOfBirth?: string; // YYYY-MM-DD
sex?: "male" | "female" | "other";
height?: { value: number; unit: "in" | "cm" }; // value >= 0
weight?: { value: number; unit: "lbs" | "kg" }; // value >= 0
mrn?: string;
externalPatientId?: string;
procedure?: string;
studyDescription?: string;
facilityName?: string;
referringPhysicianName?: string;
studyDate?: string; // YYYY-MM-DD
studyTime?: string; // HH:MM or HH:MM:SS[.fff]; Avara may truncate to HH:MM
severity?: "normal" | "high" | "stat";
}

The clinical_context.enrichment_requested webhook is sent when AutoScribe needs clinical context for a study (for example, a radiologist opens the study). This is a synchronous (soft) webhook — failures are treated as empty enrichment.

Avara asks your EHR for indication, technique, priors, and supporting documents. The SDK’s unwrap() method returns a typed ClinicalContextEnrichmentRequestedWebhookEvent. There is no authorized field. Returning {} is valid.

data.studyId on this event is a raw UUID v4, not a branded stu_… id. Most other study webhooks use stu_….

documents are verbatim text chunks. documentUrls are fetched and summarized by Avara — prefer https:// URLs.

import Avara from "avara";
import express, { Request, Response } from "express";
const client = new Avara();
const app = express();
app.use(express.json());
app.post("/webhooks/avara", async (req: Request, res: Response) => {
const event = client.webhooks.unwrap(req.body, req.headers);
if (event.type === "clinical_context.enrichment_requested") {
const { clinicId, studyInstanceUid, studyId, externalPatientId, mrn } =
event.data;
// This is your internal business logic
const enrichment = await enrichClinicalContext({
clinicId,
studyInstanceUid,
studyId,
externalPatientId,
mrn,
});
res.status(200).json(enrichment);
}
});
// This is your internal business logic
async function enrichClinicalContext(params: {
clinicId: string;
studyInstanceUid: string;
studyId: string;
externalPatientId?: string;
mrn?: string;
}): Promise<ClinicalContextEnrichmentRequestedWebhookResponse> {
// Pull indication, technique, priors, and documents from your EHR
// Return any subset of fields — or {}
return {
clinicalIndication: "Shortness of breath, evaluate for PE",
technologistTechnique: "Helical CT chest, 1.25 mm, IV contrast",
priorReports: [
{
studyDescription: "CT CHEST WO CONTRAST",
modality: "CT",
studyDate: "2025-11-02",
reportText: "No acute cardiopulmonary process.",
},
],
};
}

Response Format

interface ClinicalContextEnrichmentRequestedWebhookResponse {
clinicalIndication?: string;
technologistTechnique?: string;
technologistNotes?: string[]; // Max 50 items; each 1–1000 chars
priorReports?: Array<{
externalStudyId?: string; // Max 256
studyDescription?: string; // Max 1000
modality?: string; // Max 100
studyDate?: string; // YYYY-MM-DD
reportText: string; // Required if object present; max 50000
}>; // Max 50
documents?: Array<{
fileName: string; // 1–500
content: string[]; // Min 1 chunk
}>; // Inline text docs; max 10
documentUrls?: Array<{
fileName?: string; // 1–500
url: string; // Must be https://
}>; // Remote docs for Avara to fetch/summarize; max 10
}