remagicaDocs home

Run a workflow

Run the nodes of a workflow your team built on the canvas, follow the run and collect its results.

A workflow is a canvas: pages of nodes (Prompt, Image, Video, Voice, Music, iterators and more) joined by edges. Your code can run any of its nodes, the same way the canvas's Run button does.

Needs workflows:read to read and follow, workflows:run to run and workflows:cancel to stop. Building or editing workflows needs workflows:write, which the Builder preset includes.

Find the workflow and its nodes

GET /workflows lists your workspace's workflows. GET /workflows/{workflowId} returns one, with its document: every page, node and edge, and each node's results.

The workflow's id is also in its URL when you open it in the app. Node ids are in the document, on each node.

Run nodes

curl https://api.remagica.com/api/v1/workflows/WORKFLOW_ID/runs \
  -H "x-api-key: $REMAGICA_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "nodeIds": ["node_video_1"], "count": 2 }'
  • nodeIds are the nodes to run. Each makes count results (1–20), or count per item when an iterator or splitter feeds it.
  • Nodes upstream aren't run again. Each node reads the result its inputs currently show.
  • The run's estimate is set aside from your credits when it starts. Send priceVersion from GET /pricing to be refused with 409 PRICE_CHANGED, not charged more, if prices rose.
  • A run that can't start is refused with 409 RUN_REFUSED. Its data.code says why (missing_input, already_running, out_of_credits, ...) and data.nodeIds says which nodes.

Follow it

  • Stream: GET /workflows/{workflowId}/events sends server-sent events: a result event each time a node's result changes, and a run event when a run ends. Nothing is replayed, so read the workflow when you connect. The stream ends after 15 minutes; reconnect to keep following.
  • Poll: GET /workflow-runs/{runId} returns the run's status (running, then completed, failed, cancelled or stopped), its results, creditsEstimated and creditsSpent.
  • Webhooks: workflow_run.succeeded and workflow_run.failed. See Webhooks.

Each result's outputs hold its files, with download URLs.

Stop it

POST /workflow-runs/{runId}/cancel stops a run, and POST /workflows/{workflowId}/results/{resultId}/cancel stops one result. Results that already finished are kept.

Download its files

A Section (group) of the canvas downloads as one zip, and so does everything one node has made. See Downloads and exports.

On this page