Start workflow job

Initiates an execution for the specified workflow. After the request is successful, save the returned execution ID, and then query the status and results of the job; a successful request does not mean that the workflow has been completed.

POST https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/{workflow_id}/executions

Preparation before calling

First View workflow details to confirm the runtime fields and execution configuration of the workflow. Prepare a personal access token and target workspace ID that has access to the target workspace.

The request body cannot contain runtime_context.

Request body

workflow_idstringRequired
The ID of the workflow to run.
valuesobject
Input value keyed by runtime form `field_id`. The server will merge it with the workflow default values ​​and verify the required fields.
trigger_nowboolean
Whether to trigger execution immediately.
run_onceboolean
When the Cron workflow is set to `true`, this run will be processed as a one-time execution.
execution_modestring
Passing in is not supported; passing in a non-null value will return a parameter error. The execution mode is determined by the published workflow.
compute_resource_idstring
The computing resource ID used for this run.

Request example

curl -X POST "https://moi.matrixorigin.cn/newmoi/workflow/v2/workflow-apps/$WORKFLOW_ID/executions" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "values": {
      "<FIELD_ID>": "<VALUE>"
    },
    "trigger_now": true
  }'

Successful response

Returns 200 on success. Acceptance of the request does not mean that the execution is completed; save the data.workflow_run.execution_id and use it to query job details and results.

codestring
`OK` when successful.
msgstring
`OK` when successful.
data.workflow_run.execution_idstring
The execution ID of the new job.
data.workflow_run.workflow_idstring
Workflow ID.
data.workflow_run.statusstring
Current execution status when created; query should continue to confirm the final status.
data.workflow_run.available_actionsstring[]
Follow-up actions allowed by the current state.
data.workflow_run.execution_modestring
The mode used for this execution.
data.workflow_run.moi_task_idstring
Task ID returned when assigned by the server.
data.workflow_run.moi_case_idstring
Case ID returned when assigned by the server.
data.workflow_run.moi_workflow_def_idstring
Workflow definition ID associated with this execution.
data.workflow_run.moi_workflow_version_idstring
Workflow version ID associated with this execution.
data.workflow_run.errorstring
Current error; returned if there is a value.

Successful response example

{
  "code": "OK",
  "msg": "OK",
  "data": {
    "workflow_run": {
      "execution_id": "exec-001",
      "workflow_id": "wf-001",
      "status": "ready",
      "available_actions": ["cancel"],
      "execution_mode": "one_shot",
      "moi_task_id": "task-001",
      "moi_case_id": "case-001",
      "moi_workflow_def_id": "def-001",
      "moi_workflow_version_id": "ver-001"
    }
  }
}

Error response

codestring
Error code.
msgstring
Readable error message.
datanull
`null` in an error response.

Error response example

{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}

Follow-up operations

Record data.workflow_run.workflow_id and data.workflow_run.execution_id. Acceptance of a request does not mean completion of execution. Use these two identifiers to query workflow job details to track the status; when output is needed, query workflow job results.

Last updated on