# Update workflow

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Changes an existing workflow definition or configuration. A successful request saves the change. Changes to the definition or runtime configuration redeploy the definition but do not start a job.

```text
PATCH https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/{workflow_id}
```

## Before you call

Use [Get workflow details](get-workflow.md#path-parameters) to select the workflow. Prepare a [personal access token](../../../../../guides/genesis/api-keys.md#create-and-manage-personal-access-tokens) with workflow update permission and the [target workspace ID](../../../../../guides/ai-studio/resource-center/workspace.md#copy-the-workspace-id).

## Path parameters

Replace `$AI_STUDIO_API_KEY`, `$WORKSPACE_ID`, and `$WORKFLOW_ID` with your own values.

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Call example

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"description": "Synchronizes daily sales data"}'
```

:::::
:::::{tab-item} Parameter reference

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `workflow_id` | string | Yes | Workflow ID to update. |

:::::
::::::
:::::::

## Request body

All fields are optional, but send at least one updatable field. Do not send `runtime_context`. Replace workflow names, DSL, resource IDs, and trigger settings with your own values.

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Input examples

::::{tab-set}
:::{tab-item} Basic settings

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"name": "daily-import-v2", "compute_resource_id": "compute-001"}'
```

:::
:::{tab-item} Scheduled trigger

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"execution_mode": "cron", "cron_expression": "0 2 * * *"}'
```

:::
:::{tab-item} Volume trigger

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"execution_mode": "volume_trigger", "volume_trigger": {"volume_id": 1001, "enabled": true}}'
```

:::
:::{tab-item} Dynamic service

```bash
curl -X PATCH "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{"execution_mode": "dynamic_service", "dynamic_service": {"service_name": "order-query-service"}}'
```

:::
::::

:::::
:::::{tab-item} Parameter reference

::::{tab-set}
:class: mo-api-parameter-table

:::{tab-item} Basic settings

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | No | Workflow name; cannot be empty when sent. |
| `description` | string | No | Workflow description. |
| `dsl_yaml` | string | No | Workflow DSL YAML; cannot be empty when sent. |
| `runtime_fields` | object | No | Runtime input form configuration. |
| `runtime_layout` | object | No | Runtime input form layout. |
| `default_values` | object | No | Runtime input default values. |
| `design_graph` | object | No | Workflow design graph configuration. |
| `compute_resource_id` | string | No | Associated compute resource ID. |
| `status` | string | No | Workflow status: `ready` or `disabled`. |
| `session_id` | string | No | Workflow session ID. |

:::
:::{tab-item} Scheduled trigger

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `execution_mode` | string | No | Use `cron` for a scheduled trigger. |
| `cron_expression` | string | Conditional | Required when `execution_mode` is `cron`. |

:::
:::{tab-item} Volume trigger

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `execution_mode` | string | No | Use `volume_trigger` for a volume trigger. |
| `volume_trigger` | object | No | Volume trigger configuration. |
| `volume_trigger.volume_id` | integer | Conditional | Required unless the runtime form supplies a volume ID. |
| `volume_trigger.enabled` | boolean | No | Enables the volume trigger. |
| `volume_trigger.auto_dispatch_enabled` | boolean | No | Automatically dispatches volume-triggered runs. |
| `volume_trigger.vars_json` | string | No | JSON text of variables for the trigger. |
| `volume_trigger.max_concurrency` | integer | No | Maximum concurrent volume-triggered runs. |

:::
:::{tab-item} Dynamic service

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `execution_mode` | string | No | Use `dynamic_service` for a dynamic service. |
| `dynamic_service` | object | No | Dynamic service configuration. |
| `dynamic_service.service_name` | string | No | Dynamic service name. |
| `dynamic_service.input_schema` | string | No | Input schema. |
| `dynamic_service.output_schema` | string | No | Output schema. |
| `dynamic_service.result_mode` | string | No | Result mode. |
| `dynamic_service.runtime_spec_json` | string | No | Runtime configuration JSON text. |

:::
::::

:::::
::::::
:::::::

## Successful response

Returns 200 and the updated workflow detail. The response follows the same field grouping as [Get workflow details](get-workflow.md#successful-response).

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "workflow": {
      "id": "wf-001",
      "name": "daily-import-v2",
      "status": "ready",
      "execution_mode": "cron",
      "cron_expression": "0 2 * * *",
      "latest_workflow_version_id": "ver-002",
      "latest_version": 4,
      "updated_at": "2026-08-18T11:00:00Z"
    }
  }
}
```

:::::
:::::{tab-item} Field reference

`data.workflow` is the updated workflow detail.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.workflow` | object | Updated workflow detail. |
| `id` | string | Workflow ID. |
| `name` | string | Workflow name. |
| `status` | string | Current workflow status. |
| `execution_mode` | string | Configured execution mode. |
| `cron_expression` | string | Cron expression for scheduled workflows. |
| `latest_workflow_version_id` | string | Latest workflow version ID, when provided. |
| `latest_version` | integer | Latest workflow version number, when provided. |
| `updated_at` | string | Last update time, when provided. |

For all definition, input, execution, trigger, and compute-resource fields, see [Get workflow details](get-workflow.md#successful-response).

:::::
::::::
:::::::

## Error response

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{"code": "ErrParamInvalid", "msg": "Invalid request parameter", "data": null}
```

:::::
:::::{tab-item} Field reference

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code. |
| `msg` | string | Error message. |
| `data` | null | Empty on error. |

:::::
::::::
:::::::

## Next steps

Use [Get workflow details](get-workflow.md#path-parameters) to verify the saved definition or [Start a workflow job](../workflow-jobs/start-workflow-job.md#path-parameters) to run it.
