Skip to main content

Triggers

Event triggers watch for system events and automatically execute a linked workflow when conditions match. Use triggers to automate repetitive tasks such as generating embeddings whenever a new node is created in the knowledge graph.


List Triggers

GET /api/v1/triggers

Returns all triggers with optional filters. The response contains summary data only -- use the detail endpoint for full trigger configuration including filters and workflow_inputs.

curl http://localhost:8080/api/v1/triggers?event_source=node.create&enabled=true
ParameterTypeRequiredDefaultDescription
pageintNo1Page number (1-indexed)
page_sizeintNo50Items per page (max 1000)
event_sourcestringNonullFilter by event source (e.g. node.create)
enabledboolNonullFilter by enabled flag

Response 200 OK

{
"data": [
{
"id": "trg_abc123",
"name": "Auto-Embed on Node Create",
"event_source": "node.create",
"workflow_id": "system_workflow_generate_embeddings_v1",
"enabled": true,
"priority": 0,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00"
}
],
"pagination": {
"page": 1,
"page_size": 50,
"total_items": 1,
"total_pages": 1
}
}
note

The list endpoint returns TriggerSummaryResponse objects which exclude filters and workflow_inputs for performance. Fetch a single trigger to get the full configuration.


Get Trigger Stats

GET /api/v1/triggers/{trigger_id}/stats

Returns aggregate execution statistics for a single trigger, computed from the persisted execution history.

curl http://localhost:8080/api/v1/triggers/trg_abc123/stats
ParameterTypeRequiredDescription
trigger_idstring (path)YesTrigger ID

Response 200 OK

{
"total_executions": 42,
"successful_executions": 40,
"failed_executions": 2,
"success_rate": 0.9524,
"average_duration_ms": 0
}
FieldTypeDescription
total_executionsintTotal number of times this trigger has fired
successful_executionsintExecutions that completed successfully
failed_executionsintExecutions that failed
success_ratefloatRatio of successful to total executions
average_duration_msintAverage execution duration in ms
note

average_duration_ms always returns 0 in this release — execution-duration tracking is planned but not yet persisted.

Errors: 404 if the trigger does not exist.


Create Trigger

POST /api/v1/triggers

Creates a new event trigger linked to a workflow.

The local operator owns all triggers (single-user deployment).

curl -X POST http://localhost:8080/api/v1/triggers \
-H "Content-Type: application/json" \
-d '{
"name": "Auto-Embed on Node Create",
"event_source": "node.create",
"filters": {},
"workflow_id": "system_workflow_generate_embeddings_v1",
"workflow_inputs": null,
"enabled": true,
"priority": 0
}'
FieldTypeRequiredDefaultDescription
namestringYes--Human-readable trigger name
event_sourcestringYes--Event source to listen for (see Event Sources)
filtersobjectYes--Filter criteria applied to event data before firing
workflow_idstringYes--ID of the workflow to execute when the trigger fires
workflow_inputsobjectNonullStatic inputs passed to the workflow on each execution
enabledboolNotrueWhether the trigger is active
priorityintNo0Execution priority (lower values execute first)

Response 201 Created

{
"id": "trg_abc123",
"name": "Auto-Embed on Node Create",
"event_source": "node.create",
"filters": {},
"workflow_id": "system_workflow_generate_embeddings_v1",
"workflow_inputs": null,
"enabled": true,
"priority": 0,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00"
}

Get Trigger

GET /api/v1/triggers/{trigger_id}

Returns full details for a specific trigger, including filters and workflow_inputs.

Returns the trigger by ID. Returns 404 if no trigger with that ID exists.

curl http://localhost:8080/api/v1/triggers/trg_abc123
ParameterTypeRequiredDescription
trigger_idstring (path)YesTrigger ID

Response 200 OK

{
"id": "trg_abc123",
"name": "Auto-Embed on Node Create",
"event_source": "node.create",
"filters": {},
"workflow_id": "system_workflow_generate_embeddings_v1",
"workflow_inputs": null,
"enabled": true,
"priority": 0,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-01T12:00:00"
}

Errors: 404 if the trigger does not exist.


Update Trigger

PATCH /api/v1/triggers/{trigger_id}

Partial update -- only include the fields you want to change.

The local operator can update any trigger (single-user deployment).

curl -X PATCH http://localhost:8080/api/v1/triggers/trg_abc123 \
-H "Content-Type: application/json" \
-d '{
"enabled": false,
"priority": 10
}'
FieldTypeRequiredDescription
namestringNoTrigger name
event_sourcestringNoEvent source to listen for
filtersobjectNoFilter criteria (replaces existing)
workflow_idstringNoLinked workflow ID
workflow_inputsobjectNoStatic workflow inputs (replaces existing)
enabledboolNoActive flag
priorityintNoExecution priority

Response 200 OK -- returns the updated TriggerResponse.

{
"id": "trg_abc123",
"name": "Auto-Embed on Node Create",
"event_source": "node.create",
"filters": {},
"workflow_id": "system_workflow_generate_embeddings_v1",
"workflow_inputs": null,
"enabled": false,
"priority": 10,
"created_at": "2026-03-01T12:00:00",
"updated_at": "2026-03-09T14:30:00"
}

Errors: 404 if the trigger does not exist.


Delete Trigger

DELETE /api/v1/triggers/{trigger_id}

Permanently deletes a trigger.

The local operator can delete any trigger (single-user deployment).

curl -X DELETE http://localhost:8080/api/v1/triggers/trg_abc123
ParameterTypeRequiredDescription
trigger_idstring (path)YesTrigger ID

Response 204 No Content

No response body.

Errors: 404 if the trigger does not exist.


Event Sources

The event_source field is a free-form string following the {entity}.{action} convention. The trigger engine matches events by exact string comparison against the event_source of each enabled trigger.

Built-in event sources dispatched by Chaos Cypher:

Event SourceDispatched When
node.createA new node is added to the knowledge graph
node.updateAn existing node is modified
edge.createA new edge (relationship) is added to the knowledge graph
tip

These are the event sources used by the default seed triggers (Auto-Embed on Node Create / Update). Custom workflows and plugins can dispatch additional event sources via publish_event_sync().


Response Models

TriggerResponse

Returned by Get, Create, and Update endpoints.

FieldTypeDescription
idstringUnique trigger ID
namestringHuman-readable name
event_sourcestringEvent source the trigger listens for
filtersobjectFilter criteria applied to event data
workflow_idstringID of the linked workflow
workflow_inputsobject | nullStatic inputs passed to the workflow
enabledboolWhether the trigger is active
priorityintExecution priority
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp

TriggerSummaryResponse

Returned by the List endpoint. Same as TriggerResponse but excludes filters and workflow_inputs.

FieldTypeDescription
idstringUnique trigger ID
namestringHuman-readable name
event_sourcestringEvent source the trigger listens for
workflow_idstringID of the linked workflow
enabledboolWhether the trigger is active
priorityintExecution priority
created_atdatetimeCreation timestamp
updated_atdatetimeLast update timestamp