Create workflow¶
Create a workflow definition in the current workspace. Creating a workflow does not start a job automatically.
POST https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-deployments
Preparation before calling¶
Prepare a personal access token with permission to create workflows, a target workspace ID, and workflow DSL.
Request body¶
Replace $AI_STUDIO_API_KEY, $WORKSPACE_ID, and the workflow name and DSL in the examples with actual values.
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-deployments" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "daily-import",
"dsl_yaml": "workflow:\\n name: daily-import\\n root: main\\nroot:\\n chain: []\\n",
"execution_mode": "one_shot"
}'
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-deployments" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "order-query-service",
"dsl_yaml": "workflow:\\n name: order-query-service\\n root: main\\nroot:\\n chain: []\\n",
"execution_mode": "dynamic_service",
"dynamic_service": {
"service_name": "order-query-service"
}
}'
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-deployments" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "daily-import",
"dsl_yaml": "workflow:\\n name: daily-import\\n root: main\\nroot:\\n chain: []\\n",
"execution_mode": "cron",
"cron_expression": "0 2 * * *"
}'
curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-deployments" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"name": "volume-import",
"dsl_yaml": "workflow:\\n name: volume-import\\n root: main\\nroot:\\n chain: []\\n",
"execution_mode": "volume_trigger",
"volume_trigger": {
"volume_id": 1001,
"enabled": true
}
}'
Creating a workflow requires name and dsl_yaml. When source_type is omitted, the workflow uses manual DSL (manual_dsl). Do not send workflow_id or runtime_context when creating a workflow; use Update workflow to modify an existing workflow.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Workflow name. |
|
string |
No |
Workflow description. |
|
string |
Yes |
YAML text of the workflow DSL. |
|
string |
No |
Execution mode. Defaults to |
|
string |
No |
Workflow source type. Defaults to |
|
object |
No |
Runtime input form configuration. |
|
object |
No |
Runtime input form layout configuration. |
|
object |
No |
Default values for the runtime input form. |
|
object |
No |
Workflow design-graph configuration. |
|
string |
No |
Associated compute resource ID. |
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Workflow name. |
|
string |
Yes |
YAML text of the workflow DSL. |
|
string |
Yes |
Set to |
|
object |
Yes |
Dynamic-service configuration. |
|
string |
No |
Dynamic service name. |
|
string |
No |
Schema for dynamic-service input. |
|
string |
No |
Schema for dynamic-service output. |
|
string |
No |
Result mode for the dynamic service. |
|
string |
No |
JSON text of runtime configuration for the dynamic service. |
For other optional fields, see the One-time run tab.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Workflow name. |
|
string |
Yes |
YAML text of the workflow DSL. |
|
string |
Yes |
Set to |
|
string |
Yes |
Cron expression. |
For other optional fields, see the One-time run tab.
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Workflow name. |
|
string |
Yes |
YAML text of the workflow DSL. |
|
string |
Yes |
Set to |
|
object |
No |
Volume-trigger configuration. |
|
integer |
Conditional |
Required when the runtime input form does not provide a volume ID. |
|
boolean |
No |
Whether to enable the volume trigger. |
|
boolean |
No |
Whether to automatically dispatch volume-triggered runs. |
|
string |
No |
JSON text of variables used by the volume trigger. |
|
integer |
No |
Maximum concurrency for volume-triggered runs. |
For other optional fields, see the One-time run tab.
Successful response¶
Returns 200 on success. The service saves the workflow definition but does not start a job automatically. Save data.workflow.id for viewing, updating, or starting the workflow.
{
"code": "OK",
"msg": "OK",
"data": {
"workflow": {
"id": "wf-001",
"name": "daily-import",
"source_type": "manual_dsl",
"execution_mode": "one_shot",
"draft_id": "draft-001",
"status": "ready"
},
"deployment": {
"workflow_app_id": "wf-001",
"workflow_def_id": "def-001",
"workflow_version_id": "ver-001",
"workflow_name": "daily-import",
"version": 1,
"execution_mode": "one_shot"
}
}
}
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
object |
Response data. |
data.workflow is the summary of the created workflow.
Field |
Type |
Description |
|---|---|---|
|
string |
Workflow ID. |
|
string |
Workflow name. |
|
string |
Workflow source type. |
|
string |
Saved execution mode. |
|
string |
Workflow draft ID. |
|
string |
Current workflow status. |
data.deployment contains the published workflow version and execution-mode resource.
Field |
Type |
Description |
|---|---|---|
|
string |
Workflow application ID. |
|
string |
Workflow definition ID. |
|
string |
Workflow version ID. |
|
string |
Workflow name. |
|
integer |
Workflow version number. |
|
string |
Published execution mode. |
Field |
Type |
Returned when |
|---|---|---|
|
string |
The workflow is scheduled. |
|
string |
A candidate version exists. |
|
string |
Updating an existing workflow version. |
|
array of string |
Replacing a scheduled task. |
|
object |
The workflow uses a volume trigger. |
|
object |
The workflow is scheduled. |
|
object |
The workflow uses a dynamic service. |
|
array of string |
Deployment produces warnings. |
Error response¶
{
"code": "ErrParamInvalid",
"msg": "Request parameters are invalid",
"data": null
}
Field |
Type |
Description |
|---|---|---|
|
string |
Error code. |
|
string |
Error description. |
|
null |
Empty on error. |
Follow-up operations¶
Save data.workflow.id. To verify the created workflow, View workflow details; to run it immediately, Start workflow job.