Skip to content
Engine API

Topics

Topics endpoints of the MedHook engine API: 7 operations with parameters, schemas and a curl example for each.

On this page

Typed publish/subscribe between workflows: a Publish step writes an event, every workflow with a topic trigger on it gets it (durable, at least once, deduplicated by event id). Workspace-scoped.

List topics

get/api/topics

The workspace's topics with publisher and subscriber counts, events published in the last 24 h and dead letters of the last 7 days. No message content.

Auth: Bearer token (how to get one) · Operation: listTopics

Responses

  • 200The topics.
    Response fields

    application/json · object

    • topicsarray of Topic
    • totalinteger

Example request

curl
curl "$ENGINE_URL/api/topics" \
  -H "Authorization: Bearer $TOKEN"

Create a topic

post/api/topics

A named, typed event channel between workflows. Publish steps write events to it; every workflow with a topic trigger on it gets each event once (at least once, deduplicated by event id). Audited (topic.created). Rate limited: 20 req / 60 s.

Auth: Bearer token (how to get one) · Operation: createTopic

Request body (required)

application/json · object

  • namestringrequired
  • descriptionstring | null
  • schemaobject | null

    JSON Schema subset the events must match: type, properties, required, items, enum, const, minimum, maximum, minLength, maxLength, minItems, maxItems, additionalProperties, title, description. Other keywords are refused. null takes any event.

  • orderingKeystring | null

    A field path read from each event ("MSH.4", "$.facility"). Events with the same value reach each subscriber one at a time, in publish order. An event without it runs unordered.

  • maxRetriesinteger

    Retries of a failed delivery before it is a dead letter; the subscriber workflow's own retry setting wins when higher.

  • retryDelayMsinteger
  • onErrorstring

    An ordered delivery that failed: continue with the key's next event, or hold that subscriber's lane for the key until it succeeds or is discarded.

    One of: "continue", "hold"

Responses

  • 201Created.
    Response fields

    application/json · object

  • 400Invalid name, schema or settings.

    application/json · ApiError

  • 409A topic with this name exists in the workspace.

    application/json · ApiError

Example request

curl
curl -X POST "$ENGINE_URL/api/topics" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "adt.admit",
  "description": "string",
  "schema": {},
  "orderingKey": "MSH.4",
  "maxRetries": 3,
  "retryDelayMs": 30000,
  "onError": "continue"
}'

Get a topic's page

get/api/topics/{name}

Settings and schema, publishers, subscribers with lag (pending deliveries, oldest age) and dead letters, the 50 newest events with each delivery's state (waiting, retrying, running, delivered, dead-letter, cancelled, expired) and the dead letters of the last 7 days. No message content.

Auth: Bearer token (how to get one) · Operation: getTopic

Parameters

NameInTypeDescription
namerequiredpathstring

The topic's name (its key in the workspace).

Responses

  • 200The topic page.
  • 404Topic not found in this workspace.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/topics/adt.admit" \
  -H "Authorization: Bearer $TOKEN"

Change a topic

put/api/topics/{name}

Description, schema, ordering key, retries or onError; the name is the key and is not renamed. Takes effect at once for every deployed publisher and subscriber (retries: for new events only); check first with POST /api/topics/{name}/impact. Audited (topic.updated).

Auth: Bearer token (how to get one) · Operation: updateTopic

Parameters

NameInTypeDescription
namerequiredpathstring

The topic's name (its key in the workspace).

Request body (required)

application/json · object

  • descriptionstring | null
  • schemaobject | null

    JSON Schema subset the events must match: type, properties, required, items, enum, const, minimum, maximum, minLength, maxLength, minItems, maxItems, additionalProperties, title, description. Other keywords are refused. null takes any event.

  • orderingKeystring | null

    A field path read from each event ("MSH.4", "$.facility"). Events with the same value reach each subscriber one at a time, in publish order. An event without it runs unordered.

  • maxRetriesinteger

    Retries of a failed delivery before it is a dead letter; the subscriber workflow's own retry setting wins when higher.

  • retryDelayMsinteger
  • onErrorstring

    An ordered delivery that failed: continue with the key's next event, or hold that subscriber's lane for the key until it succeeds or is discarded.

    One of: "continue", "hold"

Responses

  • 200Changed.
    Response fields

    application/json · object

  • 400Invalid schema or settings.

    application/json · ApiError

  • 404Topic not found in this workspace.

    application/json · ApiError

Example request

curl
curl -X PUT "$ENGINE_URL/api/topics/adt.admit" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "string",
  "schema": {},
  "orderingKey": "MSH.4",
  "maxRetries": 3,
  "retryDelayMs": 30000,
  "onError": "continue"
}'

Delete a topic

delete/api/topics/{name}

Deletes the topic. Its events, deliveries and their executions stay (the trail; each delivery keeps the retries it was published with) until execution retention removes them. Answers the workflows that still name it: their Publish steps fail until a topic of that name exists. Audited (topic.deleted).

Auth: Bearer token (how to get one) · Operation: deleteTopic

Parameters

NameInTypeDescription
namerequiredpathstring

The topic's name (its key in the workspace).

Responses

  • 200Deleted.
  • 404Topic not found in this workspace.

    application/json · ApiError

Example request

curl
curl -X DELETE "$ENGINE_URL/api/topics/adt.admit" \
  -H "Authorization: Bearer $TOKEN"

Check a topic change before saving it

post/api/topics/{name}/impact

Takes the PUT body and saves nothing. Answers the publishers and subscribers as deployed, how many of the latest 50 events a new schema would reject (checked, wouldReject, problems naming fields, never values), and whether the ordering key (orderingKeyChanged: ordering restarts) or retries (retriesChanged) change. No message content.

Auth: Bearer token (how to get one) · Operation: checkTopicChange

Parameters

NameInTypeDescription
namerequiredpathstring

The topic's name (its key in the workspace).

Request body (required)

application/json · object

  • descriptionstring | null
  • schemaobject | null

    JSON Schema subset the events must match: type, properties, required, items, enum, const, minimum, maximum, minLength, maxLength, minItems, maxItems, additionalProperties, title, description. Other keywords are refused. null takes any event.

  • orderingKeystring | null

    A field path read from each event ("MSH.4", "$.facility"). Events with the same value reach each subscriber one at a time, in publish order. An event without it runs unordered.

  • maxRetriesinteger

    Retries of a failed delivery before it is a dead letter; the subscriber workflow's own retry setting wins when higher.

  • retryDelayMsinteger
  • onErrorstring

    An ordered delivery that failed: continue with the key's next event, or hold that subscriber's lane for the key until it succeeds or is discarded.

    One of: "continue", "hold"

Responses

  • 200The impact.
  • 400Invalid schema or settings.

    application/json · ApiError

  • 404Topic not found in this workspace.

    application/json · ApiError

Example request

curl
curl -X POST "$ENGINE_URL/api/topics/adt.admit/impact" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "string",
  "schema": {},
  "orderingKey": "MSH.4",
  "maxRetries": 3,
  "retryDelayMs": 30000,
  "onError": "continue"
}'

Read one event's message

get/api/topics/{name}/events/{eventId}

The message as its subscribers received it. PHI: viewers get { eventId, redacted: true }; every read is audited (topic.event_viewed). kept: false when no delivery holds it any more.

Auth: Bearer token (how to get one) · Operation: getTopicEvent

Parameters

NameInTypeDescription
namerequiredpathstring

The topic's name (its key in the workspace).

eventIdrequiredpathstring

Responses

  • 200The event.
  • 404No such event on this topic.

    application/json · ApiError

Example request

curl
curl "$ENGINE_URL/api/topics/adt.admit/events/<eventId>" \
  -H "Authorization: Bearer $TOKEN"

Schemas

Named objects the operations above link to.

ApiError

The error body. error is always present. code is present on most errors and is the field to branch on; a few routes and the sign-in and role checks return only error (and sometimes detail).

  • errorstringrequired

    Human-readable error message.

  • codestring

    Machine-readable error code.

    One of: "BAD_REQUEST", "INVALID_REQUEST", "UNAUTHORIZED", "UNAUTHENTICATED", "FORBIDDEN", "NOT_FOUND", "CONFLICT", "UNPROCESSABLE_ENTITY", "RATE_LIMITED", "INTERNAL_ERROR", "SERVICE_UNAVAILABLE", "NOT_CONFIGURED", "SIGNATURE_REQUIRED", "INVALID_SIGNATURE", "TIMESTAMP_REQUIRED", "TIMESTAMP_INVALID", "TIMESTAMP_OUT_OF_TOLERANCE", "INVALID_CREDENTIALS", "INVALID_TOKEN", "PAYLOAD_TOO_LARGE", "INVALID_NDJSON", "PHI_NOT_AUTHORIZED", "PHI_IN_SANDBOX", "IN_PROGRESS", "RETRY_SCHEDULED", "WORKFLOW_DISABLED", "CONFLICTING_SCOPE", "ALREADY_DELIVERED", "CHAIN_TOO_DEEP", "NO_FAILED_DESTINATION", "STALE_SCOPE", "UNKNOWN_DESTINATION", "NO_DESTINATIONS", "NOT_A_MESSAGE", "AI_FEATURES_DISABLED"

  • detailsany

    Optional structured context about the error.

Topic

  • idstringrequired
  • namestringrequired
  • descriptionstring | null
  • schemaobject | null

    JSON Schema subset the events must match: type, properties, required, items, enum, const, minimum, maximum, minLength, maxLength, minItems, maxItems, additionalProperties, title, description. Other keywords are refused. null takes any event.

  • orderingKeystring | null

    A field path read from each event ("MSH.4", "$.facility"). Events with the same value reach each subscriber one at a time, in publish order. An event without it runs unordered.

  • maxRetriesinteger

    Retries of a failed delivery before it is a dead letter; the subscriber workflow's own retry setting wins when higher.

  • retryDelayMsinteger
  • onErrorstring

    An ordered delivery that failed: continue with the key's next event, or hold that subscriber's lane for the key until it succeeds or is discarded.

    One of: "continue", "hold"

  • createdAtstring (date-time)
  • updatedAtstring (date-time)