# Triggers

> Start workflows from webhooks and other workflows, and manage ingress bindings.

Source: https://docs.sommatic.ai/en/api/reference/triggers/

## Trigger a workflow via chain invocation

`POST /workflow-orchestration/trigger/chain/{mode}`

Dispatches a workflow execution from another workflow's chain node. Resolves the target workflow by slug or definition ID. The mode determines whether the test (draft) or production (published version) is executed.

Authentication: Bearer token

### Parameters

- `mode` (path, string, required): Execution mode. "test" executes the draft, "prod" executes the published version. Allowed values: `test`, `prod`.

### Request body

Chain invocation payload with target workflow and input data.

- `organization_id` (string, required): The organization scope for the target workflow.
- `target_flow_slug` (string): The slug of the target workflow to invoke.
- `target_flow_definition_id` (string): Explicit flow definition ID. Takes precedence over slug.
- `execution_mode` (string): Sync waits for completion. Async returns immediately. Allowed values: `sync`, `async`.
- `data` (object): Input data to pass to the target workflow.
- `chain_context` (object): Traceability metadata from the calling workflow.
  - `caller_flow_instance_id` (string)
  - `caller_flow_slug` (string)
  - `caller_node_id` (string)
  - `correlation_id` (string)

### Responses

- `200`: Workflow executed successfully (sync mode).
- `202`: Workflow dispatched (async mode).
- `404`: Target workflow not found.
- `500`: Internal Server Error.

### Example request

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/trigger/chain/<mode>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "organization_id": "<organization_id>"
     }'
```

## dispatchChainStream (/workflow-orchestration/trigger/chain/:mode/stream)

`POST /workflow-orchestration/trigger/chain/{mode}/stream`

Authentication: Bearer token

### Parameters

- `mode` (path, string, required)

### Responses


### Example request

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/trigger/chain/<mode>/stream" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -N
```

## Trigger a workflow via webhook

`POST /workflow-orchestration/trigger/webhooks/{mode}/{bindingIdentifier}`

External entry point to execute a workflow from any system capable of
issuing an HTTP POST. The request is resolved to an `IngressBinding`
by id or custom slug, and its target `FlowDefinition` is dispatched
to the orchestrator.

The raw HTTP request is forwarded to the workflow as its initial
`$input` with the shape `{ body, headers, query, method }`.
Downstream nodes access the POSTed payload via `{{ $json.body.<field> }}`
or by upstream-node reference
`{{ $('Webhook Receiver').item.json.body.<field> }}`.

By default the call is synchronous and returns the full orchestrator
result. For long-running workflows, set `execution_mode=async` —
the response returns immediately with an `instance_id`, and progress
can be followed via the SSE channel at
`/workflow-orchestration/execution/stream`.

The endpoint is unauthenticated by design. Per-binding authentication
(shared secret, signature verification, IP allow-list) is a concern
of the `IngressBinding` configuration, not of this route.

Authentication: Authenticated by the ingress binding

### Parameters

- `mode` (path, string, required): `test` runs the draft; `prod` runs the latest published version. Allowed values: `test`, `prod`.
- `bindingIdentifier` (path, string, required): `IngressBinding` id (preferred) or its custom slug.
- `execution_mode` (query, string): Override the default `sync` behavior with `async` for long-running flows. Allowed values: `sync`, `async`.

### Request body

Arbitrary JSON payload. The full JSON becomes `$json.body` inside
the workflow. Two convenience keys are read back from the body when
present: `event` (routing hint) and `execution_mode` (same behavior
as the query param).


### Responses

- `202`: Accepted. In `sync` mode the response contains the final
orchestrator result. In `async` mode it returns immediately with
`status: running` and the `instance_id` to track via the SSE
stream.
- `400`: Missing or invalid path/query parameters.
- `404`: `IngressBinding` not found, or its target `FlowDefinition` does
not resolve to an existing workflow. In `prod` mode also returned
when no default version is published.
- `413`: Request body exceeded the per-route limit (5 MB).
- `500`: Orchestrator unreachable or unhandled error during dispatch.

### Example request

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/trigger/webhooks/<mode>/<bindingIdentifier>" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Create a new ingress binding.

`POST /workflow-orchestration/triggers/ingress-binding/`

Returns the created Ingress Binding with data provided.

Authentication: Bearer token

### Request body

IngressBinding object to be created.

- `organization_id` (string, required): ID of the organization to which this ingress binding belongs.
- `slug` (string, required): Stable semantic key uniquely identifying this ingress binding (e.g. ingress.http.email_inbound, ingress.queue.support_tickets).
- `ingress_kind` (string, required): Type of ingress surface: "http", "webhook", "queue", "event-grid", "cron", "pubsub", "s3-event", etc.
- `description` (string): Optional human-readable description of the ingress behavior and purpose.
- `route` (string): Path, topic, subscription or expression for this binding. For webhook bindings created without a route, the service sets "/trigger/webhooks/{test|prod}/{slug or id}"; the public endpoint is POST /workflow-orchestration/trigger/webhooks/{mode}/{bindingIdentifier}. Examples: - "/trigger/webhooks/prod/ingress.http.inbound_email" - "queue:support_tickets" - "topic:user.events" - "cron:0 /5 * * * *"
- `target_trigger_id` (string): Identifier of the TriggerModel that should receive events from this ingress binding.
- `target_flow_version_id` (string): Optional direct reference to a FlowVersionModel if bypassing TriggerModel (advanced mode).
- `target_flow_definition_id` (string): Optional direct reference to a FlowDefinitionModel for webhook triggers bound to draft flows.
- `authentication` (object): Authentication and authorization requirements for this ingress endpoint.
  - `mode` (string): "none", "api-key", "oauth2", "veripass-session", "service-token", "custom".
  - `allowed_api_keys` (array<string>)
  - `oauth_scopes` (array<string>)
  - `veripass_policy` (string): Optional Veripass policy required to access this ingress endpoint (role, scope, context rules).
- `payload_mapping` (object): Rules for decoding and validating incoming payloads. Defines how external data translates into the internal EnvelopeModel payload.
  - `content_type` (string): "json", "form-data", "text", "binary", "base64", or custom parser identifiers.
  - `json_path` (string): Optional JSONPath-like selector for extracting a substructure of the payload.
  - `raw_body` (boolean): When true, the raw HTTP body is preserved in the envelope.
  - `schema` (object): Optional JSON-schema-like structure for validating incoming payloads.
- `correlation_strategy` (string): Strategy for deriving or generating correlation_id for the envelope: - "from-header" - "from-payload" - "auto-generate" - "custom-rule"
- `correlation_field` (string): Field name used when correlation_strategy references headers or payload (e.g. "x-correlation-id").
- `instance_creation` (object): Rules describing whether and how new FlowInstanceModel executions are created when events are received.
  - `mode` (string): "always-new", "resume-existing", "merge", "conditional", "none".
  - `resume_lookup_key` (string): Field (header or payload) used to find an existing flow instance in "resume-existing" mode.
- `rate_limit` (object): Optional ingress-level rate limiting to prevent excessive activation.
  - `rpm` (integer)
  - `rps` (integer)
- `is_system` (boolean): True if this binding is managed internally by the platform.
- `is_enabled` (boolean): True if this ingress binding is currently active.
- `target_node_id` (string): Node ID within the flow graph to which this binding is bound. Enables 1-binding-pair-per-node constraint.
- `mode` (string): Execution mode for this binding: "test" (executes draft via flow_definition_id) or "production" (executes published version via flow_version_id). Allowed values: `test`, `production`.
- `is_deprecated` (boolean): True if this binding should not be used for new integrations.

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X POST "https://api.sommatic.ai/workflow-orchestration/triggers/ingress-binding/" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "organization_id": "<organization_id>",
       "slug": "<slug>",
       "ingress_kind": "<ingress_kind>"
     }'
```

## Update an existing ingress binding.

`PATCH /workflow-orchestration/triggers/ingress-binding/`

Updates the data of an existing Ingress Binding with the data provided.

Authentication: Bearer token

### Request body

IngressBinding object to be created.

- `organization_id` (string, required): ID of the organization to which this ingress binding belongs.
- `slug` (string, required): Stable semantic key uniquely identifying this ingress binding (e.g. ingress.http.email_inbound, ingress.queue.support_tickets).
- `ingress_kind` (string, required): Type of ingress surface: "http", "webhook", "queue", "event-grid", "cron", "pubsub", "s3-event", etc.
- `description` (string): Optional human-readable description of the ingress behavior and purpose.
- `route` (string): Path, topic, subscription or expression for this binding. For webhook bindings created without a route, the service sets "/trigger/webhooks/{test|prod}/{slug or id}"; the public endpoint is POST /workflow-orchestration/trigger/webhooks/{mode}/{bindingIdentifier}. Examples: - "/trigger/webhooks/prod/ingress.http.inbound_email" - "queue:support_tickets" - "topic:user.events" - "cron:0 /5 * * * *"
- `target_trigger_id` (string): Identifier of the TriggerModel that should receive events from this ingress binding.
- `target_flow_version_id` (string): Optional direct reference to a FlowVersionModel if bypassing TriggerModel (advanced mode).
- `target_flow_definition_id` (string): Optional direct reference to a FlowDefinitionModel for webhook triggers bound to draft flows.
- `authentication` (object): Authentication and authorization requirements for this ingress endpoint.
  - `mode` (string): "none", "api-key", "oauth2", "veripass-session", "service-token", "custom".
  - `allowed_api_keys` (array<string>)
  - `oauth_scopes` (array<string>)
  - `veripass_policy` (string): Optional Veripass policy required to access this ingress endpoint (role, scope, context rules).
- `payload_mapping` (object): Rules for decoding and validating incoming payloads. Defines how external data translates into the internal EnvelopeModel payload.
  - `content_type` (string): "json", "form-data", "text", "binary", "base64", or custom parser identifiers.
  - `json_path` (string): Optional JSONPath-like selector for extracting a substructure of the payload.
  - `raw_body` (boolean): When true, the raw HTTP body is preserved in the envelope.
  - `schema` (object): Optional JSON-schema-like structure for validating incoming payloads.
- `correlation_strategy` (string): Strategy for deriving or generating correlation_id for the envelope: - "from-header" - "from-payload" - "auto-generate" - "custom-rule"
- `correlation_field` (string): Field name used when correlation_strategy references headers or payload (e.g. "x-correlation-id").
- `instance_creation` (object): Rules describing whether and how new FlowInstanceModel executions are created when events are received.
  - `mode` (string): "always-new", "resume-existing", "merge", "conditional", "none".
  - `resume_lookup_key` (string): Field (header or payload) used to find an existing flow instance in "resume-existing" mode.
- `rate_limit` (object): Optional ingress-level rate limiting to prevent excessive activation.
  - `rpm` (integer)
  - `rps` (integer)
- `is_system` (boolean): True if this binding is managed internally by the platform.
- `is_enabled` (boolean): True if this ingress binding is currently active.
- `target_node_id` (string): Node ID within the flow graph to which this binding is bound. Enables 1-binding-pair-per-node constraint.
- `mode` (string): Execution mode for this binding: "test" (executes draft via flow_definition_id) or "production" (executes published version via flow_version_id). Allowed values: `test`, `production`.
- `is_deprecated` (boolean): True if this binding should not be used for new integrations.

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X PATCH "https://api.sommatic.ai/workflow-orchestration/triggers/ingress-binding/" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "organization_id": "<organization_id>",
       "slug": "<slug>",
       "ingress_kind": "<ingress_kind>"
     }'
```

## Delete a Ingress Binding by its id.

`DELETE /workflow-orchestration/triggers/ingress-binding/`

Deletes a Ingress Binding based on the provided ID.

Authentication: Bearer token

### Request body

ID of the Ingress Binding to delete

- `id` (string)

### Responses

- `200`: OK.
- `500`: Something went wrong while performing this action.

### Example request

```bash
curl -X DELETE "https://api.sommatic.ai/workflow-orchestration/triggers/ingress-binding/" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
       "id": "<id>"
     }'
```

## Get an Ingress Binding by query selector.

`GET /workflow-orchestration/triggers/ingress-binding/{queryselector}`

Returns the Ingress Binding information that matches the query selector an search specified in the route.

Authentication: Bearer token

### Parameters

- `queryselector` (path, enum, required): Is the filter available for this query Allowed values: `id`, `organization-id`, `all`.
- `search` (query, string): Keyword to search for entities.
- `include_status` (query, string): Optional status parameter to include ingress bindings of a specific status.
- `exclude_status` (query, string): Optional status parameter to exclude ingress bindings of a specific status.
- `page` (query, integer): Page number, starting at 1 (default 1).
- `pageSize` (query, integer): Records per page (default 25).

### Responses

- `200`: OK.
- `500`: Something was wrong while you make this action.

### Example request

```bash
curl -X GET "https://api.sommatic.ai/workflow-orchestration/triggers/ingress-binding/<queryselector>" \
  -H "Authorization: Bearer $SOMMATIC_TOKEN"
```
