All Products
Search
Document Center

DataWorks:ImportWorkflowDefinition

Last Updated:Jan 12, 2026

Imports a workflow and its child nodes that are specified by the FlowSpec field to DataStudio.

Operation description

Note
  • You cannot use this API operation to import multiple workflows at a time. If you specify multiple workflows by using FlowSpec, the system imports only the first specified workflow.

  • ImportWorkflowDefinition is an asynchronous operation. After you send a request, an asynchronous task is generated, and the system returns the ID of the asynchronous task. You can call the GetJobStatus operation to query the status of the asynchronous task.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • For mandatory resource types, indicate with a prefix of * .
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
dataworks:*update
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
ProjectIdstringYes

The DataWorks workspace ID. You can log on to the DataWorks console and go to the Workspace page to query the ID.

You must configure this parameter to specify the DataWorks workspace to which the API operation is applied.

123456
SpecstringYes

The FlowSpec information for this workflow. For more information, see FlowSpec .

Note How to quickly obtain a FlowSpec template?
  • Open a workflow in Data Studio, then click "Show Spec" in the top-right corner to retrieve the FlowSpec description for the current workflow. You can use this FlowSpec description to quickly build a template that meets your requirements.
Note This interface supports creating both the workflow and its internal nodes simultaneously. Therefore, please pay close attention to the ID specified in the FlowSpec. If the provided ID already exists, the operation will be treated as an update. A create operation is performed only if the ID is omitted or does not exist.
{ "version": "1.1.0", "kind": "CycleWorkflow", "spec": { "name": "Asynchronous_Workflow_Creation_Test", "id": "632647691239009XXXX", "type": "CycleWorkflow", "workflows": [ { "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test", "runtime": { "command": "WORKFLOW" } }, "id": "632647691239009XXXX", "trigger": { "type": "Scheduler", "cron": "00 03 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "strategy": { "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "failureStrategy": "Break" }, "name": "Asynchronous_Workflow_Creation_Test", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "632647691239009XXXX", "artifactType": "NodeOutput", "refTableName": "Asynchronous_Workflow_Creation_Test" } ] }, "nodes": [ { "recurrence": "Normal", "id": "742981001612325XXXX", "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test/111", "runtime": { "command": "ODPS_SQL" }, "content": "select now();\n" }, "trigger": { "type": "Scheduler", "cron": "00 24 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "name": "111", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "742981001612325XXXX", "artifactType": "NodeOutput", "refTableName": "111" } ] } }, { "recurrence": "Normal", "id": "595182137303408XXXX", "timeout": 0, "instanceMode": "T+1", "rerunMode": "Allowed", "rerunTimes": 3, "rerunInterval": 180000, "script": { "path": "XX/OpenAPI_Test/Workflow_Test/Asynchronous_Workflow_Creation_Test/222", "runtime": { "command": "ODPS_SQL" }, "content": "select now();\n select 1;" }, "trigger": { "type": "Scheduler", "cron": "00 00 00 * * ?", "startTime": "1970-01-01 00:00:00", "endTime": "9999-01-01 00:00:00", "timezone": "Asia/Shanghai", "delaySeconds": 0 }, "name": "222", "inputs": {}, "outputs": { "nodeOutputs": [ { "data": "595182137303408XXXX", "artifactType": "NodeOutput", "refTableName": "222" } ] } } ], "dependencies": [ { "nodeId": "595182137303408XXXX", "depends": [ { "type": "Normal", "output": "742981001612325XXXX", "refTableName": "111" } ] } ] } ] } }

Response parameters

ParameterTypeDescriptionExample
object

Schema of Response

RequestIdstring

The request ID.

7C352CB7-CD88-50CF-9D0D-E81BDF020E7F
AsyncJobobject

The status information of the asynchronous task.

Completedboolean

Indicates whether the asynchronous task is complete.

false
CreateTimelong

The time when the asynchronous task was created. This value is a UNIX timestamp.

1706581425000
Errorstring

The error message returned if the asynchronous task fails.

target folder already exists: XXXX
Idstring

The ID of the asynchronous task.

1234567691239009XXXX
Progressinteger

The progress of the asynchronous task. Valid values: 0 to 100.

0
Responsestring

The response.

Note The workflow ID is returned.
632647691239009XXXX
Statusstring

The status of the asynchronous task.

Valid values:

  • Running: The asynchronous task is running.
  • Success: The asynchronous task is complete.
  • Fail: The asynchronous task fails.
  • Cancel: The asynchronous task is canceled.
Running
Typestring

The type of the asynchronous task.

Valid values:

  • Create: The asynchronous task is used to create an object.
  • Cancel: The asynchronous task is used to cancel an operation.
Create

Examples

Sample success responses

JSONformat

{
  "RequestId": "7C352CB7-CD88-50CF-9D0D-E81BDF020E7F",
  "AsyncJob": {
    "Completed": false,
    "CreateTime": 1706581425000,
    "Error": "target folder already exists: XXXX",
    "Id": "1234567691239009XXXX",
    "Progress": 0,
    "Response": "632647691239009XXXX",
    "Status": "Running",
    "Type": "Create"
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2025-01-13The internal configuration of the API is changed, but the call is not affectedView Change Details