Skip to main content
POST
/
v1
/
workflows
/
runs
/
{run_id}
/
steps
/
{block_id}
/
simulate
from retab import Retab

client = Retab()

simulation = client.workflows.blocks.simulate(
    run_id="wfrun_def456",
    block_id="extract-invoice",
    n_consensus=5,
)

if simulation.success:
    print(simulation.handle_outputs)
else:
    print(simulation.error)
{
  "id": "sim_abc",
  "organization_id": "org_123",
  "workflow_id": "wf_abc123",
  "run_id": "wfrun_def456",
  "block_id": "extract-invoice",
  "block_type": "extract",
  "success": true,
  "handle_inputs": {
    "input-document-0": { "type": "file", "filename": "invoice_q1.pdf" }
  },
  "artifact": { "operation": "extraction", "id": "ext_xyz" },
  "handle_outputs": {
    "output-json-0": { "type": "json", "data": { "total": 1234.56 } }
  },
  "duration_ms": 412.0,
  "skipped": false,
  "step_id": "extract-invoice",
  "block_config": { "model": "gpt-5", "json_schema": { "type": "object" } }
}

Documentation Index

Fetch the complete documentation index at: https://docs.retab.com/llms.txt

Use this file to discover all available pages before exploring further.

Replay one workflow block using inputs from a previous run plus the current draft block config. The block executes once but its result is not persisted into the run — useful for testing config changes without re-running the whole workflow. The route is keyed by run_id (the workflow run whose recorded inputs feed the block), not by workflow_id. Behavior:
  1. Looks up the run and verifies the upstream subgraph hasn’t drifted since it executed (skip with check_eligibility=false).
  2. Fetches the block’s handle_inputs from the run’s recorded step data.
  3. Loads the block’s current draft config (not the published snapshot).
  4. Executes the block.
  5. Returns the produced outputs and a canonical artifact ref where the block produces a persisted resource (extract → extraction, split → split, etc.).
Query params:
  • n_consensus3 / 5 / 7. Only meaningful for extract, split, and classifier blocks; ignored otherwise.
  • step_id — for blocks inside a for_each or while_loop, pick a specific iteration. Defaults to the base step or the first iteration.
  • check_eligibility — defaults to true. Returns 409 if the upstream subgraph changed since run_id executed. Pass false to skip the check.
Unsupported block types: start, start_json, hil, api_call, plus display-only blocks like note.
from retab import Retab

client = Retab()

simulation = client.workflows.blocks.simulate(
    run_id="wfrun_def456",
    block_id="extract-invoice",
    n_consensus=5,
)

if simulation.success:
    print(simulation.handle_outputs)
else:
    print(simulation.error)
{
  "id": "sim_abc",
  "organization_id": "org_123",
  "workflow_id": "wf_abc123",
  "run_id": "wfrun_def456",
  "block_id": "extract-invoice",
  "block_type": "extract",
  "success": true,
  "handle_inputs": {
    "input-document-0": { "type": "file", "filename": "invoice_q1.pdf" }
  },
  "artifact": { "operation": "extraction", "id": "ext_xyz" },
  "handle_outputs": {
    "output-json-0": { "type": "json", "data": { "total": 1234.56 } }
  },
  "duration_ms": 412.0,
  "skipped": false,
  "step_id": "extract-invoice",
  "block_config": { "model": "gpt-5", "json_schema": { "type": "object" } }
}

Authorizations

Api-Key
string
header
required

Path Parameters

run_id
string
required
block_id
string
required

Query Parameters

n_consensus
integer | null
step_id
string | null
check_eligibility
boolean
default:true
access_token
string | null

Response

Successful Response

A stored simulation result for a single workflow block.

id
string
required

Unique simulation ID

organization_id
string
required

Organization that owns this simulation

workflow_id
string
required

Workflow the block belongs to

run_id
string
required

Run whose inputs were used

block_id
string
required

ID of the block that was simulated

block_type
string
required

Type of the block

success
boolean
required

Whether simulation succeeded

handle_inputs
Handle Inputs · object

Input payloads keyed by handle ID (file metadata for files, data for json)

artifact
StepArtifactRef · object

Canonical persisted-ref artifact for this simulation (operation + id), if any

handle_outputs
Handle Outputs · object

Output payloads keyed by handle ID

routing_decision
string[] | null

Active output handles for routing decisions

error
string | null

Error message if simulation failed

duration_ms
number | null

Duration of the simulation in milliseconds

skipped
boolean
default:false

Whether the block was skipped due to missing inputs

created_at
string<date-time>
block_config
Block Config · object

The draft block config used for this simulation

step_id
string | null

The step ID that was used for inputs (includes iteration prefix if applicable)

available_iterations
Available Iterations · object[] | null

When the block has multiple iterations, lists all available ones