> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step/flow-actions/orchestrate-saga.md).

# Orchestrate Saga

These actions provide ability to coordinate end-to-end API calls, locally executing or distributing microservice steps across the platform.

## Orchestrate Saga Actions

### StartSaga

Initiates execution of a new saga, using the `sagaPath` parameter of the requesting event, or the request metadata path if not defined. The request is accepted only if there is an active saga matching this path.

When called from within another saga, following event metadata fields are applicable for this action:

{% tabs %}
{% tab title="Table" %}

| Field          | Definition                                         | Example    | Default |
| -------------- | -------------------------------------------------- | ---------- | ------- |
| Input Element  | Json path for the input in request event payload   | parameters | -       |
| Output Element | Json path for the output in response event payload | result     | -       |
| {% endtab %}   |                                                    |            |         |

{% tab title="JSON Schema" %}

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "eventMeta": {
      "type": "object",
      "properties": {
        "inputElement": {
          "type": "string",
          "definition": "Json path for the input in request event payload",
          "example": "parameters",
          "default": null
        },
        "outputElement": {
          "type": "string",
          "definition": "Json path for the output in response event payload",
          "example": "result",
          "default": null
        }
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

With the following event metadata parameters:

{% tabs %}
{% tab title="Table" %}

| Parameter      | Definition                                                                          | Example        | Default |
| -------------- | ----------------------------------------------------------------------------------- | -------------- | ------- |
| Saga Path      | Path of the saga to call                                                            | /ListCustomers |         |
| Fire Forget    | Whether this call works asynchronously. This uses the common Fire & Forget setting. | true           | false   |
| Input Pattern  | JMESPath pattern to apply on data input                                             | -              | -       |
| Output Pattern | JMESPath pattern to apply on data output, before returning response                 | -              | -       |
| Start Step     | ID of the step to start saga execution from                                         | 3              | -       |
| Stop Step      | ID of the step to stop saga execution at                                            | 10             | -       |
| {% endtab %}   |                                                                                     |                |         |

{% tab title="JSON Schema" %}

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "eventMeta": {
      "type": "object",
      "properties": {
        "parameters": {
          "type": "object",
          "properties": {
            "sagaPath": {
              "type": "string",
              "definition": "Path of the saga to call",
              "example": "/ListCustomers",
              "default": null
            },
            "fireForget": {
              "type": "string",
              "definition": "Whether specific call to saga should work async (in case saga itself is not configured as such)",
              "default": "false"
            },
            "inputPattern": {
              "type": "string",
              "definition": "JMESPath pattern to apply on data input",
              "example": null,
              "default": null
            },
            "outputPattern": {
              "type": "string",
              "definition": "JMESPath pattern to apply on data output, before returning response",
              "example": null,
              "default": null
            },
            "startStep": {
              "type": "string",
              "definition": "ID of the step to start saga execution from",
              "example": "3"
            },
            "stopStep": {
              "type": "string",
              "definition": "ID of the step to stop saga execution at",
              "example": "10"
            }
          }
        }
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Nested sagas should only be used within the same runner as they do not replicate original event payload and metadata during execution for stateless distribution.
{% endhint %}

### StepSaga

Executes the next action after a saga step is completed by an event runner, using the saga id and step id in event saga metadata.

{% hint style="info" %}
Unlike the other event handlers, SagaEventHandler is rarely called from within saga flows, as it acts as a coordinator rather than a simple task executor.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/devops/api-event-and-process-flows/configuring-saga-steps/event-step/flow-actions/orchestrate-saga.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
