Skip to content

Workflows

Get workspace source

Read the workspace as a source directory: `secrets.ts` (secret names, never values) and `credentials.ts` (credential keys, never tokens), one declaration file per MCP server (`mcp/<key>.ts`), per deployment (`deployments/<workflow key>.ts`), per table (`tables/<key>.ts`), per custom tool (`tools/<key>.ts`, its code in `tools/<key>.js`) and per skill (`skills/<key>.md`), one folder per knowledge base (`knowledge/<key>/`, its settings beside its documents in `docs/`) and per workflow (`workflows/<key>/`, exactly as Get Workflow Source prints it, with its lock and base), every workspace file under `files/`, the binary files (workspace files and knowledge documents) listed by hash with an `href` to download each, and `base`, which binds each resource key to its id and records each resource's fingerprint. Each resource appears by its resource key: allocated from its name the first time source names it, then never changed. `kinds` narrows the read; the directory then manages only those kinds. A resource left out (too large to read as source, not readable by the caller, or past the directory's declaration or binary-file budget) is listed in `skipped` with why, and a kind holding more than 500 resources is left out with `E_LIMIT_EXCEEDED`. A table's rows are part of source only when its declaration opts in with `rows` (`tables/<key>.rows.jsonl`, at most 10000 rows each); environment values and credentials never are. This read records no audit event. Returns `403` while workflows as code is not enabled. OAuth scope: `api:read`.

GET/api/v2/workspaces/{workspaceId}/source

Read the workspace as a source directory: secrets.ts (secret names, never values) and credentials.ts (credential keys, never tokens), one declaration file per MCP server (mcp/<key>.ts), per deployment (deployments/<workflow key>.ts), per table (tables/<key>.ts), per custom tool (tools/<key>.ts, its code in tools/<key>.js) and per skill (skills/<key>.md), one folder per knowledge base (knowledge/<key>/, its settings beside its documents in docs/) and per workflow (workflows/<key>/, exactly as Get Workflow Source prints it, with its lock and base), every workspace file under files/, the binary files (workspace files and knowledge documents) listed by hash with an href to download each, and base, which binds each resource key to its id and records each resource's fingerprint. Each resource appears by its resource key: allocated from its name the first time source names it, then never changed. kinds narrows the read; the directory then manages only those kinds. A resource left out (too large to read as source, not readable by the caller, or past the directory's declaration or binary-file budget) is listed in skipped with why, and a kind holding more than 500 resources is left out with E_LIMIT_EXCEEDED. A table's rows are part of source only when its declaration opts in with rows (tables/<key>.rows.jsonl, at most 10000 rows each); environment values and credentials never are. This read records no audit event. Returns 403 while workflows as code is not enabled.

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

workspaceIdstringRequired

Workspace to read or apply.

minLength
1
maxLength
128

Query parameters

kindsstring

Comma-separated kinds to read; every kind the server supports when omitted.

minLength
1

Responses

200

The workspace as source.

object

The workspace as a source directory.

1 field
dataobjectRequired

Response data.

7 fields
workspaceIdstringRequired

Workspace id.

kindsarrayRequired

The kinds read; the directory manages exactly these.

Schema details
Array itemstring

A resource kind: secret, credential, custom-tool, skill, mcp-server, table, knowledge-base, file, workflow, deployment.

enum
["secret","credential","custom-tool","skill","mcp-server","table","knowledge-base","file","workflow","deployment"]
filesobjectRequired

Directory path → file text.

Schema details
Additional propertiesstring
blobsarrayRequired

Binary files, downloaded separately by href.

Schema details
Array itemobject
6 fields
pathstringRequired

Directory path of the binary file.

minLength
1
maxLength
1024
sha256string

Absent when the server did not hash the bytes within the request; hash the downloaded bytes and record them in the base with id and rev.

pattern
^[0-9a-f]{64}$
sizeintegerRequired

Bytes.

minimum
0
maximum
10000000
idstringRequired

Stored id of the binary file.

hrefstringRequired

Where to download its bytes.

revstring

Content revision, present when sha256 is absent.

Additional properties are not allowed.

baseobjectRequired

.sim/base.json: per resource, the id and fingerprint the directory was read at. Apply compares it with the server to tell a local edit from a server change.

3 fields
versionnumberRequired

Base format version.

const
1
workspaceIdstringRequired

Workspace the directory was read from.

resourcesobjectRequired

kind:key → the stored resource and its fingerprint.

Schema details
Additional propertiesobject

One resource in the base.

5 fields
idstringRequired

Stored id the key is bound to.

fingerprintstring

rf1: fingerprint of the resource as last read; absent for a workflow, and for a binary file listed without sha256 until the client records its hash.

columnsobject

Table column key → stored column.

Schema details
Additional propertiesobject
2 fields
idstringRequired

Stored column id.

optionsobject

Select option name → option id.

Schema details
Additional propertiesstring

Additional properties are not allowed.

blobsobject

Binary file name → its stored id, revision and hash as last read.

Schema details
Additional propertiesobject
3 fields
idstringRequired

Stored id of the binary file.

revvalueRequired

Content revision as last read.

Schema details

Any of

Option 1integer
minimum
-9007199254740991
maximum
9007199254740991
Option 2string
sha256stringRequired

SHA-256 of the bytes, lowercase hex.

pattern
^[0-9a-f]{64}$

Additional properties are not allowed.

rowsobject

A table’s managed rows, as last read.

2 fields
fingerprintstringRequired

rf1: fingerprint of the managed rows as last read.

versionintegerRequired

The table’s row version as last read; it moves on every row write.

minimum
0
maximum
9007199254740991
Additional propertiesvalue

An x- extension field, kept as written.

Additional propertiesvalue

An x- extension field, kept as written.

Additional propertiesvalue

An x- extension field, kept as written.

skippedarrayRequired

Resources left out, with why: too large to read as source, not readable by the caller, or past the directory's declaration or binary-file budget.

Schema details
Array itemobject
3 fields
kindstringRequired

A resource kind: secret, credential, custom-tool, skill, mcp-server, table, knowledge-base, file, workflow, deployment.

enum
["secret","credential","custom-tool","skill","mcp-server","table","knowledge-base","file","workflow","deployment"]
keystringRequired

Resource key.

reasonstringRequired

Why it was left out.

Additional properties are not allowed.

diagnosticsarrayRequired

Findings from reading.

Schema details
Array itemobject

A finding about the directory, pinned to its file when it has one.

15 fields
codestringRequired

Diagnostic code, e.g. E_APPLY_STALE or E_UNKNOWN_PARAM.

enum
["E_DECL_SYNTAX","E_DECL_HEADER","E_DECL_IMPORT","E_DECL_EXPORT","E_DECL_UNSUPPORTED","E_DECL_DUPLICATE_KEY","E_DECL_SHAPE","E_DECL_UNKNOWN_FIELD","E_DECL_UNKNOWN_FILE","W_PATH_NOT_SENT","E_BLOB_MANIFEST","E_BLOB_MISSING","E_KEY_INVALID","W_DECL_SUSPICIOUS_CHARACTER","E_BASE_JSON","E_BASE_VERSION","E_BASE_SHAPE","E_BASE_UNKNOWN_FIELD","E_SECRET_NAME","E_SECRET_MISSING","W_SECRET_MISSING","E_CREDENTIAL_MISSING","E_CREDENTIAL_AMBIGUOUS","W_CREDENTIAL_MISSING","W_CREDENTIAL_AMBIGUOUS","E_TABLE_COLUMN_NAME","E_TABLE_DUPLICATE_COLUMN","E_TABLE_TOO_MANY_COLUMNS","E_TABLE_OPTIONS","E_TABLE_TYPE_CONVERSION","E_TABLE_FOLDER","E_TABLE_ROWS","I_TABLE_SEED_SKIPPED","I_TABLE_ROWS_UNKEYED","W_LIKELY_RENAME","E_TOOL_SCHEMA","E_TOOL_CODE","E_TOOL_STORED_MISSING","W_TOOL_LITERAL_SECRET","E_SKILL_FRONTMATTER","E_MCP_LITERAL_SECRET","E_MCP_STORED_MISSING","E_MCP_TOOL_UNKNOWN","W_MCP_REPLACE","W_MCP_TOOLS_UNCHECKED","E_FILE_PATH","E_FILE_PATH_COLLISION","E_FILE_NAME","E_FILE_TOO_LARGE","E_FILE_CONTENT","E_KB_EMBEDDING_IMMUTABLE","E_KB_EMBEDDING_MODEL","E_KB_DOC_AMBIGUOUS","E_KB_DOC_NAME","E_KB_DOC_EMPTY","E_KB_CHUNKING","E_KB_FOLDER","W_KB_DOC_UNCHECKED","W_KB_DOC_FAILED","I_KB_REEMBED","I_KB_CHUNKING","I_KB_PROCESSING","I_KB_DOCS_UNHASHED","I_KB_UNMANAGED_DOCS","I_KB_REPLACE_UNFINISHED","E_DEPLOY_WORKFLOW","E_DEPLOY_SECRET","E_DEPLOY_CHAT_OUTPUT","E_DEPLOY_CHAT_IDENTIFIER","E_DEPLOY_PINNED_CHAT","W_DEPLOYED_DRAFT_CHANGED","W_DEPLOY_DRAFT_NOT_SOURCE","E_DEPLOY_DRAFT_NOT_SOURCE_CHAT","I_DEPLOY_DRAFT_NOT_LIVE","E_APPLY_NO_BASE","E_APPLY_FORBIDDEN","E_APPLY_DELETE_NOT_ALLOWED","E_APPLY_LOCKED","E_APPLY_REFUSED","E_APPLY_FAILED","E_PLAN_TOO_LARGE","E_PLAN_REF_DELETED","E_PLAN_REF_HELD","W_RESOURCE_IN_USE","W_TABLE_COLUMN_RENAMED_IN_USE","E_WORKFLOW_FILES_MISSING","E_WORKFLOW_FOLDER_COPIED","W_UNDECLARED","W_BASE_OTHER_WORKSPACE","W_PROMOTE_TARGET_DELETED","W_PROMOTE_DELETES_TARGET_ONLY","W_SERVER_CHANGED","W_SERVER_DELETED","W_SERVER_MOVED","I_KEY_REBOUND","E_KEY_RENAMED","E_APPLY_STALE","E_LIMIT_EXCEEDED","E_NAME_TAKEN","I_FINDINGS_TRUNCATED","E_SYNTAX","E_SDK_HEADER","E_SDK_MAJOR","E_SDK_MAJOR_OLD","E_UNSUPPORTED_SYNTAX","E_WORKFLOW_EXPORT","E_INVALID_CHARACTER","E_NUMBER_NOT_FINITE","W_NUMBER_PRECISION","E_TOO_MANY_ERRORS","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_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_WORKFLOW_META_INVALID"]
severitystringRequired

Diagnostic severity.

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

What was found.

hintstring

How to address it.

filestring

Directory 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.

pathstring

JSON Pointer into a JSON file, such as the base.

kindstring

Kind of the resource the finding is about.

keystring

Key of the resource the finding is about.

blockKeystring

Workflow block the finding is about.

paramstring

Block field the finding is about.

Additional properties are not allowed.

Additional properties are not allowed.

Additional properties are not allowed.

Response example 1

json
{
  "data": {
    "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
    "kinds": [
      "table",
      "workflow"
    ],
    "files": {
      "tables/leads.ts": "// @sim-sdk 1\nimport { column, defineTable } from '@sim/workflow-sdk/workspace'\n\nexport default defineTable({\n  name: 'leads',\n  columns: {\n    email: column.string({ required: true, unique: true }),\n    status: column.select({ options: ['new', 'won'] }),\n  },\n})\n"
    },
    "blobs": [],
    "base": {
      "version": 1,
      "workspaceId": "a91c4b2e-6d3f-4e8a-b5c7-0d9e2f1a8c64",
      "resources": {
        "table:leads": {
          "id": "tbl_5c0e2a7b9d1f4e3a8b6c2d0f7e9a1b3c",
          "fingerprint": "rf1:4b8d2f6a0c3e7b1d5f9a2c6e0b4d8f3a7c1e5b9d2f6a0c4e8b3d7f1a5c9e2b6d",
          "columns": {
            "email": {
              "id": "col_8e1c4a7b2d5f"
            },
            "status": {
              "id": "col_3b6d9f2a5c8e",
              "options": {
                "new": "k2Pq9x",
                "won": "r7Tn4m"
              }
            }
          }
        }
      }
    },
    "skipped": [],
    "diagnostics": []
  }
}

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