# Get workflow

> A version of a workflow (the latest when no version is given) with its document, the workflow's region, and the URLs that run its webhook trigger steps.

Source: https://docs.stacksync.com/api-reference/workflows/get_workflow

`GET https://api.stacksync.com/v1/workspaces/{workspace_id}/workflows/id/{workflow_id}/`

- Operation: `get_workflow`
- Resource: Workflows
- Access: read-only

## Authentication

- `Authorization: Bearer <key>`: A workspace API key (workspace_…, created by a workspace owner under Workspace settings > Stacksync API) acts with editor rights on that workspace only; a user API key (user_…, created under Profile > Stacksync API) acts as that user in every workspace they belong to. POST, PUT and PATCH requests must send Content-Type: application/json. Every authentication failure answers 403.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `workspace_id` | integer | Yes | The workspace. List the ones your key can reach with GET /v1/workspaces. |
| `workflow_id` | string (uuid) | Yes | The workflow. |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `region` | string (besg \| usnv) \| null | No | Region to get the workflow from. If not provided, multiple regions will be searched. To increase performance, it is recommended to provide a region. |
| `version` | string \| null | No | Version of the workflow to get. If not provided, the latest version will be returned. |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow` | object (WorkflowVersion) | Yes | A version of a workflow, as the documented "Get workflow" answers it; workflow_schema is the workflow document |
| `workflow.workflow_id` | string | Yes |  |
| `workflow.workflow_version` | string | Yes |  |
| `workflow.workflow_status` | string | Yes |  |
| `workflow.is_draft` | boolean | Yes |  |
| `workflow.is_deployed` | boolean | Yes |  |
| `workflow.workflow_schema` | object (WorkflowSchemaModel) \| null | No |  |
| `workflow.workflow_schema.workflow_execution_timeout` | integer \| null, default 300 | No |  |
| `workflow.workflow_schema.workflow_module_execution_timeout` | integer \| null, default 300 | No |  |
| `workflow.workflow_schema.return_workflow_module_instance_ids` | array of string \| null | No |  |
| `workflow.workflow_schema.modules` | array of object (WorkflowSchemaModuleModel) | Yes |  |
| `workflow.workflow_schema.modules[].name` | string | Yes |  |
| `workflow.workflow_schema.modules[].workflow_module_instance_id` | string | Yes |  |
| `workflow.workflow_schema.modules[].module_id` | string | Yes |  |
| `workflow.workflow_schema.modules[].description` | string \| null | No |  |
| `workflow.workflow_schema.modules[].properties` | object | Yes |  |
| `workflow.workflow_schema.modules[].connections` | array of object (WorkflowModuleConnectionManagedModelByResourceId) \| object (WorkflowModuleConnectionManagedModelByName) \| object (WorkflowModuleConnectionUserDataModel), default [] | No |  |
| `workflow.workflow_schema.modules[].module_options` | object (WorkflowSchemaModuleOptionsModel) \| null | No |  |
| `workflow.workflow_schema.modules[].module_options.patches` | object \| null | No |  |
| `workflow.workflow_schema.modules[].module_options.layout` | object (WorkflowSchemaModuleOptionsLayoutModel) \| null | No |  |
| `workflow.workflow_schema.modules[].module_options.layout.group_module_instance_id` | string \| null | No |  |
| `workflow.workflow_schema.modules[].module_options.enable_error_handling` | boolean \| null | No |  |
| `workflow.workflow_schema.modules[].module_options.workflow_module_execution_timeout` | integer \| null | No |  |
| `workflow.workflow_schema.modules[].error_handling_strategy` | object (WorkflowModuleErrorStrategyModel) \| null | No |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.conditions` | array of object (WorkflowModuleErrorStrategyConditionModel), default [] | No |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.conditions[].condition` | object (WorkflowModuleConditionGroupModel) \| object (WorkflowModuleConditionValueModel) \| object (WorkflowModuleConditionComparatorModel) | Yes |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.conditions[].retry_policy` | object (WorkflowModuleErrorStrategyConditionActionModel) | Yes |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.else_condition` | object (WorkflowModuleErrorStrategyConditionActionModel) \| null | No |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.else_condition.retry_count` | integer, default 0 | No |  |
| `workflow.workflow_schema.modules[].error_handling_strategy.else_condition.retry_interval` | integer, default 0 | No |  |
| `workflow.workflow_schema.edges` | array of object (WorkflowSchemaEdgeModel) | Yes |  |
| `workflow.workflow_schema.edges[].source` | object (WorkflowSchemaEdgeHandleModel) | Yes |  |
| `workflow.workflow_schema.edges[].source.handle_id` | string \| null | No |  |
| `workflow.workflow_schema.edges[].source.workflow_module_instance_id` | string | Yes |  |
| `workflow.workflow_schema.edges[].target` | object (WorkflowSchemaEdgeHandleModel) | Yes |  |
| `workflow.workflow_schema.edges[].target.handle_id` | string \| null | No |  |
| `workflow.workflow_schema.edges[].target.workflow_module_instance_id` | string | Yes |  |
| `workflow.workflow_schema.edges[].edge_id` | string | Yes |  |
| `workflow.options` | object \| null | No |  |
| `workflow.created_by` | integer | Yes |  |
| `workflow.created_time` | string | Yes |  |
| `workflow.last_modified_by` | integer | Yes |  |
| `workflow.last_modified_time` | string | Yes |  |
| `region` | string (besg \| usnv) | Yes |  |
| `webhook_triggers` | array of object (WebhookTrigger) | No | The webhook trigger steps of the version and the URLs that run them |
| `webhook_triggers[].step_id` | string | Yes |  |
| `webhook_triggers[].draft` | object (WebhookTriggerRequest) \| null | Yes | Runs the latest draft; null when the latest version is not a draft holding the step |
| `webhook_triggers[].draft.url` | string | Yes | Queues a run of this version and answers its id |
| `webhook_triggers[].draft.method` | string | Yes | The HTTP method the step takes: GET or POST |
| `webhook_triggers[].draft.wait_for_result_url` | string \| null | Yes | When the step waits for the result: the URL answering the run's result instead of its id; null otherwise |
| `webhook_triggers[].draft.requires_api_key` | boolean | Yes | Send one of the step's API keys as `Authorization: Bearer <key>`; a key is shown once, when it is generated on the step in the web app |
| `webhook_triggers[].draft.query_parameter_names` | array of string | Yes | The query parameters the step reads |
| `webhook_triggers[].draft.header_names` | array of string | Yes | The headers the step reads |
| `webhook_triggers[].deployed` | object (WebhookTriggerRequest) \| null | Yes | Runs the deployed version; null when no deployed version holds the step |
| `webhook_triggers[].deployed.url` | string | Yes | Queues a run of this version and answers its id |
| `webhook_triggers[].deployed.method` | string | Yes | The HTTP method the step takes: GET or POST |
| `webhook_triggers[].deployed.wait_for_result_url` | string \| null | Yes | When the step waits for the result: the URL answering the run's result instead of its id; null otherwise |
| `webhook_triggers[].deployed.requires_api_key` | boolean | Yes | Send one of the step's API keys as `Authorization: Bearer <key>`; a key is shown once, when it is generated on the step in the web app |
| `webhook_triggers[].deployed.query_parameter_names` | array of string | Yes | The query parameters the step reads |
| `webhook_triggers[].deployed.header_names` | array of string | Yes | The headers the step reads |

## Example request

```bash
curl -X GET "https://api.stacksync.com/v1/workspaces/{workspace_id}/workflows/id/{workflow_id}/" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY"
```

## Example response (200)

```json
{
  "workflow": {
    "workflow_id": "<workflow_id>",
    "workflow_version": "<workflow_version>",
    "workflow_status": "<workflow_status>",
    "is_draft": false,
    "is_deployed": false,
    "workflow_schema": {
      "workflow_execution_timeout": 300,
      "workflow_module_execution_timeout": 300,
      "return_workflow_module_instance_ids": [
        "<return_workflow_module_instance_ids>"
      ],
      "modules": [
        {
          "name": "<name>",
          "workflow_module_instance_id": "<workflow_module_instance_id>",
          "module_id": "<module_id>",
          "description": "<description>",
          "properties": {},
          "connections": [],
          "module_options": {
            "patches": {},
            "layout": {
              "group_module_instance_id": "<group_module_instance_id>"
            },
            "enable_error_handling": false,
            "workflow_module_execution_timeout": 0
          },
          "error_handling_strategy": {
            "conditions": [],
            "else_condition": {
              "retry_count": 0,
              "retry_interval": 0
            }
          }
        }
      ],
      "edges": [
        {
          "source": {
            "handle_id": "<handle_id>",
            "workflow_module_instance_id": "<workflow_module_instance_id>"
          },
          "target": {
            "handle_id": "<handle_id>",
            "workflow_module_instance_id": "<workflow_module_instance_id>"
          },
          "edge_id": "<edge_id>"
        }
      ]
    },
    "options": {},
    "created_by": 0,
    "created_time": "<created_time>",
    "last_modified_by": 0,
    "last_modified_time": "<last_modified_time>"
  },
  "region": "besg",
  "webhook_triggers": [
    {
      "step_id": "<step_id>",
      "draft": {
        "url": "<url>",
        "method": "<method>",
        "wait_for_result_url": "<wait_for_result_url>",
        "requires_api_key": false,
        "query_parameter_names": [
          "<query_parameter_names>"
        ],
        "header_names": [
          "<header_names>"
        ]
      },
      "deployed": {
        "url": "<url>",
        "method": "<method>",
        "wait_for_result_url": "<wait_for_result_url>",
        "requires_api_key": false,
        "query_parameter_names": [
          "<query_parameter_names>"
        ],
        "header_names": [
          "<header_names>"
        ]
      }
    }
  ]
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string }` |
| 403 | Forbidden | `{ "error": string }` |
| 404 | Not Found | `{ "error": string }` |
| 422 | Unprocessable Content | `{ "error": string }` |

## Related

- [API Reference overview](https://docs.stacksync.com/api-reference): base URLs, regions, pagination, idempotency and errors
- [Authentication](https://docs.stacksync.com/api-reference/authentication): API keys and the 403 answers
- OpenAPI document: https://docs.stacksync.com/openapi.json
- [List workflows](https://docs.stacksync.com/api-reference/workflows/list_workflows)
- [List workflow versions](https://docs.stacksync.com/api-reference/workflows/list_workflow_versions)
- [Get workflow info](https://docs.stacksync.com/api-reference/workflows/get_workflow_info)
- [Create workflow](https://docs.stacksync.com/api-reference/workflows/create_workflow)
- [Create workflow draft](https://docs.stacksync.com/api-reference/workflows/create_workflow_draft)
- [Update workflow](https://docs.stacksync.com/api-reference/workflows/update_workflow)
- [Update workflow options](https://docs.stacksync.com/api-reference/workflows/update_workflow_options)
- [Delete workflow](https://docs.stacksync.com/api-reference/workflows/delete_workflow)
- [Delete workflow draft step](https://docs.stacksync.com/api-reference/workflows/delete_workflow_draft_step)
- [Run workflow](https://docs.stacksync.com/api-reference/workflows/run_workflow)
- [Deploy workflow](https://docs.stacksync.com/api-reference/workflows/deploy_workflow)
- [Duplicate workflow](https://docs.stacksync.com/api-reference/workflows/duplicate_workflow)
- [Save workflow draft](https://docs.stacksync.com/api-reference/workflows/save_workflow_draft)
- [Save workflow draft step](https://docs.stacksync.com/api-reference/workflows/save_workflow_draft_step)