# Get workflow

> A version of a workflow (the latest when no version is given) with its document, and the workflow's region.

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

## 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"
}
```

## 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)
- [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)
- [Check a workflow email alias](https://docs.stacksync.com/api-reference/workflows/check_workflow_email_alias)