# Workflows (/cli/workflows)

Build, deploy, run, and inspect workflows from the terminal.

`sim workflows` is also spelled `sim workflow`.

These commands accept the [global options](/cli/commands#global-options).

## Workflows \[#workflows]

### List workflows \[#list-workflows]

```bash
sim workflows list [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--scope <value>` | No | Which lifecycle set to list: `active` (default) for live workflows, `archived` for workflows a `DELETE` archived. The folder filter resolves against active folders only, so pairing it with `archived` returns an empty page when the containing folder was archived too. Accepted values: `active`, `archived`. |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |
| `--deployed-only` | No | Return only workflows with an active deployment when true. |
| `--no-deployed-only` | No | Send --deployed-only as false. |
| `--limit <n>` | No | Maximum items to return (0 for everything). Defaults to `0`. |
| `--search <value>` | No | Case-insensitive substring match against the resource name. |
| `--sort-by <value>` | No | Field used to sort the result. Do not rely on case-insensitive ordering when sorting by `name`. Defaults to "position". Accepted values: `position`, `name`, `createdAt`, `updatedAt`, `runCount`. |
| `--sort-order <value>` | No | Sort direction. Defaults to "asc". Accepted values: `asc`, `desc`. |

API request and response schemas: [listWorkflows](/api-reference/workflows/listWorkflows).

### Get workflow \[#get-workflow]

```bash
sim workflows get <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [getWorkflow](/api-reference/workflows/getWorkflow).

### Create workflow \[#create-workflow]

```bash
sim workflows create [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--name <value>` | Yes | Workflow name. |
| `--description <value>` | No | Optional workflow description. |
| `--folder <value>` | No | Existing folder path (leading / optional); create it first with sim workflows mkdir \<path>. |

The new workflow's draft holds one Start block (start_trigger, named Start): connect the blocks you add from it.

API request and response schemas: [createWorkflow](/api-reference/workflows/createWorkflowV2).

### Update workflow \[#update-workflow]

```bash
sim workflows update <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--name <value>` | No | Replacement workflow name. |
| `--description <value>` | No | Replacement workflow description; null clears it. (--description null sends the word, not JSON null). |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |

API request and response schemas: [updateWorkflow](/api-reference/workflows/updateWorkflowV2).

### Duplicate workflow \[#duplicate-workflow]

```bash
sim workflows duplicate create <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--name <value>` | No | Name for the copy. Defaults to the source name, deduplicated within the folder. |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |

API request and response schemas: [duplicateWorkflow](/api-reference/workflows/duplicateWorkflow).

### Move workflows \[#move-workflows]

```bash
sim workflows move [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <value...>` | Yes | Workflows to move. Duplicates are collapsed. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). |
| `--to <value>` | Yes | Destination folder path; / moves the workflows to the workspace root. |

API request and response schemas: [moveWorkflows](/api-reference/workflows/moveWorkflows).

### Move a workflow to a folder \[#move-a-workflow-to-a-folder]

```bash
sim workflows mv <workflowId> <folder>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `folder` | Yes | Folder path as shown in the app; the leading / is optional |

API request and response schemas: [updateWorkflow](/api-reference/workflows/updateWorkflowV2).

### Delete workflow \[#delete-workflow]

This archives the workflow and its run history; restore with `workflows restore`.

```bash
sim workflows delete <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [deleteWorkflow](/api-reference/workflows/deleteWorkflowV2).

### Restore an archived workflow \[#restore-an-archived-workflow]

```bash
sim workflows restore <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [restoreWorkflow](/api-reference/workflows/restoreWorkflow).

## Draft state and edits \[#draft-state-and-edits]

### Get workflow state \[#get-workflow-state]

```bash
sim workflows state get <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [getWorkflowState](/api-reference/workflows/getWorkflowState).

### Replace workflow state \[#replace-workflow-state]

OAuth login or personal API key required.

This replaces the entire draft graph and cannot be undone.

```bash
sim workflows state replace <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--dry` | No | Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs. |
| `--no-dry` | No | Send --dry as false. |
| `--blocks <json\|@file>` | Yes | Blocks keyed by block id. (JSON, or @path / @- to read a file or stdin). |
| `--edges <json\|@file>` | Yes | Directed connections between blocks. (JSON, or @path / @- to read a file or stdin). |
| `--loops <json\|@file>` | No | Ignored on write: loop containers are recomputed from `blocks`. (JSON, or @path / @- to read a file or stdin). |
| `--parallels <json\|@file>` | No | Ignored on write: parallel containers are recomputed from `blocks`. (JSON, or @path / @- to read a file or stdin). |
| `--variables <json\|@file>` | No | Replacement variable set. Omit to leave the stored variables untouched. (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Conditional | Confirm this operation (required unless --dry). |

API request and response schemas: [replaceWorkflowState](/api-reference/workflows/replaceWorkflowState).

### Show a workflow’s draft as a compact read-only outline \[#show-a-workflows-draft-as-a-compact-read-only-outline]

```bash
sim workflows outline <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [getWorkflowOutline](/api-reference/workflows/getWorkflowOutline).

### Edit a workflow’s blocks, connections and settings with a batch of operations \[#edit-a-workflows-blocks-connections-and-settings-with-a-batch-of-operations]

OAuth login or personal API key required.

This edits the draft graph: the batch adds, edits, or deletes blocks and their edges as written.

```bash
sim workflows operations apply <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--dry` | No | Validate and lint without writing, auditing, or notifying collaborators. Returns the same validation, preparation warnings, lint findings, and ID-ownership conflicts (`409`) as a committed write. `needsRedeployment` describes the pre-write state. For semantic operations, `mintedBlockIds` is empty; `previewBlockIds` contains provisional IDs with a warning, since committing mints new IDs. |
| `--no-dry` | No | Send --dry as false. |
| `--operations <json\|@file>` | Yes | Edits to apply, in a single batch, keyed by operation_type: \[{"operation_type":"add","block_id":"my-fn","params":{"type":"function","name":"My Fn","inputs":{"code":"return {ok:true}"}}},{"operation_type":"edit","block_id":"\<uuid>","params":{"name":"Renamed","connections":{"source":"my-fn"}}},{"operation_type":"delete","block_id":"\<uuid>"}]. Also extract_from_subflow, whose params carry {"subflowId":"\<loop-id>"}, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId. To move an existing block into a loop or parallel (keeping its id), edit it with params {"parentId":"\<loop-id>"}; {"parentId":null} moves it out (JSON, or @path / @- to read a file or stdin). |
| `--atomic` | No | Fail the whole batch when any operation is declined or any block input would be dropped. The default applies what it can and reports the rest in `skipped` and `inputValidationErrors`; `true` writes nothing and answers `409` instead. |
| `--no-atomic` | No | Send --atomic as false. |
| `--layout <value>` | No | Whether to reposition blocks the batch touched. `targeted` (default) nudges only the affected subgraph; `none` leaves every position exactly as supplied. Accepted values: `targeted`, `none`. |
| `--set-block-enabled <json\|@file>` | No | Blocks to enable or disable, applied after --operations: \[{"block_id":"\<uuid>","enabled":false}]. Disabling a loop or parallel cascades to its unlocked descendants; enabling a block whose container is disabled is declined (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Conditional | Confirm this operation (required unless --dry). |

```text
Edges:
  connections maps a source handle to its targets: {"source":"<id>"}, {"source":["<a>","<b>"]},
  or {"source":{"block":"<id>","handle":"<target handle>"}}; "success" is an alias of "source".
  An add's connections create the new block's edges. An edit's connections REPLACE every
  outgoing edge of that block, on every handle: list again each edge to keep; {} removes them all.
  Moving a block into or out of a loop or parallel (parentId) removes each of its existing edges
  that would cross the container's boundary, atomic or not, and names them in warnings. Edges the
  batch itself asks for across a boundary are refused. Wire into the body from loop-start-source
  and onward from loop-end-source (parallel-start-source, parallel-end-source).
  To remove one edge, edit its source block with
  {"removeEdges":[{"targetBlockId":"<id>","sourceHandle":"source"}]} (sourceHandle defaults to
  "source").
Source handles:
  source               the normal path
  error                a failure (a block that has an error output)
  if, else-if-0, else  a condition's branches, in order (else-if-1, … for more)
  route-0, route-1, …  a router's routes, in order
  loop-start-source    a loop into its body; loop-end-source after the loop
  parallel-start-source, parallel-end-source  the same for a parallel
Renames:
  An edit's {"name":"New name"} also rewrites every <old key.field> reference to the block, in
  other blocks' inputs and in a loop's or parallel's collection and condition. Edits run after the
  batch's adds, so a block added in the same batch is rewritten too.
Inputs:
  inputs takes the field ids `sim blocks get <type>` lists (inputSchema, operationInputSchema),
  or the name a pair of them shares (inputDefinitions: tableId for tableSelector and
  manualTableId; a string goes to the typed field). Add the type it answers with: `blocks get
  table` answers table_v2, and an add of legacy table is refused. An edit's inputs replace each
  field they name whole (a responseFormat schema too) and keep the fields they do not name.
  conditions (condition): [{"title":"if","value":"<start.n> > 3"},{"title":"else if","value":"…"},
  {"title":"else","value":""}]; the last entry is the else. Each entry's id comes from its
  position (<block id>-if, <block id>-else-if-0, …, <block id>-else): an id you pass is replaced.
  inputFormat (Start): [{"name":"email","type":"string"}]; types string, number, boolean,
  object, array, file[]; an optional default "value" as text.
Block settings, beside inputs in an add's or edit's params:
  "retry":{"enabled":true,"maxTries":3,"waitBetweenTriesMs":1000} retries a failed block; null
  clears it. An api block's retries input repeats the request after a timeout, reset, 429 or
  5xx, not when the host does not resolve or refuses the connection; "retry" covers that. They
  nest: every try of "retry" runs the request with its retries.
Outputs:
  A block that fails outputs {"error":"<message>"}: connect its error handle and read
  <name.error> there (without one, the run fails). A Function's error leads with the line and
  code that threw; its <name.errorMessage> is the thrown message alone, the one to reply with.
  A Workflow block's result is the child's
  output; a child ending in a Response block gives {data, status, headers}, so read
  <call.result.data.x>. A Table block's row holds its cells under data: read a cell as
  <name.row.data.column> (<name.rows[0].data.column>).
References:
  Inside a loop or parallel body read <loop.currentItem> and <loop.index>, or
  <parallel.currentItem> and <parallel.index>; after it, <name.results>. A reference to a block
  that did not run (a branch not taken) is null as a whole value, in a condition or in a
  Function's code, and '' inside text.
Order:
  Operations run in phases whatever their order in the batch: deletes first, then
  extract_from_subflow, adds, insert_into_subflow and edits; operations of one type keep the
  order given, except insert_into_subflow, which runs a parent before its children. A delete plus an add with the same name therefore replaces the block in one batch.
Run logs:
  `sim logs list --workflow <workflowId>` lists a workflow's runs; `sim logs get <runId> --trace
  --no-include-workflow-state` shows each block's resolved inputs, outputs and errors.
```

API request and response schemas: [applyWorkflowOperations](/api-reference/workflows/applyWorkflowOperations).

### Update workflow variables \[#update-workflow-variables]

This applies the listed variable changes; variables omitted from the operations remain unchanged.

```bash
sim workflows variables update <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--operations <json\|@file>` | Yes | Variable changes to apply in order, keyed by operation: \[{"operation":"add","name":"my_var","type":"string","value":"hello"},{"operation":"edit","name":"my_var","value":"updated"},{"operation":"delete","name":"my_var"}] (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [applyWorkflowVariables](/api-reference/workflows/applyWorkflowVariables).

## Deployments and versions \[#deployments-and-versions]

### Deploy workflow \[#deploy-workflow]

OAuth login or personal API key required.

```bash
sim workflows deploy <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--name <value>` | No | Optional label for the deployment version. |
| `--description <value>` | No | Optional release note for the deployment version. |
| `--expected-draft-fingerprint <value>` | No | Deploy only this draft: the `sf1:` fingerprint a source apply answered with (`base.fingerprint`). When the draft changed since, the deploy answers `409` and publishes nothing. |
| `-y, --yes` | No | Accepted and ignored: this command needs no confirmation. |

API request and response schemas: [deployWorkflow](/api-reference/workflows/deployWorkflow).

### Show a workflow’s current deployment \[#show-a-workflows-current-deployment]

```bash
sim workflows deployment status <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [getWorkflowDeployment](/api-reference/workflows/getWorkflowDeployment).

### Update workflow public API access \[#update-workflow-public-api-access]

OAuth login or personal API key required.

```bash
sim workflows deployment update <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--is-public-api <true\|false>` | Yes | Whether the deployed workflow should accept unauthenticated public API execution. Accepted values: `true`, `false`. |

API request and response schemas: [updateWorkflowPublicApi](/api-reference/workflows/updateWorkflowPublicApi).

### Show the health of every trigger the live deployment serves \[#show-the-health-of-every-trigger-the-live-deployment-serves]

```bash
sim workflows triggers list <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [listWorkflowTriggers](/api-reference/workflows/listWorkflowTriggers).

### Enable or disable one trigger of the live deployment \[#enable-or-disable-one-trigger-of-the-live-deployment]

```bash
sim workflows triggers update <workflowId> <blockId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `blockId` | Yes | Trigger block in the deployed workflow. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--enabled <true\|false>` | Yes | Whether the trigger should fire. A disable lasts until the next deploy or version activation, which re-enables every trigger. Accepted values: `true`, `false`. |

API request and response schemas: [updateWorkflowTrigger](/api-reference/workflows/updateWorkflowTrigger).

### List workflow versions \[#list-workflow-versions]

```bash
sim workflows versions list <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--limit <n>` | No | Maximum items to return (0 for everything). Defaults to `100`. |
| `--cursor <value>` | No | Continue from nextCursor returned by a previous result. |

API request and response schemas: [listWorkflowVersions](/api-reference/workflows/listWorkflowVersionsV2).

### Get workflow version \[#get-workflow-version]

```bash
sim workflows versions get <workflowId> <version>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `version` | Yes | Numeric deployment version. |

API request and response schemas: [getWorkflowVersion](/api-reference/workflows/getWorkflowVersionV2).

### Update workflow version \[#update-workflow-version]

```bash
sim workflows versions update <workflowId> <version> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `version` | Yes | Numeric deployment version. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--name <value>` | No | New label for the deployment version. |
| `--description <value>` | No | New release note for the deployment version, or null to clear it. (--description null sends the word, not JSON null). |

API request and response schemas: [updateWorkflowVersion](/api-reference/workflows/updateWorkflowVersionV2).

### Compare workflow versions \[#compare-workflow-versions]

```bash
sim workflows versions compare <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--base <value>` | Yes | Deployment version to compare from. |
| `--target <value>` | Yes | Deployment version to compare to, in the same workflow. |

API request and response schemas: [compareWorkflowVersions](/api-reference/workflows/compareWorkflowVersionsV2).

### Activate workflow version \[#activate-workflow-version]

OAuth login or personal API key required.

This changes which deployed version runs in production for every API and chat consumer.

```bash
sim workflows activate create <workflowId> <version> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `version` | Yes | Numeric deployment version. |

**Options**

| Option | Required | Description |
| - | - | - |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [activateWorkflowVersion](/api-reference/workflows/activateWorkflowVersion).

### Revert workflow to version \[#revert-workflow-to-version]

OAuth login or personal API key required.

This overwrites the draft graph with the selected version and cannot be undone.

```bash
sim workflows revert create <workflowId> <version> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |
| `version` | Yes | Numeric deployment version, or `active` for the currently live version. |

**Options**

| Option | Required | Description |
| - | - | - |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [revertWorkflowVersion](/api-reference/workflows/revertWorkflowVersion).

### Rollback workflow \[#rollback-workflow]

OAuth login or personal API key required.

This changes which deployed version runs in production for every API and chat consumer.

```bash
sim workflows rollback <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--to-version <value>` | No | Deployment version to reactivate. Omit to select the previous active version. |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [rollbackWorkflow](/api-reference/workflows/rollbackWorkflow).

### Take a workflow out of deployment \[#take-a-workflow-out-of-deployment]

OAuth login or personal API key required.

This takes the workflow offline for every API and chat consumer, and agents calling its MCP tools lose access until it is deployed again.

```bash
sim workflows undeploy <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [undeployWorkflow](/api-reference/workflows/undeployWorkflow).

## Run and inspect \[#run-and-inspect]

### Run a deployed workflow, or its saved draft \[#run-a-deployed-workflow-or-its-saved-draft]

```bash
sim workflows run <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--input <json\|@file>` | No | Trigger input as JSON (JSON, or @path / @- to read a file or stdin). |
| `--async` | No | Queue the run and return immediately. Defaults to false. |
| `--execution-timeout-seconds <value>` | No | Maximum duration of the run in seconds, capped by the plan's execution timeout. Requires --async or --wait-timeout. |
| `--select-output <value...>` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). |
| `--include-file-base64` | No | Inline eligible output files as base64 content. Defaults to true for the installed CLI; Chat defaults to file references and admits requested bytes only for synchronous runs. Rejected when async is true. |
| `--no-include-file-base64` | No | Send --include-file-base64 as false. |
| `--base64-max-bytes <value>` | No | Maximum total bytes of file content to inline as base64, lowering but never raising the server limit of 16 MiB. Rejected when `async` is true. |
| `--run-id <value>` | No | One-shot identifier for this run; NOT an idempotency key — reusing a claimed value fails with RUN_ID_CONFLICT instead of replaying the first result, and a fresh value starts another run. |
| `--draft` | No | Run the saved draft instead of the active deployment, sending its writes. |
| `--deployment-version <n>` | No | Run this deployed version instead of the active one (a version number from `sim workflows versions list`); a Workflow block in it still runs its child workflow's active deployment. Needs workspace write access, through a full-access API key or an OAuth token with api:write. Not with --draft or any flag that runs the draft. |
| `--dry` | No | Dry run of the saved draft (implies --draft): writes are not sent but answered with placeholders and listed with their request payloads in sideEffects; reads, model calls and code run for real. Logged as a test run. Not with --follow, --async or --wait-timeout. |
| `--allow <block>` | No | Send this block's writes for real during a dry run (its id, display name or key, or \<workflow>.\<block> for a workflow it calls); for an Agent, only its own tool calls, not a workflow or custom block it calls; repeatable. |
| `--mock <block>=<json\|@file>` | No | Answer this block with the given JSON object instead of running it during a dry run (its id, display name or key, or \<workflow>.\<block> for a workflow it calls), to steer a branch or give a stubbed write a realistic result; a bare --mock \<block> takes its output from --mock-from. Not a locked block, or one of a locked workflow or folder; data only (the API reference lists the fields a mock cannot set). The run records only which blocks were mocked, not the outputs, so a rerun reads them again with --mock-from; repeatable. |
| `--mock-from <runId>` | No | Answer each block a bare --mock \<block> names with the output it recorded in this earlier run of the workflow, redacted as the run shows it: this workflow's blocks (not a child's; not inside a loop or parallel unless that run mocked it); fields a mock cannot set, such as cost or model, are left out. |
| `--trigger <blockId>` | No | Enter the run through this runnable trigger, by its block id; runs the saved draft (implies --draft). |
| `--sample` | No | Run with the selected trigger's sample payload instead of --input; runs the saved draft (implies --draft), whose writes are sent unless --dry. |
| `--from-block <block>` | No | Rerun the saved draft from this block (its id, display name or key), reusing the outputs --source-run produced before it; a failed run prints this command as next. |
| `--source-run <runId>` | No | Earlier run of this workflow, deployed or draft, whose outputs the blocks before --from-block keep (requires --from-block). |
| `--stop-after <block>` | No | Stop the run after this saved block (its id, display name or key), failing it if the run takes a path that skips the block; with --from-block on the same block, re-runs only that block (implies --draft). Unless --select-output names others, blockOutputs holds the output of that block under its key (or id); output stays empty. |
| `--dir <dir>` | No | This workflow's source directory: a failed run names the source file and line of the block that failed, read through its .sim/lock.json. Not with --async or --follow, and not for a run --wait-timeout leaves running. |
| `--wait-timeout <seconds>` | No | Wait at most this many seconds for a synchronous run (0 waits until it settles). A run still going then continues in the background under async limits: the command prints its run record and exits 4, and `sim workflows runs wait` keeps waiting. Not with --async or --follow. |
| `--follow` | No | Stream the run as it happens; progress on stderr, result on stdout. The stream reports only success and output, so the result omits the run id and timings a non-streaming run returns. |
| `--include-thinking` | No | Show model reasoning while following (requires --follow). |
| `--include-tool-calls` | No | Show tool calls while following (requires --follow). |

Without --draft (or a flag that implies it) this runs the active deployment; a workflow never deployed has none. --deployment-version \<n> runs that deployed version instead (it needs workspace write access, through a full-access API key or an OAuth token with api:write); the child workflows it calls still run their own active deployment. --draft runs the saved draft, as the source loop leaves it, sending its writes.

\--dry runs the saved draft without its writes: each call that could change something (a write tool, any MCP call, an HTTP request other than GET/HEAD/OPTIONS, code's other fetches) gets a placeholder (ids like dry_run_row_1, numbers above 900000000) and is listed in sideEffects.stubbed with the request it would have sent; check those payloads. A read that would send a placeholder is held back too (reason placeholder), and an MCP call its server calls read-only says so (reason mcp-read-only). Reads, model calls and code run for real; code in a remote sandbox (shell, Python, imports) runs for real too, its network requests included, and is listed in sideEffects.unchecked. Child workflows run dry too; custom, Human in the loop and Wait blocks are answered whole, so the run never pauses. --allow \<block> sends that block's writes for real (use a test resource). --mock \<block>=\<json> answers a block with fixed output, to steer a branch; --mock-from \<runId> with a bare --mock \<block> answers it with the output that run recorded. --allow and --mock also name a block of a workflow this one calls as \<workflow>.\<block>. --allow, --mock and --mock-from imply --dry; --draft sends every write, so it refuses them. Overrides the run never reached are listed in sideEffects.unreached, and mock fields a block never gets in sideEffects.mockFields. The API reference describes each list and refusal.

The result is the run: runId, status (completed, failed, paused or cancelled), error, output (the workflow's final output) and blockOutputs (what --select-output named). It has no success field: branch on status, or on the exit code. With --follow it is the stream's final frame instead: success and output.

A run that failed in a block has next: { command, reason }, the command that reruns the saved draft from that block (or the outermost loop or parallel holding it) with this run as --source-run. A dry run's keeps --dry and --allow, and reads its mocks again with --mock-from; a mock it cannot read again (a child's block, one never reached, or one passed beside --mock-from) is left out and named in nextNote, for you to pass again. A run paused for input has next: the runs resume command.

Exit codes: 0 completed or paused (--async: queued); 1 failed or cancelled (the result is printed first, then the error on stderr), or the command failed; 4 still running when --wait-timeout elapsed.

API request and response schemas: [executeWorkflow](/api-reference/workflows/executeWorkflowV2).

### List runs for a workflow \[#list-runs-for-a-workflow]

```bash
sim workflows runs list [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <workflowId>` | Yes | Workflow ID. |
| `--status <value>` | No | Filter by run status. Accepted values: `pending`, `running`, `completed`, `failed`, `cancelled`, `paused`. |
| `--trigger <value>` | No | Filter by trigger type. |
| `--start-date <value>` | No | Only include runs started at or after this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. |
| `--end-date <value>` | No | Only include runs started at or before this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. |
| `--limit <n>` | No | Maximum items to return (0 for everything). Defaults to `100`. |
| `--cursor <value>` | No | Continue from nextCursor returned by a previous result. |
| `--order <value>` | No | Sort direction by run start time. This list is sortable only by run start time, so it takes `order` in place of `sortBy`/`sortOrder`, which it rejects. Defaults to "desc". Accepted values: `asc`, `desc`. |

API request and response schemas: [listWorkflowRuns](/api-reference/workflow-runs/listWorkflowRunsV2).

### List runs waiting on human input across the workspace \[#list-runs-waiting-on-human-input-across-the-workspace]

```bash
sim workflows runs paused [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--include-output` | No | Include each pause point's reviewer `display` content when true. |
| `--no-include-output` | No | Send --include-output as false. |
| `--limit <n>` | No | Maximum items to return (0 for everything). Defaults to `100`. |
| `--cursor <value>` | No | Continue from nextCursor returned by a previous result. |
| `--sort-by <value>` | No | Field used to sort the result. Defaults to "pausedAt". Accepted values: `pausedAt`. |
| `--sort-order <value>` | No | Sort direction. Defaults to "desc". Accepted values: `asc`, `desc`. |

API request and response schemas: [listPausedRuns](/api-reference/workflow-runs/listPausedWorkflowRunsV2).

### Show run status \[#show-run-status]

Requested outputs are included in JSON or YAML output.

```bash
sim workflows runs get <runId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `runId` | Yes | Unique workflow run identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <workflowId>` | Yes | Workflow ID. |
| `--include-output` | No | Include the final output in JSON or YAML output. |
| `--select-output <value...>` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). |
| `--include-file-base64` | No | Inline each produced file's bytes as base64. Requires `includeOutput`. A file above the inline ceiling answers `413` naming its download path; fetch large files from `downloadPath` instead. |
| `--no-include-file-base64` | No | Send --include-file-base64 as false. |
| `--base64-max-bytes <value>` | No | Per-file inline ceiling, lowering but never raising the server limit of 16 MiB. |

API request and response schemas: [getWorkflowRun](/api-reference/workflow-runs/getWorkflowRunV2).

### Wait until a run finishes or needs input \[#wait-for-a-run-to-reach-a-terminal-state-then-show-it]

```bash
sim workflows runs wait <runId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `runId` | Yes | Unique workflow run identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <workflowId>` | Yes | Workflow ID. |
| `--wait-timeout <seconds>` | No | Give up after this many seconds, or 0 to wait indefinitely (default: 3600). Bounds the whole wait; SIM_TIMEOUT_SECONDS bounds one request. |

Exit codes: 0 completed, 1 failed, 2 cancelled, 3 needs input, 4 timed out. Time-based pauses continue waiting; a human pause or an unspecified pause kind ends the wait with code 3. Use `sim workflows runs resume` with the pause context to continue.

API request and response schemas: [getWorkflowRun](/api-reference/workflow-runs/getWorkflowRunV2).

### Resume a paused run \[#resume-a-paused-run]

Output is included in JSON or YAML output.

```bash
sim workflows runs resume <runId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `runId` | Yes | Unique workflow run identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <workflowId>` | Yes | Workflow ID. |
| `--context <value>` | Yes | Pause context ID returned by run status. |
| `--input <json\|@file>` | No | Resume input as JSON (JSON, or @path / @- to read a file or stdin). |

API request and response schemas: [resumeWorkflow](/api-reference/workflow-runs/resumeWorkflowRunV2).

### Cancel a running workflow run \[#cancel-a-running-workflow-run]

Canceling a paused run prevents resuming that run. Starting a new run can repeat side effects already performed.

```bash
sim workflows runs cancel <runId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `runId` | Yes | Unique workflow run identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <workflowId>` | Yes | Workflow ID. |

API request and response schemas: [cancelWorkflowRun](/api-reference/workflow-runs/cancelRunV2).

## Chat deployments \[#chat-deployments]

### Show a workflow’s chat deployment \[#show-a-workflows-chat-deployment]

OAuth login or personal API key required.

```bash
sim workflows chat status <workflowId>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

API request and response schemas: [getWorkflowChatDeployment](/api-reference/workflows/getWorkflowChatDeployment).

### Deploy or replace a workflow chat \[#publish-or-replace-a-workflows-chat-deployment]

OAuth login or personal API key required.

This replaces visitor access settings for the chat deployment. Omitted authentication fields reset to defaults, including the password and allowed-email list; avatar and welcome-message behavior follows their option descriptions.

Omitting `--auth-type` selects public access: anyone holding the URL can chat. Supply the complete password or allow-list settings again when replacing a restricted deployment.

```bash
sim workflows chat publish <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--identifier <value>` | Yes | URL slug the deployed chat answers on. Must be free across live deployments. |
| `--title <value>` | Yes | Title shown to visitors. |
| `--description <value>` | No | Description shown to visitors. Omitted clears it. |
| `--customizations <json\|@file>` | No | Presentation overrides. Omitted `primaryColor` and `welcomeMessage` use platform defaults; an omitted or empty `imageUrl` keeps the existing avatar. An empty `welcomeMessage` keeps the existing message. (JSON, or @path / @- to read a file or stdin). |
| `--auth-type <value>` | No | How visitors are gated. `public` leaves the chat open to anyone holding the URL. Defaults to "public". Accepted values: `public`, `password`, `email`, `sso`. |
| `--password <value>` | Conditional | Write-only password of 15 to 1024 characters, not only whitespace. Required whenever `authType` is `password`, and rejected otherwise. Never readable back. Taken literally, except that a request from the Sim agent resolves a whole-value `{{ENV_VAR}}` reference to that variable before the rules apply. |
| `--allowed-emails <json\|@file>` | No | Email addresses or domains admitted under `email` and `sso` gating. At least one is required for those modes. (JSON, or @path / @- to read a file or stdin). |
| `--output-configs <json\|@file>` | No | Block outputs to surface to visitors. Omitted surfaces none. (JSON, or @path / @- to read a file or stdin). |
| `--include-thinking` | No | Allow visitors to receive provider thinking events. Defaults to false. |
| `--no-include-thinking` | No | Send --include-thinking as false. |
| `--include-tool-calls` | No | Allow visitors to receive tool lifecycle events. Defaults to false. |
| `--no-include-tool-calls` | No | Send --include-tool-calls as false. |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [replaceWorkflowChatDeployment](/api-reference/workflows/replaceWorkflowChatDeployment).

### Take a workflow’s chat deployment offline \[#take-a-workflows-chat-deployment-offline]

OAuth login or personal API key required.

This takes the chat offline and frees its identifier. The workflow itself stays deployed and executable.

```bash
sim workflows chat unpublish <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [deleteWorkflowChatDeployment](/api-reference/workflows/deleteWorkflowChatDeployment).

## Export and import \[#export-and-import]

### Print a workflow as a portable JSON document \[#print-a-workflow-as-a-portable-json-document]

The export clears credentials, passwords, and table sub-block values, but it is not a general secret scanner. Inspect literal variables and inline configuration before sharing the document.

```bash
sim workflows export <workflowId> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | Yes | Unique workflow identifier. |

**Options**

| Option | Required | Description |
| - | - | - |
| `--include-references` | No | Include non-secret resource identities for mapped import. |
| `--include-workspace-bindings` | No | Keep table, knowledge base, document, folder, channel and other workspace bindings. On by default; --no-include-workspace-bindings clears them for a copy to share outside this workspace. Credentials are cleared either way. |
| `--no-include-workspace-bindings` | No | Send --include-workspace-bindings as false. |

A table, child workflow, knowledge base or other workspace binding prints as its id; a credential always prints as null. For a copy to share outside this workspace, pass --no-include-workspace-bindings to clear the bindings too.

API request and response schemas: [exportWorkflow](/api-reference/workflows/exportWorkflow).

### Preview workflow import \[#preview-workflow-import]

```bash
sim workflows import-preview [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <json\|@file>` | Yes | Workflow export object, bare workflow state, or JSON string containing either form. (JSON, or @path / @- to read a file or stdin). |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |
| `--name <value>` | No | Override for the imported workflow name. |
| `--description <value>` | No | Override for the imported workflow description. |
| `--mappings <json\|@file>` | No | Mapping entries addressed by resource kind and source identifier. (JSON, or @path / @- to read a file or stdin). |
| `--bindings <json\|@file>` | No | Resolved and unresolved source occurrences with their destination selections. (JSON, or @path / @- to read a file or stdin). |
| `--dependent-values <json\|@file>` | No | Destination-specific values addressed by the source block ID and field key, before imported IDs are regenerated. (JSON, or @path / @- to read a file or stdin). |

API request and response schemas: [previewWorkflowImport](/api-reference/workspace-sync/previewWorkflowImport).

### Import workflow \[#import-workflow]

```bash
sim workflows import [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow <json\|@file>` | Yes | Workflow export object, bare workflow state, or JSON string containing either form. (JSON, or @path / @- to read a file or stdin). |
| `--folder <value>` | No | Folder path as shown in the app; the leading / is optional. |
| `--name <value>` | No | Override for the imported workflow name. |
| `--description <value>` | No | Override for the imported workflow description. |
| `--mappings <json\|@file>` | No | Mapping entries addressed by resource kind and source identifier. (JSON, or @path / @- to read a file or stdin). |
| `--bindings <json\|@file>` | No | Resolved and unresolved source occurrences with their destination selections. (JSON, or @path / @- to read a file or stdin). |
| `--dependent-values <json\|@file>` | No | Destination-specific values addressed by the source block ID and field key, before imported IDs are regenerated. (JSON, or @path / @- to read a file or stdin). |
| `--request-id <value>` | No | Stable client request ID for mapped import. Reuse it with identical inputs after an uncertain response; changed inputs return 409. A new ID can create another workflow. |
| `--preview-fingerprint <value>` | No | Fingerprint returned by an import preview with the same choices. A changed plan returns 409; preview again. Do not invent this value. |
| `--wait` | No | Wait for the committed operation to finish; missing configuration and failure exit nonzero. |
| `--wait-timeout <seconds>` | No | Maximum operation wait in seconds (default 3600; 0 waits indefinitely). |

API request and response schemas: [importWorkflow](/api-reference/workflows/importWorkflow).

## Folders \[#folders]

### List workflow resources and child folders together \[#list-workflow-resources-and-child-folders-together]

```bash
sim workflows ls [path] [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `path` | No | Folder path to list; defaults to the root folder |

**Options**

| Option | Required | Description |
| - | - | - |
| `--search <text>` | No | Filter folders and resources by name. |
| `--limit <n>` | No | Maximum combined items to return (0 for everything). Defaults to `0`. |

API request and response schemas: [listWorkflows](/api-reference/workflows/listWorkflows), [listWorkflowFolders](/api-reference/workflows/listWorkflowsFolders).

### List workflow folders \[#list-workflow-folders]

```bash
sim workflows folders list [options]
```

Also available as `sim workflows folders ls`.

**Options**

| Option | Required | Description |
| - | - | - |
| `--parent <value>` | No | Direct parent folder path. |
| `--search <value>` | No | Case-insensitive substring match against the folder name. |
| `--sort-by <value>` | No | Field used to sort the result. Do not rely on case-insensitive ordering when sorting by `name`. Defaults to "name". Accepted values: `name`, `createdAt`, `updatedAt`. |
| `--sort-order <value>` | No | Sort direction. Defaults to "asc". Accepted values: `asc`, `desc`. |

API request and response schemas: [listWorkflowFolders](/api-reference/workflows/listWorkflowsFolders).

### Create a workflow folder at a path \[#create-a-workflow-folder-at-a-path]

```bash
sim workflows folders create <path>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `path` | Yes | Folder path as shown in the app; the leading / is optional |

API request and response schemas: [createWorkflowFolder](/api-reference/workflows/createWorkflowsFolder).

### Delete workflow folder \[#delete-workflow-folder]

This archives the workflow folder and, when recursive, everything inside it.

```bash
sim workflows folders delete <path> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `path` | Yes | Folder path as shown in the app; the leading / is optional |

**Options**

| Option | Required | Description |
| - | - | - |
| `--recursive` | No | Archive the folder and its descendants. Defaults to "false". |
| `-y, --yes` | Yes | Confirm this operation. |

API request and response schemas: [deleteWorkflowFolder](/api-reference/workflows/deleteWorkflowsFolder).

### Rename or move a workflow folder \[#rename-or-move-a-workflow-folder]

```bash
sim workflows folders move <path> <destination>
```

Also available as `sim workflows folders mv`.

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `path` | Yes | Folder path as shown in the app; the leading / is optional |
| `destination` | Yes | Folder path as shown in the app; the leading / is optional |

API request and response schemas: [relocateWorkflowFolder](/api-reference/workflows/relocateWorkflowsFolder).

### Create a workflow directory at a path \[#create-a-workflow-directory-at-a-path]

```bash
sim workflows mkdir <path>
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `path` | Yes | Folder path to create; the leading / is optional |

API request and response schemas: [createWorkflowFolder](/api-reference/workflows/createWorkflowsFolder).

## Workflows as code \[#workflows-as-code]

### Show a workflow’s draft as TypeScript source with its identity lock \[#show-a-workflows-draft-as-typescript-source-with-its-identity-lock]

```bash
sim workflows source get <workflow> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflow` | Yes | Workflow id, or its exact name |

**Options**

| Option | Required | Description |
| - | - | - |
| `--function-code <value>` | No | Where function-block code goes: `files` (default) writes it to `functions/*` files referenced with `codeFile()`; `inline` prints it in tagged templates. Accepted values: `inline`, `files`. |
| `--dir <dir>` | No | Write the source, its lock and SDK type declarations into this directory instead of printing them. |
| `--force` | No | With --dir: replace another workflow's source or edits no apply has saved. |

Exit codes with --dir: 0 written; 1 the command failed, no workflow or several are named exactly the name given (WORKFLOW_NOT_FOUND, WORKFLOW_NAME_AMBIGUOUS: each candidate is listed with its id), the directory is a workspace source directory (SOURCE_DIR_KIND_MISMATCH, even with --force), or it holds another workflow's source (SOURCE_WORKFLOW_MISMATCH) or edits no apply has saved (SOURCE_LOCAL_EDITS: apply them, get into another directory, or pass --force); 7 the workflow is too large to print as source; 9 rate limited (HTTP 429) after the CLI's retries: wait a minute and run it again; 10 (busy, retry) another sim command is using --dir, or the workspace directory it is a workflow folder of (SOURCE_DIR_BUSY): nothing was read or written, run it again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was read or written, run `sim login` and the get again.

API request and response schemas: [getWorkflowSource](/api-reference/workflows/getWorkflowSource).

### Show what changed locally and on the server since the directory was read \[#show-what-changed-locally-and-on-the-server-since-the-directory-was-read]

```bash
sim workflows source status [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--summary-file <path>` | No | Also write the plan as Markdown to this file (or set SIM_SUMMARY_FILE), replacing it each run; its first line is a comment that names the directory, for a CI step that updates one pull-request comment. |
| `--dir <dir>` | No | Source directory: workflow\.ts, functions/\* and .sim/. Defaults to `.`. |
| `--offline` | No | Report local changes only, without asking the server. |
| `--json` | No | Print the machine-readable status (same as --output json). |

With --json, `plan` is what applying would do as `apply --dry --allow-delete` reports it (its errors and warnings counted the same, a conflict as an error), and `next` the command to run (with --allow-delete only when the plan deletes something).

Exit codes: 0 clean (nothing to apply, and the server changed nothing since the directory was read); a server that cannot be reached is not a failure: the status shows the local changes only and says so (exit 0 or 11); 1 the command failed; 7 the source is too large for the server to read in one dry run; 9 rate limited (HTTP 429) after the CLI's retries: wait a minute and run it again; 10 (busy, retry) another sim command is using --dir, or the workspace directory it is a workflow folder of (SOURCE_DIR_BUSY): nothing was read or written, run it again once the other finished; 11 local changes only (applying writes them); 12 the server changed since the directory was read: drift (a resource edited, added or deleted there that the directory leaves alone) or a conflict (also changed here, so applying it is refused as stale), with or without local changes; 13 not logged in (AUTH_REQUIRED) or the credential was refused: the status shows the local changes only, then run `sim login`.

API request and response schemas: [planWorkflowSource](/api-reference/workflows/planWorkflowSource), [getSourceResources](/api-reference/workflows/getSourceResources).

### Create a workflow from a workflow source directory \[#create-a-workflow-from-a-workflow-source-directory]

```bash
sim workflows source create [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
| `--summary-file <path>` | No | Also write the plan as Markdown to this file (or set SIM_SUMMARY_FILE), replacing it each run; its first line is a comment that names the directory, for a CI step that updates one pull-request comment. |
| `--dir <dir>` | Yes | Source directory: workflow\.ts and functions/\*. Without workflow\.ts, writes a starter and the types instead (an error with --dry or --yes). |
| `--dry` | No | Check the source and show the outcome without creating anything. |
| `--name <name>` | No | The workflow name (default: the source's). |
| `--folder <path>` | No | The folder to create it in (default: the root). |
| `-y, --yes` | No | Create without asking for confirmation. |
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |

Exit codes: 0 created (or a clean dry run, or a starter written); 1 the source has errors (each printed as file:line:column with its frame and hint), the workflow name is taken (SOURCE_NAME_TAKEN: pass --name), the --run test run did not complete (the workflow is created; nothing was deployed), or the command failed (a starter is created in the workspace its types were written for unless --workspace or SIM_WORKSPACE names another); 6 the folder is locked; 7 the source is too large; 9 rate limited (HTTP 429) after the CLI's retries, so nothing was created: wait a minute and run it again; 10 (busy, retry) another sim command is using --dir, or the workspace directory it is a workflow folder of (SOURCE_DIR_BUSY): nothing was read or written, run it again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was created (run the same command with --yes); 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.

API request and response schemas: [createWorkflowFromSource](/api-reference/workflows/createWorkflowFromSource), [getSourceCatalog](/api-reference/catalog/getSourceCatalog), [getSourceResources](/api-reference/workflows/getSourceResources), [deployWorkflow](/api-reference/workflows/deployWorkflow), [getWorkflowDeployment](/api-reference/workflows/getWorkflowDeployment), [executeWorkflow](/api-reference/workflows/executeWorkflowV2).

### Apply a workflow source directory to a workflow draft \[#apply-a-workflow-source-directory-to-a-workflow-draft]

```bash
sim workflows source apply [workflowId] [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `workflowId` | No | Refuse unless .sim/base.json names this workflow (default: the workflowId there) |

**Options**

| Option | Required | Description |
| - | - | - |
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
| `--summary-file <path>` | No | Also write the plan as Markdown to this file (or set SIM_SUMMARY_FILE), replacing it each run; its first line is a comment that names the directory, for a CI step that updates one pull-request comment. |
| `--dir <dir>` | No | Source directory: workflow\.ts, functions/\*, .sim/lock.json and .sim/base.json. Defaults to `.`. |
| `--dry` | No | Check the source and show the outcome without saving or writing files. |
| `-y, --yes` | No | Apply without asking for confirmation. |
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |
| `--allow-delete` | No | Delete blocks and variables the source no longer declares; without it, an apply that deletes one is refused. |

Exit codes: 0 applied (or a clean dry run); 1 the source has errors (each printed as file:line:column with its frame and hint), the workflowId given is not the one .sim/base.json names (SOURCE_WORKFLOW_MISMATCH: the directory holds another workflow's source), the --run test run did not complete (the draft is saved; nothing was deployed), or the command failed; 5 the workflow changed since the directory was read (SOURCE_STALE, on a dry run too: get it again, reapply the edit, retry); 6 the workflow or its folder is locked (E_APPLY_LOCKED; a locked block exits 1, E_APPLY_LOCKED_BLOCK); 7 the source is too large; 9 rate limited (HTTP 429) after the CLI's retries, so nothing was written: wait a minute and run it again; 10 (busy, retry) another sim command is using --dir, or the workspace directory it is a workflow folder of (SOURCE_DIR_BUSY): nothing was read or written, run it again once the other finished; 13 not logged in, the login expired, or the server refused the credential (AUTH_REQUIRED): nothing was sent, run `sim login` (or fix or unset SIM_API_KEY when the key comes from it) and the command again; 14 without --yes and with no terminal to ask: the plan was printed with no errors and nothing was written (run the same command with --yes to apply it); 130 interrupted (Ctrl-C): a write already sent is finished and saved into the directory first, waiting up to 60s for its answer, and a second Ctrl-C, or no answer by then, stops at once and prints that it may have been written and how to check.

API request and response schemas: [applyWorkflowSource](/api-reference/workflows/applyWorkflowSource), [deployWorkflow](/api-reference/workflows/deployWorkflow), [getWorkflowDeployment](/api-reference/workflows/getWorkflowDeployment), [getSourceResources](/api-reference/workflows/getSourceResources), [executeWorkflow](/api-reference/workflows/executeWorkflowV2).

### Show the block catalog workflow source is checked against \[#show-the-block-catalog-workflow-source-is-checked-against]

```bash
sim workflows source catalog [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--workflow-id <value>` | No | Return the source catalog for this workflow: the workspace catalog plus every block type already placed in it, the ones the caller could not add marked `addable: false`. |

API request and response schemas: [getSourceCatalog](/api-reference/catalog/getSourceCatalog).

### Compile and type-check a workflow source directory locally, without the server \[#compile-and-type-check-a-workflow-source-directory-locally-without-the-server]

```bash
sim workflows source check [options]
```

**Options**

| Option | Required | Description |
| - | - | - |
| `--dir <dir>` | No | Source directory: workflow\.ts, functions/\* and .sim/. Defaults to `.`. |
| `--strict` | No | Fail on the warnings listed below in every block, not only new ones. |
| `--no-strict` | No | Never fail on a warning an apply saves. |
| `--no-types` | No | Skip the type check (TypeScript 7.0.2 over tsconfig.json) that runs after the compile. |
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |

Compiles workflow\.ts (and the function files it names) with the compiler the server runs, against the workspace's block catalog the last get or create cached, and prints the findings as the dry run does. No request is made to Sim. It covers the source itself (syntax, builders, params, references, wiring). In a workflow folder of a workspace directory (workflows/\<key>), it reads the workspace's .sim/base.json and also checks env names, resource keys and table columns against what the directory declares. The dry run still checks what only the server knows (stored values, deployment), so run it before applying. A check also adds the blocks the source now uses to the CLI's tsconfig.json, so a block the edit added is typed; in a workspace directory it also regenerates .sim/sdk/workspace.d.ts from the files, so each key and workflow input they declare is. Then it type-checks the directory with TypeScript 7.0.2 (the release the declarations are built for) over tsconfig.json. Each type error is an E_TYPE error, its message starting with TypeScript's code. One is left out on a line the compile already reports an error on, and in a file still as the last get or apply wrote it when that file had the same error then (against the declarations as that get or apply left them). The first check installs that release with npm into the CLI's cache, once (none when SIM_TYPESCRIPT_DIR already holds it); when it cannot (offline, no npm), the check warns W_TYPES_UNCHECKED and passes or fails on the compile alone. --no-types skips the type check.

Exit codes: 0 no errors; 1 errors (each printed as file:line:column with its frame and hint), or no cached catalog (run the get once). With --output json, stdout is one document that also lists every finding under diagnostics.

These warnings, which an apply saves as written, fail the check as errors on every block the lock does not bind (a block added since the get, or every block of a new workflow): W_REQUIRED_MISSING, W_UNKNOWN_OPTION, W_UNKNOWN_OUTPUT_PATH, W_VALUE_KIND, W_OUT_OF_RANGE, W_LITERAL_SECRET, W_TABLE_UNKNOWN_COLUMN, W_CHILD_INPUT_UNKNOWN, W_CHILD_RESULT_PATH, W_BRANCH_UNWIRED, W_UNRESOLVED_REF, W_REF_OUT_OF_SCOPE, W_LOOP_CONDITION_SYNTAX. --strict fails on them in every block, except W_BRANCH_UNWIRED on a block the lock binds (the stored workflow may hold it, and the server then stays quiet); --no-strict fails on none of them. In every mode, as the server refuses them: W_REF_OUT_OF_SCOPE is the error E_APPLY_REF_OUT_OF_SCOPE in any file of a block the edit added or changed; W_LOOP_CONDITION_SYNTAX is the error E_APPLY_LOOP_CONDITION_SYNTAX in any file of a block the edit added or changed; W_UNKNOWN_OPTION is the error E_APPLY_INVALID_SUBBLOCK_FIELD in workflow\.ts on a block the edit added or changed; W_UNKNOWN_OUTPUT_PATH is the error E_APPLY_UNRESOLVED_REF in workflow\.ts on a block the edit added or changed; W_UNRESOLVED_REF is the error E_APPLY_UNRESOLVED_REF in workflow\.ts on a block the edit added or changed; W_UNKNOWN_BLOCK_TYPE is the error E_APPLY_INVALID_BLOCK_TYPE in workflow\.ts on a block the edit added or changed; W_TYPE_NOT_ADDABLE is the error E_APPLY_TYPE_NOT_ADDABLE in workflow\.ts on a block the edit added or changed; W_UNRESOLVED_REF is the error E_APPLY_UNRESOLVED_REF in a function file changed since the get; W_UNKNOWN_OUTPUT_PATH is the error E_APPLY_UNRESOLVED_REF in a function file changed since the get; W_CODE_FILE_REF_SYNTAX is the error E_APPLY_CODE_FILE_REF_SYNTAX in a function file changed since the get. A block counts as changed when the lock does not bind it, when the source moved it into another container, or when it compiles differently than in the source the last get or apply printed (.sim/stored-edges.json records a digest of each block). That last comparison needs the catalog the source was printed with in the cache: without it, a bound block that did not move counts as unchanged, so the server may refuse what the check passes. A $ref in a function file to a block the lock binds that the source no longer declares stays a warning, unless a warning cap left findings out: the server may infer that block was renamed and rewrite the reference, and refuses it otherwise. W_JSON_REF_UNTYPED is reported, as the server reports it, only on a field the edit made store the reference anew: one whose text differs from what the printed source stored, through block renames, or where the reference was typed then, as when an edit elsewhere (a Start input, a Function's code) changes its type. Without the record or that catalog, it is reported on every block the edit added or changed; with --strict, on every block.

Exit 10 (busy, retry): another sim workspaces source or workflows source command is using this directory or a workflow folder in it (SOURCE_DIR_BUSY); nothing was read or written. Run this one again once it finished.

### Show the content of the changes in a workflow source directory \[#show-the-content-of-the-changes-in-a-workflow-source-directory]

```bash
sim workflows source diff [paths...] [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `paths...` | No | Files or folders to compare (default: every file) |

**Options**

| Option | Required | Description |
| - | - | - |
| `--dir <dir>` | No | Source directory: workflow\.ts, functions/\* and .sim/. Defaults to `.`. |
| `--server` | No | Compare with the server's current source instead of the base. |
| `--json` | No | Print the machine-readable diff (same as --output json). |

Without --server, each file created, edited or deleted since the directory was read is shown against the text it was read at. The CLI records only each file's digest, so that text is the server's current text where it still matches the digest; a file the server changed since is named instead (compare it with --server). A binary file is shown by its sizes. Paths filter by file or folder (and in a workspace directory by kind:key, such as table:leads). Exit codes: 0 the differences were shown, whether or not there were any; 7 the source is too large for the server to read; 1 the command failed.

API request and response schemas: [getWorkflowSource](/api-reference/workflows/getWorkflowSource).

### Print a block's declaration, edges and readers with line numbers \[#print-a-blocks-declaration-edges-and-readers-with-line-numbers]

Offline.

```bash
sim workflows source find <block> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `block` | Yes | Block name, key or identifier; a part of a name matches every block |

**Options**

| Option | Required | Description |
| - | - | - |
| `--dir <dir>` | No | Workflow source directory to read. Defaults to `.`. |

Prints each block the name matches, read from the directory alone (no request is made): its declaration in workflow\.ts with line numbers, its function file, the wiring statements of its incoming and outgoing edges, and every block that reads its outputs (a param, a branch, or a function file's $ref), each as file:line. \<block> is a block name (Security Score), its key (securityscore) or its identifier (securityScore); with no exact match, every block whose name contains it is printed (at most 20). Run it from a workflow source directory, or pass --dir. When the source does not compile, readers are left out (JSON output carries compiles: false).

Exit codes: 0 printed; 1 no block matches (the closest name is suggested), or the directory is not a workflow source directory.

### Print a builder's params and outputs from the cached block catalog \[#print-a-builders-params-and-outputs-from-the-cached-block-catalog]

Offline.

```bash
sim workflows source params <builder> [options]
```

**Arguments**

| Argument | Required | Description |
| - | - | - |
| `builder` | Yes | Builder path (table.upsertRow, agent, trigger.schedule) or namespace |

**Options**

| Option | Required | Description |
| - | - | - |
| `--dir <dir>` | No | Source directory whose catalog to read. Defaults to `.`. |
| `--full` | No | Print every param with its type, enum, default and doc, not the brief form. |

Prints a builder in brief (an example call, the required params with types, the optional ones by name, the gate field that picks which others apply, and the outputs), from the block catalog the last get, create or check cached. --full prints every param with its type, enum, default and doc. A legacy builder names the one that replaces it. No request is made. \<builder> is the dotted builder path as source writes it: table.upsertRow, agent, trigger.schedule, slack.sendMessage (slack.tool.sendMessage names the same builder). A namespace (gmail, trigger.gmail) lists its builders; a block type prints the builder written for it (function is fn) or lists them (table_v2); a construct core.d.ts declares (loop, parallel, t, env) prints its declaration. Run it from a workflow or workspace source directory, or pass --dir.

Exit codes: 0 printed; 1 no builder or namespace of that name (the closest one is named), or no cached catalog (run a get once).

### List the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers and env names source can name \[#list-the-tables-knowledge-bases-credentials-workflows-skills-custom-tools-mcp-servers-and-env-names-source-can-name]

```bash
sim workflows source resources
```

API request and response schemas: [getSourceResources](/api-reference/workflows/getSourceResources).

## Related docs \[#related-docs]

- [Workflow builder](/workflows)
- [Build and run workflows with the API](/api-reference/build-and-run-workflows)
- [Import and workspace sync](/cli/workflow-sync)
- [Scripting and exit codes](/cli/scripting#exit-codes)
