Skip to content

Workflows

Plan workflow source

Report what Apply Workflow Source would do with this source, without writing: whether the draft changed since `base` (`E_APPLY_STALE`), the diff, and every finding, exactly as `dryRun=true` reports them, with `200`. A read: it needs only workspace read access, draws on the source-plan budget rather than the source-write budget (a server already running as many plans as it allows answers `429`), and records no audit or analytics event, so `sim workflows source status` never spends what an apply needs. `allowDelete=true` plans block and variable deletes instead of reporting `E_APPLY_BLOCK_DELETE` or `E_APPLY_VARIABLE_DELETE`. Returns `403` while workflows as code is not enabled. Workspace API keys return `403`; use a personal API key or scoped OAuth token. OAuth scope: `api:read`.

POST/api/v2/workflows/{workflowId}/source/plan

Report what Apply Workflow Source would do with this source, without writing: whether the draft changed since base (E_APPLY_STALE), the diff, and every finding, exactly as dryRun=true reports them, with 200. A read: it needs only workspace read access, draws on the source-plan budget rather than the source-write budget (a server already running as many plans as it allows answers 429), and records no audit or analytics event, so sim workflows source status never spends what an apply needs. allowDelete=true plans block and variable deletes instead of reporting E_APPLY_BLOCK_DELETE or E_APPLY_VARIABLE_DELETE. Returns 403 while workflows as code is not enabled. Workspace API keys return 403; use a personal API key or scoped OAuth token.

OAuth scope: api:read.

Authentication

Send a personal or workspace API key in X-API-Key. See key types and access; operations that reject workspace keys say so in their description.

Send X-API-Key in the request header.

Alternatively

Send a Sim OAuth access token in Authorization: Bearer. See OAuth authentication and scopes.

Authorization: Bearer YOUR_ACCESS_TOKEN

Required scopes: api:read

OAuth flows
json
{
  "authorizationCode": {
    "authorizationUrl": "https://www.sim.ai/api/auth/oauth2/authorize",
    "tokenUrl": "https://www.sim.ai/api/auth/oauth2/token",
    "refreshUrl": "https://www.sim.ai/api/auth/oauth2/token",
    "scopes": {
      "api:read": "Read your workspaces, workflows, files, tables, and logs",
      "api:write": "Read, create, change, run, and delete resources in your workspaces",
      "offline_access": "Stay signed in without asking again"
    }
  }
}

OAuth scope: api:read.

Path parameters

workflowIdstringRequired

Unique workflow identifier.

minLength
1

Query parameters

allowDeleteboolean

Plan the deletes of blocks and variables the source no longer declares as an apply with allowDelete would, listing them in the diff, instead of reporting E_APPLY_BLOCK_DELETE or E_APPLY_VARIABLE_DELETE.

Request body

Required

Edited source files with the lock and base they were read with.

object

Edited source files with the lock and base they were read with.

3 fields
filesobjectRequired

Relative path → file text: workflow.ts plus every function-code file it references (for example functions/score.js). At most 2001 files and 4000000 bytes together, for a workflow of at most 2000 blocks.

Schema details
Additional propertiesstring
lockobjectRequired

Identity sidecar (.sim/lock.json): binds the keys in the source to stored ids.

3 fields
versionnumberRequired

Lock format version.

const
1
blocksobjectRequired

Block key → identity.

Schema details
Additional propertiesobject

One block’s identity.

8 fields
idstringRequired

Block id.

parentvalueRequired

Key of the enclosing loop or parallel, or null.

Schema details

Any of

Option 1string
Option 2null
branchesobject

Condition or router branch key → stored branch id.

Schema details
Additional propertiesstring
itemsobject

Per field, its id-bearing items (input format fields) in stored order.

Schema details
Additional propertiesarray
Schema details
Array itemobject

One id-bearing list item.

2 fields
namestringRequired

Item name.

idstringRequired

Item id.

Additional properties are not allowed.

identstringRequired

The const name the block is printed as.

orderintegerRequired

Declaration-order tie-break.

minimum
-9007199254740991
maximum
9007199254740991
layoutobject

Stored canvas geometry; applied only to new blocks.

6 fields
xnumberRequired

Canvas x position.

ynumberRequired

Canvas y position.

wnumber

Container width.

hnumber

Container height.

heightnumber

Stored block height.

horizontalHandlesboolean

Handles on the left and right.

Additional propertiesvalue

An x- extension field, kept verbatim.

codeFilestring

Path of the block’s function-code file.

Additional propertiesvalue

An x- extension field, kept verbatim.

variablesobjectRequired

Variable key → variable id.

Schema details
Additional propertiesstring
Additional propertiesvalue

An x- extension field, kept verbatim.

baseobjectRequired

Where and when the source was read (.sim/base.json). A draft that no longer matches base.fingerprint is reported as E_APPLY_STALE in diagnostics.

5 fields
versionnumber

Base format version; a base written before it existed reads as 1.

default
1
const
1
workflowIdstringRequired

Workflow the source was read from; an apply to another workflow is refused.

minLength
1
workspaceIdstringRequired

Workspace the workflow belongs to.

fingerprintstringRequired

Freshness token of the draft the source was read at: a hash of the canonical workflow and its ids. It ignores canvas positions, so moving blocks does not change it.

minLength
1
maxLength
256
catalogHashstringRequired

Hash of the block catalog the source was printed against.

Additional propertiesvalue

An x- extension field, kept verbatim.

Additional properties are not allowed.

Request example 1

json
{
  "files": {
    "workflow.ts": "// @sim-sdk 1\nimport { trigger, workflow } from '@sim/workflow-sdk'\n\nexport default workflow('Support triage', () => {\n  const start = trigger.start('Start')\n})\n"
  },
  "lock": {
    "version": 1,
    "blocks": {
      "start": {
        "id": "a3f1c0b2-7a44-4c1d-9d3a-2b8e5f0a1c77",
        "parent": null,
        "ident": "start",
        "order": 0
      }
    },
    "variables": {}
  },
  "base": {
    "version": 1,
    "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36",
    "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
    "fingerprint": "sf1:9c1d4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8e1f4a7b0c3d6e9f2a5b8c1d",
    "catalogHash": "3f0c1a9e5b7d2c4f6a8e0b1d3c5f7a9e2b4d6f8a0c2e4b6d8f0a2c4e6b8d0f2a"
  }
}

Responses

200

The evaluated source.

object

What an apply would store, and every finding.

1 field
dataobjectRequired

Response data.

12 fields
workflowIdstringRequired

Workflow id.

workspaceIdstringRequired

Workspace id.

dryRunbooleanRequired

True when nothing was written because dryRun was set.

appliedbooleanRequired

True when the draft was written or the workflow renamed or redescribed; false on a dry run and on a no-op.

diffobjectRequired

What the apply changed, or would change on a dry run.

5 fields
noopbooleanRequired

True when the source matches the saved draft.

metaarray

The workflow name and description fields the source changes.

Schema details
Array itemstring
enum
["name","description"]
blocksobjectRequired

Block changes.

4 fields
addedarrayRequired

New blocks.

Schema details
Array itemobject

An added or removed block by id, source key and type.

3 fields
idstringRequired

Stored block id.

keystringRequired

Block key in the source.

typestringRequired

Block type.

Additional properties are not allowed.

removedarrayRequired

Deleted blocks.

Schema details
Array itemobject

An added or removed block by id, source key and type.

3 fields
idstringRequired

Stored block id.

keystringRequired

Block key in the source.

typestringRequired

Block type.

Additional properties are not allowed.

renamedarrayRequired

Renamed blocks; each keeps its id.

Schema details
Array itemobject

A renamed block.

3 fields
idstringRequired

Stored block id; unchanged by the rename.

fromstringRequired

Previous key.

tostringRequired

New key.

Additional properties are not allowed.

modifiedarrayRequired

Changed blocks.

Schema details
Array itemobject

A changed block.

4 fields
idstringRequired

Stored block id.

keystringRequired

Block key in the source.

fieldsarrayRequired

Changed fields, modes (modes.<param>) and attributes.

Schema details
Array itemstring
reparentedboolean

Moved into or out of a container.

Additional properties are not allowed.

Additional properties are not allowed.

edgesobjectRequired

Connection changes.

2 fields
addedintegerRequired

Connections added.

minimum
-9007199254740991
maximum
9007199254740991
removedintegerRequired

Connections removed.

minimum
-9007199254740991
maximum
9007199254740991

Additional properties are not allowed.

variablesobjectRequired

Variable changes.

4 fields
addedarrayRequired

Variable keys added.

Schema details
Array itemstring
removedarrayRequired

Variable keys removed.

Schema details
Array itemstring
renamedarrayRequired

Variables renamed; each keeps its id, so none is deleted.

Schema details
Array itemobject

A renamed variable.

2 fields
fromstringRequired

Former key.

tostringRequired

New key.

Additional properties are not allowed.

modifiedarrayRequired

Variable keys changed.

Schema details
Array itemstring

Additional properties are not allowed.

Additional properties are not allowed.

diagnosticsarrayRequired

Warnings, and on a dry run every error a commit would refuse.

Schema details
Array itemobject

A finding from applying workflow source, pinned to the submitted files.

14 fields
codestringRequired

Diagnostic code, e.g. E_UNKNOWN_PARAM or E_APPLY_LOCKED_BLOCK.

enum
["E_SYNTAX","E_SDK_HEADER","E_SDK_MAJOR","E_SDK_MAJOR_OLD","E_UNSUPPORTED_SYNTAX","E_WORKFLOW_EXPORT","E_LIMIT_EXCEEDED","E_INVALID_CHARACTER","E_NUMBER_NOT_FINITE","W_NUMBER_PRECISION","E_TOO_MANY_ERRORS","I_FINDINGS_TRUNCATED","E_DUPLICATE_NAME","E_RESERVED_NAME","E_KEY_OVERRIDE","E_EMPTY_NAME","E_LOOKALIKE_NAME","W_LOOKALIKE_NAME","W_SUSPICIOUS_CHARACTER","E_NAME_NOT_LITERAL","E_UNKNOWN_IDENTIFIER","E_OUT_OF_SCOPE","E_UNKNOWN_VARIABLE","E_DUPLICATE_VARIABLE","E_VARIABLE_NAME_MISMATCH","E_INVALID_ENV_NAME","W_ENV_UNKNOWN","W_CHILD_INPUT_UNKNOWN","W_CHILD_NO_START","W_CHILD_RESULT_PATH","E_UNKNOWN_SUBFLOW_PROPERTY","W_FORWARD_REF","W_REF_NOT_NORMALIZED","E_REF_UNREPRESENTABLE","W_REF_OUT_OF_SCOPE","E_EDGE_SCOPE","E_EDGE_NOTE","E_TARGET_TRIGGER","E_NO_DEFAULT_OUTPUT","E_DUPLICATE_EDGE","E_ERROR_PORT_UNSUPPORTED","W_ERROR_PORT_STORED","E_UNKNOWN_BRANCH","E_DUPLICATE_BRANCH_KEY","E_BRANCH_KEY_COLLIDES","E_BRANCH_ELSE_LAST","W_RAW_HANDLE","W_SUBFLOW_HANDLE_SCOPE","E_EDGE_CYCLE","W_EDGE_CYCLE","W_BRANCH_UNWIRED","E_UNKNOWN_BUILDER","E_UNKNOWN_PARAM","E_FIXED_PARAM","W_FIELD_NOT_APPLICABLE","W_REQUIRED_MISSING","W_UNKNOWN_OPTION","E_UNKNOWN_OPERATION","W_UNKNOWN_MODEL","W_LEGACY_BLOCK_TYPE","W_UNKNOWN_BLOCK_TYPE","W_TYPE_NOT_ADDABLE","I_SCHEDULE_UTC","E_STORED_VALUE_MISSING","W_VALUE_KIND","W_OUT_OF_RANGE","W_TABLE_FILTER_SHAPE","W_LITERAL_SECRET","W_SUBFLOW_COUNT","W_UNKNOWN_OUTPUT_PATH","W_OUTPUT_PATH_UNDECLARED","W_JSON_REF_UNTYPED","W_LOOP_CONDITION_SYNTAX","E_CODE_FILE_MISSING","E_CODE_FILE_PATH","W_CODE_FILE_INLINED","W_CODE_FILE_REF_SYNTAX","W_UNRESOLVED_REF","W_FORWARD_REF_LITERALIZED","W_COMMENT_MOVED","W_COMMENT_DROPPED","E_LOCK_JSON","E_LOCK_VERSION","E_LOCK_SHAPE","E_LOCK_UNKNOWN_FIELD","E_LOCK_KEY","E_LOCK_IDENT","E_LOCK_DUPLICATE_IDENT","E_LOCK_DUPLICATE_ID","E_LOCK_PARENT","E_LOCK_BRANCH","E_LOCK_CODE_FILE_PATH","E_SOURCE_META_JSON","E_SOURCE_META_VERSION","E_SOURCE_META_SHAPE","E_SOURCE_META_UNKNOWN_FIELD","E_SOURCE_META_IDENT","E_SOURCE_META_DUPLICATE_IDENT","E_SOURCE_META_ANCHOR","E_CANON_LEGACY_NAME_COLLISION","E_CANON_EDGE_SCOPE","W_CANON_RESERVED_NAME","W_CANON_DANGLING_EDGE","W_CANON_DANGLING_PARENT","W_CANON_RAW_HANDLE","W_CANON_UNKNOWN_BLOCK_TYPE","W_CANON_UNRESOLVED_ID","W_CANON_TITLE_OVERRIDE","W_CANON_SUBFLOW_REPAIRED","W_CANON_SUBBLOCK_TYPE_DRIFT","W_CANON_UNDECODABLE_JSON","E_MAT_DUPLICATE_LOCK_ID","E_MAT_UNKNOWN_RESOURCE","E_MAT_UNKNOWN_VARIABLE","W_MAT_DELETED_SINCE_PULL","W_MAT_INFERRED_RENAME","W_MAT_RETYPE_RECREATED","W_MAT_LOCK_ID_CLAIMED","I_MAT_NEEDS_LAYOUT","E_APPLY_STALE","E_APPLY_WORKFLOW_MISMATCH","E_APPLY_LOCKED_BLOCK","E_APPLY_TYPE_NOT_ADDABLE","E_APPLY_INVALID_STATE","E_APPLY_BLOCK_NOT_FOUND","E_APPLY_INVALID_BLOCK_TYPE","E_APPLY_BLOCK_NOT_ALLOWED","E_APPLY_MODEL_NOT_ALLOWED","E_APPLY_TOOL_NOT_ALLOWED","E_APPLY_INVALID_EDGE_SOURCE","E_APPLY_INVALID_EDGE_SCOPE","E_APPLY_INVALID_SOURCE_HANDLE","E_APPLY_INVALID_TARGET_HANDLE","E_APPLY_INVALID_SUBBLOCK_FIELD","E_APPLY_MISSING_REQUIRED_PARAMS","E_APPLY_RETRY_NOT_SUPPORTED","E_APPLY_DUPLICATE_TRIGGER","E_APPLY_DUPLICATE_SINGLE_INSTANCE_BLOCK","E_APPLY_DISABLED_ANCESTOR","E_APPLY_CREDENTIAL_UNREACHABLE","W_APPLY_CREDENTIAL_KEPT","E_APPLY_SANDBOX_PLAN_REQUIRED","W_APPLY_HOSTED_KEY_DROPPED","W_APPLY_VALUE_NORMALIZED","W_APPLY_TYPE_CHANGED","W_APPLY_TRIGGER_REMOVED","W_APPLY_CATALOG_MOVED","W_APPLY_PROBABLE_RENAME","E_APPLY_LINT","E_APPLY_UNRESOLVED_REF","E_APPLY_REF_OUT_OF_SCOPE","E_APPLY_CODE_FILE_REF_SYNTAX","E_APPLY_LOOP_CONDITION_SYNTAX","W_APPLY_LINT","W_TABLE_UNKNOWN_COLUMN","E_APPLY_INVALID_SCHEDULE","E_APPLY_BLOCK_DELETE","E_APPLY_VARIABLE_DELETE","E_NAME_TAKEN","E_WORKFLOW_META_INVALID"]
severitystringRequired

Diagnostic severity.

enum
["error","warning","info"]
messagestringRequired

What was found.

hintstring

How to address it.

blockKeystring

Block the finding is about.

paramstring

Field the finding is about.

filestring

Submitted file the finding is in.

lineinteger

1-based line in file.

minimum
-9007199254740991
maximum
9007199254740991
columninteger

1-based column in file.

minimum
-9007199254740991
maximum
9007199254740991
endLineinteger

1-based line the finding ends on.

minimum
-9007199254740991
maximum
9007199254740991
endColumninteger

1-based column the finding ends at.

minimum
-9007199254740991
maximum
9007199254740991
framestring

The source lines around the finding, with a caret row.

blockIdstring

Stored id of the block the finding is about.

pathstring

JSON Pointer into the lock, for a lock finding.

Additional properties are not allowed.

filesobjectRequired

The source re-printed from what was saved, including any normalized values.

Schema details
Additional propertiesstring
lockobjectRequired

Identity sidecar (.sim/lock.json): binds the keys in the source to stored ids.

3 fields
versionnumberRequired

Lock format version.

const
1
blocksobjectRequired

Block key → identity.

Schema details
Additional propertiesobject

One block’s identity.

8 fields
idstringRequired

Block id.

parentvalueRequired

Key of the enclosing loop or parallel, or null.

Schema details

Any of

Option 1string
Option 2null
branchesobject

Condition or router branch key → stored branch id.

Schema details
Additional propertiesstring
itemsobject

Per field, its id-bearing items (input format fields) in stored order.

Schema details
Additional propertiesarray
Schema details
Array itemobject

One id-bearing list item.

2 fields
namestringRequired

Item name.

idstringRequired

Item id.

Additional properties are not allowed.

identstringRequired

The const name the block is printed as.

orderintegerRequired

Declaration-order tie-break.

minimum
-9007199254740991
maximum
9007199254740991
layoutobject

Stored canvas geometry; applied only to new blocks.

6 fields
xnumberRequired

Canvas x position.

ynumberRequired

Canvas y position.

wnumber

Container width.

hnumber

Container height.

heightnumber

Stored block height.

horizontalHandlesboolean

Handles on the left and right.

Additional propertiesvalue

An x- extension field, kept verbatim.

codeFilestring

Path of the block’s function-code file.

Additional propertiesvalue

An x- extension field, kept verbatim.

variablesobjectRequired

Variable key → variable id.

Schema details
Additional propertiesstring
Additional propertiesvalue

An x- extension field, kept verbatim.

baseobjectRequired

Where the saved (or, on a dry run, would-be) draft was read: the next apply’s base.

5 fields
versionnumberRequired

Base format version; a base written before it existed reads as 1.

default
1
const
1
workflowIdstringRequired

Workflow the source was read from; an apply to another workflow is refused.

minLength
1
workspaceIdstringRequired

Workspace the workflow belongs to.

fingerprintstringRequired

Freshness token of the draft the source was read at: a hash of the canonical workflow and its ids. It ignores canvas positions, so moving blocks does not change it.

minLength
1
maxLength
256
catalogHashstringRequired

Hash of the block catalog the source was printed against.

Additional propertiesvalue

An x- extension field, kept verbatim.

mintedIdsobjectRequired

Block key → id for new blocks whose id was minted rather than taken from the lock.

Schema details
Additional propertiesstring
notesarrayRequired

Non-fatal notes about the write.

Schema details
Array itemstring
needsRedeploymentbooleanRequired

Whether the draft now differs from the live deployment; apply never deploys.

Additional properties are not allowed.

Additional properties are not allowed.

Response example 1

json
{
  "data": {
    "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36",
    "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
    "dryRun": true,
    "applied": false,
    "diff": {
      "noop": true,
      "blocks": {
        "added": [],
        "removed": [],
        "renamed": [],
        "modified": []
      },
      "edges": {
        "added": 0,
        "removed": 0
      },
      "variables": {
        "added": [],
        "removed": [],
        "renamed": [],
        "modified": []
      }
    },
    "diagnostics": [],
    "files": {
      "workflow.ts": "// @sim-sdk 1\nimport { trigger, workflow } from '@sim/workflow-sdk'\n\nexport default workflow('Support triage', () => {\n  const start = trigger.start('Start')\n})\n"
    },
    "lock": {
      "version": 1,
      "blocks": {
        "start": {
          "id": "a3f1c0b2-7a44-4c1d-9d3a-2b8e5f0a1c77",
          "parent": null,
          "ident": "start",
          "order": 0
        }
      },
      "variables": {}
    },
    "base": {
      "version": 1,
      "workflowId": "3b1f7c92-8d4e-4a6b-9c0d-5e2f8a714b36",
      "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
      "fingerprint": "sf1:9c1d4e7f0a3b6c9d2e5f8a1b4c7d0e3f6a9b2c5d8e1f4a7b0c3d6e9f2a5b8c1d",
      "catalogHash": "3f0c1a9e5b7d2c4f6a8e0b1d3c5f7a9e2b4d6f8a0c2e4b6d8f0a2c4e6b8d0f2a"
    },
    "mintedIds": {},
    "notes": [],
    "needsRedeployment": false
  }
}

Response headers

X-RateLimit-Limitinteger

Maximum requests allowed in the current window.

minimum
0
maximum
9007199254740991
X-RateLimit-Remaininginteger

Requests remaining in the current window.

minimum
0
maximum
9007199254740991
X-RateLimit-Resetstring

ISO 8601 timestamp when the current rate-limit window resets.

format
date-time
pattern
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?(?:Z))$
Was this helpful?
Suggest an edit