# API Flow Examples

All API workflows can be accessed via DevOps → Saga in the admin UI. In that screen, you’ll find the flows listed below under the “training” group.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2F2FBLoAjsSeSLyLqNLCPo%2Fimage.png?alt=media&#x26;token=47ef7a43-987a-4d57-a056-0cf3b7a973d9" alt=""><figcaption><p>Training Sagas</p></figcaption></figure>

## Saga: /train\_ping

This is the smallest end-to-end flow in the training domain. It wires a `Start` step straight to a `Success` step. It then echoes the incoming request payload back in the response. Use it as a smoke test for routing, authentication, and payload shape.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FUy7ZhG6ce4RAYrlLbXpx%2Fimage.png?alt=media&#x26;token=cb59a4eb-d0d7-43bb-a30f-a422d719e298" alt="" width="375"><figcaption><p>Ping Flow</p></figcaption></figure>

## Saga: /train\_hello

This flow adds a single transformation step to the basic ping pattern. It generates a deterministic output message, like `"Hello World"`, regardless of input. It is useful for learning how transform outputs become HTTP responses. It also helps confirm response mapping without touching any state.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FzXMfBVtC2lCQ52kIMcKm%2Fimage.png?alt=media&#x26;token=b1d9f655-185c-4d8d-976a-73e835dadfc5" alt="" width="302"><figcaption><p>Hello Flow</p></figcaption></figure>

## Saga: /train\_redirect

This flow demonstrates redirecting one endpoint to another saga. It reuses `train_hello` without defining its own step graph. That pattern keeps multiple endpoints consistent, while avoiding duplicate logic. It is also handy for deprecations and versioned routes.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2F9i0Y1zEtv5n0bJsiXnPf%2Fimage.png?alt=media&#x26;token=6322750f-86b9-4708-9e03-8939f0024fd7" alt="" width="563"><figcaption><p>Redirect Mapping</p></figcaption></figure>

## Saga: /train\_condition

This flow shows how branching works in sagas. A condition is evaluated and step links route execution to `Success` or `Fail`. It is a good template for validation or eligibility checks. Use the pattern when you need explicit “happy path” and “rejection path” responses.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FX8dD4JIMcDYhcYbClHPJ%2Fimage.png?alt=media&#x26;token=8a9b9d95-2073-4abf-b652-53b56341ac09" alt="" width="375"><figcaption><p>Condition Flow</p></figcaption></figure>

## Saga: /train\_get

This flow demonstrates a read operation against a state manager. It calls a local read handler to fetch a `dummy` record by `id`. The response payload is built from the record returned by the handler. Use it to understand how saga inputs map to state reads.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FAEGoshXGHMyLL08KMFbm%2Fimage.png?alt=media&#x26;token=5ecb0f47-4e8c-459f-ad7c-b077e705c8d9" alt="" width="305"><figcaption><p>Get Flow</p></figcaption></figure>

## Saga: /train\_set

This flow demonstrates a write operation against a state manager. It calls a local write handler to create or update a record in the `dummy` state manager. The request payload becomes the write input, with IDs and fields mapped by parameters. Use it as a baseline for POST/PUT style endpoints.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FJ0znSeq5MPZgxHovGxyB%2Fimage.png?alt=media&#x26;token=64bbc9aa-4f7b-4326-8ce9-76fc264c878e" alt="" width="302"><figcaption><p>Set Flow</p></figcaption></figure>

## Saga: /train\_query

This flow demonstrates server-side filtering with a reusable query definition. It calls a local query handler and executes the `"Dummy Search"` query. The query filters records by fields such as `name` and returns a list. Use it to learn how query parameters travel from API input to the query engine.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FPTquCilkZkPwCHwByGyP%2Fimage.png?alt=media&#x26;token=07a5e882-391f-46f6-b25f-c78a8b48a14b" alt="" width="305"><figcaption><p>Query Flow</p></figcaption></figure>

The query is accessible from the Query screen of the Configuration application. This is where the stored query text and parameters live. Updating it changes this endpoint’s behavior without editing the saga.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2Fyz0Sy3vzo4M1ATmN33Rx%2Fimage.png?alt=media&#x26;token=6d184083-6639-417a-b47b-b2ccd9328008" alt=""><figcaption><p>Dummy Search Query</p></figcaption></figure>

## Saga: /train\_rest

This flow demonstrates an outbound HTTP call from a saga. It uses the REST handler together with a configured `System` definition. The saga builds a request, sends a GET call to the remote system, then forwards the response. Use it for simple integrations and for validating network access from runners.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FUK9gQ5gx2mwul7p2pt7X%2Fimage.png?alt=media&#x26;token=3ba3136a-673a-4016-a7e2-c02ea054778b" alt="" width="375"><figcaption><p>Rest Flow</p></figcaption></figure>

This flow is also used in AI Agent example, and includes a simple input schema, which allows the AI agent to make calls to this flow in the correct data pattern. It also includes some optional instructions and mappings for the agent in AI tab.

## Saga: /train\_pattern

This flow builds on `train_rest` by parameterizing request and response mapping. It uses patterns in event metadata to inject values into the outbound request. It can also extract and reshape fields from the remote response into a clean API output. Use it when you need lightweight mapping without custom code.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FHzS39w36GiKpQE8FaoBf%2Fimage.png?alt=media&#x26;token=f845350a-071b-470e-aa93-3aca29a4e307" alt=""><figcaption><p>Pattern Parameters</p></figcaption></figure>

## Saga: /train\_secret

This flow demonstrates basic crypto utilities in a saga. It encrypts an input value using a preconfigured key. It then decrypts the value back and returns it for verification. Use it to understand how secrets and encryption helpers fit into API flows.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FkPy3pJ4ZkJUhHoCWb8Db%2Fimage.png?alt=media&#x26;token=2ebfe2b4-5b8b-4afe-a9d5-48bd1a00db85" alt="" width="366"><figcaption><p>Secret Flow</p></figcaption></figure>

## Saga: /train\_script

This flow executes a stored Groovy script from within the saga. The script reads parameters from the incoming payload. It then returns a computed payload, often echoing or reshaping inputs. Use it for fast prototyping when a transform step is not enough.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FBv1eLn5jUMukjr60Ymbu%2Fimage.png?alt=media&#x26;token=993d2a55-6ee3-4aee-a535-d9f89529864e" alt="" width="245"><figcaption><p>Script Flow</p></figcaption></figure>

The script itself is configured using the code editor accessible in Configuration application.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FSS1Lc2Q0aJLzIpeOEzUg%2Fimage.png?alt=media&#x26;token=85acf96b-9821-4a12-8c3d-4534f466c823" alt=""><figcaption><p>Executed Groovy Script</p></figcaption></figure>

## Saga: /train\_template

This flow renders a text output using a stored Handlebars template. It passes inputs like `name` and `surname` into the template context. The rendered string is returned as the API response, which is useful for emails or HTML snippets. Use it to learn template parameter binding and output formatting.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2F1e8IvJ7Z3CLfUZQpTOPb%2Fimage.png?alt=media&#x26;token=fde4f6bf-3125-489d-98c9-aa1c8b478d52" alt="" width="250"><figcaption><p>Template Flow</p></figcaption></figure>

The template itself is configured using the code editor accessible in Configuration application.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2F0MGbJaMKYZi0PQRN5KFK%2Fimage.png?alt=media&#x26;token=be2bdbf5-c18c-43c3-a895-e48fee4bfe47" alt=""><figcaption><p>Rendered Handlebars Template</p></figcaption></figure>

## Saga: /train\_hft

This flow demonstrates dynamic Java compilation and execution at runtime. It loads a Java class definition from stored configuration. It compiles the class and runs it as an event handler during the saga. Use it for advanced experiments, where you need real code without redeploying.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FEBqIyu5hQWPpMafvF7Nt%2Fimage.png?alt=media&#x26;token=471fd82b-eba4-4c50-8efb-33bff2e68699" alt="" width="248"><figcaption><p>HFT Flow</p></figcaption></figure>

The class itself is configured using the code editor accessible in Configuration application.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FqWR1udyyJdeQAe3nPSVn%2Fimage.png?alt=media&#x26;token=0a9a3b04-6e3f-4fec-b256-b43545ff47e2" alt=""><figcaption><p>Dynamic Java Class</p></figcaption></figure>

## Saga: /train\_rule

This flow evaluates a list of rules against the incoming payload. It returns the selected outcome value after rule matching. It is a good template for pricing, routing, or classification decisions. Use it to see how business rules can be changed without code changes.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2F1mGzZwvQP9Jo3Se1UgCG%2Fimage.png?alt=media&#x26;token=276f091f-e359-4506-9e7d-553b68793bfc" alt=""><figcaption><p>Simple Rule Flow</p></figcaption></figure>

The rule list for calculation is configured using the rule records accessible in Configuration application.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FthFIlxwjFhjJzATRbc56%2Fimage.png?alt=media&#x26;token=ea00b9e6-eecf-4803-83a0-b0907b9c73ed" alt=""><figcaption><p>Rule Configuration</p></figcaption></figure>

## Saga: /train\_mock

This flow returns a fixed example response without calling any backend. It is intended for mocking endpoints during UI or integration development. You can keep contract tests moving while the real logic is not ready. Later you can swap the mock for real steps without changing the route.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2Fk6yYAIaJoDYEZGeif8hS%2Fimage.png?alt=media&#x26;token=678c2eb3-1893-499c-aa2f-aadee4894dba" alt=""><figcaption><p>Mocking Configuration</p></figcaption></figure>

## Saga: /train\_for

This flow demonstrates looping over a list in the payload. It runs the same action for each item, such as rendering a template per entry. It typically produces an aggregated output list or concatenated result. Use it when you need per-item enrichment without writing code.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2Fs31qYk13aQ3N6DMp5PMz%2Fimage.png?alt=media&#x26;token=af591aa1-7579-4dfc-848e-6dee37cb53cb" alt=""><figcaption></figcaption></figure>

## Saga: /train\_parallel

This flow demonstrates fan-out execution. It triggers two independent branches at the same time. It then continues once both branches complete, typically combining their outputs. Use it to reduce latency when you call multiple systems.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FjucxZ4HufGytAaasFtHC%2Fimage.png?alt=media&#x26;token=d17d4dd6-2ff6-4a71-9bae-401f11c2bd74" alt=""><figcaption></figcaption></figure>

## Saga: /train\_nested

This flow calls another saga from within a parent saga. It passes a payload into the nested saga and receives its output. This is the main reuse mechanism for shared business logic. Use it to keep complex flows modular and easier to test.

<figure><img src="https://1659095931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcnDk3J1AzTgg2NFrGPlh%2Fuploads%2FRAR6h52JV46ff6tiHOAO%2Fimage.png?alt=media&#x26;token=f3a2d324-e60b-4a26-a0d7-300eb094c41e" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.rierino.com/examples/training-examples/api-flow-examples.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
