# Update workflow options

> Merge options (the builder's canvas settings) into a version; a deployed version gets a new draft. Answers the latest version without its document.

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

`PATCH https://api.stacksync.com/v1/workspaces/{workspace_id}/workflows/{workflow_id}/options`

- Operation: `update_workflow_options`
- Resource: Workflows
- Access: writes data

## 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.
- `Content-Type: application/json` on every request with a body.

## 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) | Yes | Region of the resource: besg (Europe) or usnv (United States), as GET /v1/regions lists them |

## Request body

`application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `version` | string | Yes | The version whose options change; a deployed version gets a new draft |
| `options` | object | Yes | The builder's canvas settings, merged over the stored ones |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow_id` | string | Yes |  |
| `workflow_version` | string | Yes |  |
| `workflow_status` | string | Yes |  |
| `is_draft` | boolean | Yes |  |
| `is_deployed` | boolean | Yes |  |
| `workflow_schema` | object (WorkflowSchemaModel) \| null | No |  |
| `workflow_schema.workflow_execution_timeout` | integer \| null, default 300 | No |  |
| `workflow_schema.workflow_module_execution_timeout` | integer \| null, default 300 | No |  |
| `workflow_schema.return_workflow_module_instance_ids` | array of string \| null | No |  |
| `workflow_schema.modules` | array of object (WorkflowSchemaModuleModel) | Yes |  |
| `workflow_schema.modules[].name` | string | Yes |  |
| `workflow_schema.modules[].workflow_module_instance_id` | string | Yes |  |
| `workflow_schema.modules[].module_id` | string | Yes |  |
| `workflow_schema.modules[].description` | string \| null | No |  |
| `workflow_schema.modules[].properties` | object | Yes |  |
| `workflow_schema.modules[].connections` | array of object (WorkflowModuleConnectionManagedModelByResourceId) \| object (WorkflowModuleConnectionManagedModelByName) \| object (WorkflowModuleConnectionUserDataModel), default [] | No |  |
| `workflow_schema.modules[].module_options` | object (WorkflowSchemaModuleOptionsModel) \| null | No |  |
| `workflow_schema.modules[].module_options.patches` | object \| null | No |  |
| `workflow_schema.modules[].module_options.layout` | object (WorkflowSchemaModuleOptionsLayoutModel) \| null | No |  |
| `workflow_schema.modules[].module_options.layout.group_module_instance_id` | string \| null | No |  |
| `workflow_schema.modules[].module_options.enable_error_handling` | boolean \| null | No |  |
| `workflow_schema.modules[].module_options.workflow_module_execution_timeout` | integer \| null | No |  |
| `workflow_schema.modules[].error_handling_strategy` | object (WorkflowModuleErrorStrategyModel) \| null | No |  |
| `workflow_schema.modules[].error_handling_strategy.conditions` | array of object (WorkflowModuleErrorStrategyConditionModel), default [] | No |  |
| `workflow_schema.modules[].error_handling_strategy.conditions[].condition` | object (WorkflowModuleConditionGroupModel) \| object (WorkflowModuleConditionValueModel) \| object (WorkflowModuleConditionComparatorModel) | Yes |  |
| `workflow_schema.modules[].error_handling_strategy.conditions[].retry_policy` | object (WorkflowModuleErrorStrategyConditionActionModel) | Yes |  |
| `workflow_schema.modules[].error_handling_strategy.conditions[].retry_policy.retry_count` | integer, default 0 | No |  |
| `workflow_schema.modules[].error_handling_strategy.conditions[].retry_policy.retry_interval` | integer, default 0 | No |  |
| `workflow_schema.modules[].error_handling_strategy.else_condition` | object (WorkflowModuleErrorStrategyConditionActionModel) \| null | No |  |
| `workflow_schema.modules[].error_handling_strategy.else_condition.retry_count` | integer, default 0 | No |  |
| `workflow_schema.modules[].error_handling_strategy.else_condition.retry_interval` | integer, default 0 | No |  |
| `workflow_schema.edges` | array of object (WorkflowSchemaEdgeModel) | Yes |  |
| `workflow_schema.edges[].source` | object (WorkflowSchemaEdgeHandleModel) | Yes |  |
| `workflow_schema.edges[].source.handle_id` | string \| null | No |  |
| `workflow_schema.edges[].source.workflow_module_instance_id` | string | Yes |  |
| `workflow_schema.edges[].target` | object (WorkflowSchemaEdgeHandleModel) | Yes |  |
| `workflow_schema.edges[].target.handle_id` | string \| null | No |  |
| `workflow_schema.edges[].target.workflow_module_instance_id` | string | Yes |  |
| `workflow_schema.edges[].edge_id` | string | Yes |  |
| `options` | object \| null | No |  |
| `created_by` | integer | Yes |  |
| `created_time` | string | Yes |  |
| `last_modified_by` | integer | Yes |  |
| `last_modified_time` | string | Yes |  |

## Example request

```bash
curl -X PATCH "https://api.stacksync.com/v1/workspaces/{workspace_id}/workflows/{workflow_id}/options?region=besg" \
  -H "Authorization: Bearer $STACKSYNC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "version": "<version>",
  "options": {}
}'
```

## Example response (200)

```json
{
  "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>"
}
```

## Errors

| Status | Meaning | Body |
| --- | --- | --- |
| 400 | Bad Request | `{ "error": string, "msg": string, "field": string \| null }` |
| 403 | Forbidden | `{ "error": string, "msg": string, "field": string \| null }` |
| 404 | Not Found | `{ "error": string, "msg": string, "field": string \| null }` |
| 409 | Conflict | `{ "error": string, "msg": string, "field": string \| null }` |

## 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](https://docs.stacksync.com/api-reference/workflows/get_workflow)
- [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)
- [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)