Skip to content

Triggers API

Auth: API key. Scopes: triggers:read / triggers:write (management) and runs:write (firing).

Base path: /v1/triggers

A trigger is how work starts. It points at a blueprint diagram (sourceId) and has a type that decides how runs are created. See Triggers (concepts).

typeStarts a run whenType-specific fields
webYou fire POST /v1/triggers/:triggerIdNone
searchA query matches (optionally on a schedule)queryId, optional schedule
eventA connected-system event matchesevent

POST /v1/triggers/:triggerId

Only type: "web" triggers can be fired over HTTP. This is what your backend, a form, or a job hits when something happens on your side. Requires runs:write.

Firing a search or event trigger returns 409 (trigger_not_web).

bash
curl -X POST "https://api-staging.medflow.care/v1/triggers/TRIGGER_ID" \
  -H "Authorization: Bearer $MEDFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "payload": {
      "patientId": "pt-12345",
      "externalRef": "order-abc"
    },
    "autoStart": true
  }'
FieldRequiredDescription
payloadNoJSON context for the run (ids, refs)
idempotencyKeyNoOptional if Idempotency-Key header is set
autoStartNoOverrides the trigger default

Response 201

json
{
  "runId": "<uuid>",
  "sourceId": "<uuid>",
  "triggerId": "<uuid>",
  "idempotencyKey": "<string> | null",
  "automationStatus": "<AutomationStatus>",
  "createdAt": "<ISO 8601>"
}

When autoStart is false, the run starts as queued. Otherwise it moves to scheduled and then running (see Automation status). Audited as run.create.


POST /v1/triggers

Every trigger shares a small set of fields. Extra options depend on type.

FieldRequiredDescription
nameYesDisplay name
sourceIdYesBlueprint id (Diagrams)
typeYesweb, search, or event
autoStartNoDefault true. Start automation when a run is created
activeNoDefault true. Whether the trigger is enabled

No extra fields. Fire it with Fire a trigger. Partner Quickstart triggers are created as web.

bash
curl -X POST "https://api-staging.medflow.care/v1/triggers" \
  -H "Authorization: Bearer $MEDFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Partner intake",
    "sourceId": "SOURCE_ID",
    "type": "web",
    "autoStart": true,
    "active": true
  }'
FieldRequiredDescription
queryIdYesQuery that selects who to start pathways for
scheduleNoRecurring cadence (for example nightly). Omit to run on demand only
bash
curl -X POST "https://api-staging.medflow.care/v1/triggers" \
  -H "Authorization: Bearer $MEDFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Nightly screening cohort",
    "sourceId": "SOURCE_ID",
    "type": "search",
    "queryId": "QUERY_ID",
    "schedule": { "interval": "daily", "timezone": "America/New_York" },
    "autoStart": true,
    "active": true
  }'
FieldRequiredDescription
eventYesEvent type to match (for example order.signed). See Webhooks and the Connections catalog
bash
curl -X POST "https://api-staging.medflow.care/v1/triggers" \
  -H "Authorization: Bearer $MEDFLOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order signed follow-up",
    "sourceId": "SOURCE_ID",
    "type": "event",
    "event": "order.signed",
    "autoStart": true,
    "active": true
  }'

Response 201 (shape depends on type, with unused type-specific fields omitted or null)

json
{
  "triggerId": "<uuid>",
  "name": "<string>",
  "sourceId": "<uuid>",
  "type": "web | search | event",
  "queryId": "<uuid> | null",
  "event": "<string> | null",
  "schedule": "<Schedule> | null",
  "autoStart": <boolean>,
  "active": <boolean>,
  "createdAt": "<ISO 8601>",
  "updatedAt": "<ISO 8601>"
}

GET /v1/triggers

QueryDescription
typeweb / search / event
activetrue / false
sourceIdFilter by blueprint
limit / cursorPagination

GET /v1/triggers/:triggerId

Returns the trigger configuration. To start a run from a web trigger, fire it with POST.


PATCH /v1/triggers/:triggerId

Partial update. You can change shared fields (name, sourceId, autoStart, active) and the type-specific fields for the trigger’s current type. Changing type is not supported. Create a new trigger instead.


DELETE /v1/triggers/:triggerId

Response 204. Existing runs are retained, but no new runs can be started from the deleted trigger.