Flows is currently in beta and is subject to change as the platform evolves
input: the schema for the data required to start the FlowstartsAt: the first state to executestates: the workflow definitionoutput: the shape of the final result returned by the Run- metadata: optional fields such as
name,description, andversion
Template Structure
Theinput section defines the contract for starting a Run. This is the shape your application must satisfy when it provides inputData.
The states section defines the workflow itself. Each state represents a unit of execution, such as calling a Sohar API, making a decision, or waiting for more input.
The output section defines the final response shape for the Flow. When a Run completes, the API returns the result of evaluating this output mapping for that specific execution.
A minimal template looks like this:
Input
Each Flow template defines the input required to start a Run. This is declared in the template’sinput section as a schema. When a Run is created, the inputData provided by the caller must match that schema.
In practical terms, the input section defines the contract for using the Flow. It tells you what data must be available at the start of execution, before any states run.
For example, a Flow that begins with a Verification request may require input such as patient details, payer information, member ID, place of service code, and specialty code. A Flow that begins with Discovery may require a smaller input shape, such as patient information alone.
A simple input definition might look like this:
States
Flows currently support three main state types:requestchoicecallback
end: true.
Request States
Arequest state calls a supported Sohar API as part of the workflow.
Use request states when you want the Flow to perform work such as creating a Verification, running Discovery, or invoking another supported product operation. A request state defines the resource to call, and it must either specify the next state or mark itself as terminal with end: true.
Request states can also control how data moves through the workflow:
overridelets you adjust the runtime context before the request runsresultSelectorlets you map values from the API response back into the Flow context for use in later states
Using Result Selector
UseresultSelector when a later step needs data from the API response returned by the request state.
For example, a Verification request may return a status that you want to use in a later choice state. In that case, resultSelector can copy the value into the Flow context:
$.verificationStatus is available to the rest of the Flow.
Using Override
Useoverride when a request should run with a modified version of the current runtime context.
This is useful when you want to set or replace values for a specific request without changing the original input contract of the Flow. For example, you may want to force a specific payer ID before running a request:
payerId set to “00001” in the effective runtime context for that state.
Choice States
Achoice state adds branching logic.
Choice states evaluate conditions in order and take the first matching branch. This lets you model workflow logic such as:
- if required data is present, continue to one step
- if a result indicates success, take one branch
- if a result indicates a pending or error condition, take another
Callback States
Acallback state pauses the workflow and waits for additional input.
Use callback states when a Flow cannot continue with the data available at the start of the Run. This is useful for human-in-the-loop workflows, conditional follow-up collection, or integrations where some information becomes available later.
When a Run reaches a callback state, it moves to PENDING. The callback step defines the input contract for the additional data required to continue.
Context
Context is the runtime data available to a Flow as it executes. You can think of it as the working memory for a Run. It begins with theinputData provided when the Run starts, and then evolves as the workflow progresses.
At runtime, context is built from:
- the initial
inputDataprovided when the Run is created - any
callbackinput submitted later while the Run isPENDING - any values written back into context by a request state’s
resultSelector
Why Context Matters
Request states execute against the current context. In practice, this means the data in context needs to match the input shape expected by the Sohar API the state is calling. If a request state invokes Verification, the context must contain the fields that Verification expects. If a later state invokes Discovery or Cost Estimate, the context must contain the fields required by those APIs at that point in the workflow. To determine what fields a request state needs in context, refer to the API documentation for the Sohar product that state calls. In general, the context available at that point in the Flow should match the request shape that product expects. For example:- a Verification request expects a shape like
patient,payerId,memberId,placeOfServiceCode, andspecialtyCode - a Discovery request expects a shape like
patient
Output
Each Flow template also defines the output returned when a Run completes. This is declared in the template’soutput section. Rather than returning the raw response from a single Sohar API, a Flow returns the result of evaluating the template’s output mapping for that specific Run.
In practical terms, the output section defines the final response contract for the Flow. It lets you decide which values from the workflow should be exposed to the caller, and how those values should be shaped.
A simple output definition might look like this:
verificationStatus and verificationId, regardless of how many states the Flow executed internally to produce those values.
When designing a Flow, it is helpful to think of output as the public interface of the completed workflow. The Flow may execute several internal states, but the output should expose only the final data the caller actually needs.
Flow Logic
Choice states are how Flows make decisions at runtime. Eachchoice evaluates a variable from the runtime context and applies a single operator. Choices are evaluated from top to bottom, and the first match wins. If nothing matches, the Flow uses the default path. If no default is defined, execution fails.
Supported operators are:
isPresent,isNullisTruthy,isFalsystringEquals,stringMatchesnumericEquals,lt,gt,lte,gte