# Get Workflow Definition

Read a workflow's whole structure in one call: its properties, its triggers, and its steps as a tree in execution order. Read the draft the editor shows, the published version that runs, or any saved version. Step settings are not included yet.

`GET https://connect.mindcloud.co/v2/workflows/:workflowId/definition`

Permissions: `workflow:view`.

## Parameters

### Path

- `workflowId` (string, required): The workflow's id, from List Workflows.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. A key can also act in its child organizations, and, with "Use this key across all of your organizations" on, in every organization its creator can open in the app. List them with GET /v2/companies. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Query

- `version` (string): draft (the default), published, or a version label from List Workflow Versions.
  draft (the default, what the editor shows), published (what runs), or a version label from List Workflow Versions, such as 0.0.14.
  Default: `draft`

## Example request

```bash
curl --request GET \
  --url 'https://connect.mindcloud.co/v2/workflows/Wq3kZ8pLx2Nb/definition?version=draft' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN'
```

## Response fields

- `id` (string): The workflow's id.
- `name` (string): The workflow's name.
- `type` (string): workflow, or function for a workflow other workflows call.
- `isActive` (boolean): Whether the published version runs on its triggers.
- `environmentId` (string): The environment the workflow runs in. Null for the default environment.
- `tags` (array of string): Ids of the tags on the workflow.
- `version` (string): The version this answer describes: draft, or the saved version label.
- `publishedVersion` (string): The version that runs. Null when the workflow was never published.
- `changesSincePublish` (number): How many draft edits are not published yet.
- `revision` (string): The draft's revision: send it in If-Match on your next change to the draft. The response's ETag header is the same value. Null when reading a saved version, which never changes.
- `triggers` (array of objects): What starts the workflow. A workflow can have several.
  - `id` (string): The trigger's id.
  - `name` (string): The trigger's display name.
  - `appSlug` (string): What starts the workflow: schedule, webhook, runWorkflow (when another workflow calls it), or the app whose event does.
  - `appVersion` (string): The app version the trigger is pinned to. For a built-in trigger (Schedule, Webhook, When called), the version of the built-in app it was added with, "0" or "0.0.1" (some older ones hold "draft" or null); it does not change what the trigger does.
  - `actionId` (string): The app event the trigger listens for. Null for a built-in trigger.
  - `isDisabled` (boolean): True when the trigger is turned off.
  - `isConfigured` (boolean): Whether the trigger passed the editor's validation. Null when it was never validated.
- `steps` (array of objects): The steps, top level first, in execution order. A step that holds others carries them in body (a loop, folder or batch step) or then and else (an If/Else).
  - `id` (string): The step's id. Stable across edits; never positional.
  - `number` (number): The number the editor shows for this step, in execution order. Null for a folder, which the editor does not number.
  - `name` (string): The step's display name.
  - `appSlug` (string): The app the step runs, or the built-in step type (iterate, ifElse, map, ...).
  - `appVersion` (string): The app version the step is pinned to. For a built-in step (If, Loop, Map, ...), the version of the built-in app it was added with, "0" or "0.0.1" (some older ones hold "draft" or null); it does not change what the step does.
  - `actionId` (string): The app action the step runs. Null for a built-in step type.
  - `functionId` (string): The function this step calls, for a function call step.
  - `parentStepId` (string): The step this one sits inside (a loop, group, folder or if/else). Null at the top level.
  - `slot` (string): Where the step sits in its parent: steps (the top level), body (a loop, group or folder), then or else (an if/else lane).
    Allowed values:
      - `steps`
      - `body`
      - `then`
      - `else`
  - `depth` (number): How deeply the step is nested. 0 at the top level.
  - `isDisabled` (boolean): True when the step is turned off and runs skip it.
  - `isConfigured` (boolean): Whether the step passed the editor's validation (required values set, connection chosen). Null when it was never validated.
  - `body` (array): Steps nested inside this one, in order. Present when it has any; each has the same keys.
  - `then` (array): Steps nested inside this one, in order. Present when it has any; each has the same keys.
  - `else` (array): Steps nested inside this one, in order. Present when it has any; each has the same keys.
