Skip to content
SBDocs

Customers · Guides

Pass inputs to a run

Name a workflow's text on the canvas, then replace it for each run from your code.

Before you start
  • A workflow with a Text or Prompt builder node, and access to edit it in the app.
  • An API key with the runs:create scope.
You'll end with
A workflow whose prompt your code sets on every run.

A workflow built on the canvas runs with the text it was built with. To change that text from your code — a new prompt for every run — give the node a name, then pass a value for that name when you start the run. Nothing about the workflow changes; the value applies to that one run.

Which nodes can take an input#

  • A Text node: the value replaces its text.
  • A Prompt builder node: the value replaces its template, so it may contain {{input-a}}-style slots of its own.

Every input is a string. To vary a number or an image, build the workflow so a text value controls it, or create a new workflow.

Give a node an input name#

  1. Open the workflow on the canvas and select the Text or Prompt builder node.
  2. In the inspector, find API connection and type a name in API input key (in the simple view it is called Name for automations). Use something short and stable, such as subject: your code will use it.
  3. Keep the node's own text as the default. A run that passes no value for the name runs with it.

Creating the workflow from code instead? Set apiInputKey in the step's config, beside its text or template. See Workflow format.

Pass values when you start a run#

Send inputs, an object from input name to value, to Run a workflow or Run an agent:

Run a workflow with an input
WORKFLOW_ID="YOUR_WORKFLOW_ID"

curl -X POST "https://app.sushibelt.ai/api/v1/workflows/$WORKFLOW_ID/runs" \
  -H "Authorization: Bearer $SUSHIBELT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {
      "subject": "a red fox in snow"
    }
  }'

Leave out any input you do not want to change. An empty inputs, or no inputs at all, runs the workflow as it was built.

Find a workflow's input names#

The names are on the nodes in the app. From code, a run with a name the workflow does not have is refused before anything starts or is charged, with 422 and the names it does have in validKeys:

422 Unknown input keyJSON
{
  "error": "Unknown input key(s): subjct",
  "validKeys": ["subject", "style"]
}

Tip: check your names before a batch

Before starting many runs with the same names, start one and check it is not refused with 422. A misspelled name never falls back to the default: the run is refused.

Next steps