# Update workflow

> Rename a workflow, switch it on (running) or off (paused) with its schedules and sync triggers, or share it with the workspace.

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

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

- Operation: `update_workflow`
- 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 |
| --- | --- | --- | --- |
| `workflow_name` | string \| null, 1 to 200 characters | No |  |
| `workflow_status` | string (running \| paused \| deleted) \| null | No | running switches the workflow on, paused off |
| `is_shared_with_workspace` | boolean \| null | No |  |
| `validate_only` | boolean, default false | No | Run every check of the write and answer 204 without writing: a refused write answers the error the write would |

## Returns

### 200 OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow_id` | string | Yes |  |
| `workflow_name` | string | Yes |  |
| `workflow_resource_id` | string | Yes |  |
| `workflow_status` | string (running \| paused \| deleted) | Yes |  |
| `workspace_id` | integer | Yes |  |
| `is_shared_with_workspace` | boolean | Yes |  |
| `module_app_type_display_list` | array of string \| null | No |  |
| `parent_folders` | array of object (ParentFolderModel) \| null | No |  |
| `parent_folders[].parent_folder_id` | string (uuid4) | Yes |  |
| `parent_folders[].type` | string (primary \| shortcut) | Yes |  |
| `created_by` | integer | Yes |  |
| `created_time` | string | Yes |  |
| `last_modified_by` | integer | Yes |  |
| `last_modified_time` | string | Yes |  |
| `region` | string (besg \| usnv) | Yes |  |

### 204 No Content

No body.

## Example request

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

## Example response (200)

```json
{
  "workflow_id": "<workflow_id>",
  "workflow_name": "<workflow_name>",
  "workflow_resource_id": "<workflow_resource_id>",
  "workflow_status": "running",
  "workspace_id": 0,
  "is_shared_with_workspace": false,
  "module_app_type_display_list": [
    "<module_app_type_display_list>"
  ],
  "parent_folders": [
    {
      "parent_folder_id": "3f6c1d2e-8a4b-4c7d-9e21-5b6f7a8c9d01",
      "type": "primary"
    }
  ],
  "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, "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 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)