Skip to main content

Create Dynamic Workflow

Create a dynamic workflow and publish version 1. The request body contains the name, description, JavaScript, and optional input schema.

Prerequisites

Complete the endpoint and authentication configuration. See API Overview and Authentication.

Endpoint

POST /dynamic_workflows

Request body

name string (Required)Workflow name. Non-empty, up to 128 charactersdescription string (Optional)Workflow descriptionscript string (Required)Complete JavaScript. The first statement is a static export const meta; the body reads args and returns a JSON objectinput_schema object / null (Optional)Input constraint that describes the workflow args object. Omitting it, null, or {} all save as {}. If the root type is declared, it must be object. The service does not convert parameter types or fill in default values

Request example

curl -X POST "$AGENTSTUDIO_URL/dynamic_workflows" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<'EOF'
{
  "name": "sum-workflow",
  "description": "Adds two integers",
  "script": "export const meta = { name: 'sum-workflow' }\n\nreturn { sum: Number(args.a) + Number(args.b) }"
}
EOF
Returns 200 with the complete resource and version=1. A successful create is already published. The server generates the id; do not send a resource ID in the request body.

Response fields

id stringWorkflow ID in the format wf_&lt;ULID&gt;type stringFixed to dynamic_workflowname / description stringName and descriptionstatus / archived string / boolstatus is fixed to published; archived indicates whether the workflow is archivedversion intPublished version number. It is 1 after creationscript / input_schema string / objectComplete script and input schemacreated_at / updated_at stringCreation and last modification time, ISO 8601request_id stringUnique request identifier

Response example

{
  "id": "wf_01M7RMD9PRNVEPY2QKW1MA36TE",
  "type": "dynamic_workflow",
  "name": "sum-workflow",
  "description": "Adds two integers",
  "status": "published",
  "archived": false,
  "version": 1,
  "script": "export const meta = { name: 'sum-workflow' }\n\nreturn { sum: Number(args.a) + Number(args.b) }",
  "input_schema": {},
  "created_at": "2026-11-19T01:00:00Z",
  "updated_at": "2026-11-19T01:00:00Z",
  "request_id": "req_example"
}