Skip to content

Introduction to scenarios

A scenario is a graph. Boxes (the actions) are joined by links that carry values and signals. The engine runs a box as soon as all of its wired inputs have received something.

In Restorm, this is what replaces the pre-request and post-request scripts of other API clients — with one decisive advantage: you can see the flow.

Right-click in the tree ▸ Add ▸ Scenario.

A complete scenario in the editor: an Input/Param node, an HTTP request, an assertion on the status code, a Handlebars extraction, an If condition and a Log

  • Chaining calls and passing a value from one to the next: create a resource, get its identifier, use it in the following call.
  • Checking: assertions, JSON schema validation, comparison.
  • Branching and looping: if, switch, for, forEach, while, retry.
  • Orchestrating several transports: open an MQTT subscription, trigger an action over HTTP, check the message arrives.
  • Automating: the same scenario runs in the interface and with no window in continuous integration.
NotionWhat it is
Box (node)An action. Ninety types are available — see the catalogue
PortA wiring point on a box, typed and directed
Link (edge)A wire between an output port and an input port
SelectorA path applied to the value in transit on a link (data.items[0].id)
Run variableA named value, set and re-read during the run
ParameterAn input to the scenario, supplied at launch or on the command line
OutputA result exposed to the scenario’s caller

They are not listed in the configuration: they are part of the box’s frame.

PortDirectionRole
inInputThe trigger. It accepts several incoming links and then waits for all of them to have arrived — this is the “wait for several branches to finish” barrier
errorOutputThe failure route. Everything that goes wrong leaves this way
doneOutputEmitted once the box and its whole downstream subgraph have finished

The done / value-output distinction matters: a value leaves as soon as it is produced, whereas done waits for everything that depends on it to be finished.

  1. Add an HTTP Request action and bind it to an existing request.
  2. Add an Assert action, operator eq.
  3. Draw a link from the request’s response port to the assertion’s a input, and put the selector status on that link.
  4. In the assertion, set b to 200.
  5. Click Play.

The assertion has two outputs, then and else: wire a Log or a Toast onto each to watch the result go by.