Anam Transcription

Webhooks · HMAC + retries

Server delivery, separate from browser events

The service sends signed JSON to the configured tenant webhook_url. Webhooks wake trusted server consumers. For browser completion, use the SSE feed; for canonical text, use an authorized HTTP read. The transcription service knows no application report, clinical role or business action.

Event contract

Event Stage Meaning
transcription.realtime.started realtime Optional live processing started
transcription.realtime.partial realtime Optional throttled live draft; tenant opt-in is required
transcription.realtime.ended realtime Live stream ended, not canonical completion
transcription.processing final A worker started the canonical stage
transcription.transcript_ready final Text exists; required speaker inference may still be pending
transcription.completed final Canonical pipeline completed; inspect speaker status and capture integrity
transcription.failed final Terminal failure or dead letter

Only completed and failed carry is_final: true. Completion can explicitly report skipped/failed/not-requested speaker inference; it does not certify that every source byte was captured. Read the current transcript, revision and capture_incomplete before using the output.

Headers and signature

Header Contract
X-Anam-Event Event name
X-Anam-Stage realtime or final
X-Anam-Delivery Stable delivery UUID across retry attempts
X-Anam-Job-Id Tenant-scoped job UUID
X-Anam-Sequence Payload sequence; not a global lifecycle order
X-Anam-Timestamp Current sending/signing time, in Unix seconds
X-Anam-Signature t=<seconds>,v1=<64 hex HMAC-SHA256>

Verify {timestamp}.{original UTF-8 body bytes} with the tenant webhook signing secret before parsing. Compare digests in constant time and reject sending timestamps outside ±5 minutes. Reject malformed/duplicate timestamp or v1 fields. The original body and delivery ID stay unchanged on retry; the signing timestamp/signature are fresh. Event emitted_at may be older and is not the freshness clock.

Route by a trusted configured endpoint and its signing secret. Native v1 has no tenant-ID header/body field. Free metadata, event URLs and HTTP headers must not choose a tenant, API key, provider or origin. Bind the signing route to the authorized native client; rotate receiver secrets with an overlap window before updating the sender.

Acknowledge after durable acceptance

// Conceptual composition using the repository's separate consumers package.
// Configure trusted route/tenant/secret bindings on the server, never from request JSON.
app.post('/webhooks/:routeId', express.raw({ type: 'application/json', limit: '1mb' }),
  async (req, res, next) => {
    try {
      const route = trustedRoute(req.params.routeId);
      const note = verifyNativeWebhook(route, { rawBody: req.body, headers: req.headers });
      await inbox.accept(note); // receipt + work intent commit atomically, dedupe by tenant/delivery
      res.sendStatus(202);      // durable acceptance; asynchronous worker does the business work
    } catch (error) { next(error); } // never ACK parser/signature/persistence failure
  });

Do not send 200 before persisting the inbox. A crash between ACK and an in-memory handler loses the event. Retried duplicate deliveries must resolve to the same persisted receipt; a reused delivery ID with a different body is a conflict. The inbox stores routing metadata and a body hash, not inline speech or the raw body. Subsequent consumers re-fetch the current source through tenant-authorized APIs rather than trusting webhook text.

At-least-once, bounded retries and ordering

  • Respond 2xx after durable acceptance, within the configured timeout. Run heavy work asynchronously.
  • Transport/DNS failures, HTTP 408, 429 and 5xx retry with exponential backoff and full jitter. Defaults: 2-second base, 5-minute cap, 6 attempts.
  • Other 4xx and redirects are permanent failures. Redirects and environment HTTP proxies are disabled.
  • A crashed attempt consumes its budget. Expired claims are reclaimed only when attempts remain; the final interrupted attempt becomes exhausted.
  • Every claim has an exclusive token. A stale process cannot acknowledge, fail or reschedule its successor's delivery.
  • Delivery is at least once, not exactly once. A receiver may persist the body while its 2xx response is lost; dedupe by delivery_id.
  • Concurrent delivery and retries can reorder lifecycle events. sequence is scoped to the event/stream, not a monotonically increasing number across every stage. A late processing notice must not regress a completed source; reconcile current API state.

Use GET /v1/jobs/:jobId/deliveries to inspect bounded tenant delivery metadata and POST /v1/jobs/:jobId/deliveries/retry to explicitly replay failed/exhausted deliveries after fixing the endpoint. A separate consumer inbox also has its own scoped work/dead-letter replay API; it is not the transcription service delivery queue.

Targets and content privacy

Production targets require HTTPS. URL userinfo/fragments and non-public addresses are refused, including normalized IPv4-mapped IPv6. All DNS answers are checked, then pinned for that connection while preserving the original Host and TLS server name. DNS and HTTP share a bounded deadline. WEBHOOK_ALLOW_PRIVATE_TARGETS=true is an explicit local/test exception and is refused in production. A network egress policy remains defense in depth.

The v1 payload may inline a small result (default maximum 256 KiB), include opted-in realtime partial text, and echo job.metadata. This is authorized content delivery, not a content-free log. If the consumer only needs a notification, configure WEBHOOK_MAX_INLINE_RESULT_BYTES=0, keep realtime partial webhooks off, and put only opaque non-sensitive references in metadata. Do not store webhook speech in ordinary logs or dedup receipts.

Derive source reads from a trusted configured service origin and the verified job UUID. Do not blindly follow result_url. Current webhook events do not include every later edit/delete; consumers need bounded reconciliation and host revocation/tombstone handling. Webhook connections do not reduce ASR/diarization inference costs.

Contracts: contracts/webhook-payload.schema.json, docs/webhook-inbox.md, docs/integration-guide.md. Receiver implementation: consumers/src/webhooks; sender: api/src/webhooks. These are tested mechanisms, not a claim that regional deployment, throughput or delivery to every external provider has been validated.