Create Dynamic Workflow

Updated at:

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 characters

description string (Optional)

Workflow description

script string (Required)

Complete JavaScript. The first statement is a static export const meta; the body reads args and returns a JSON object

input_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 string

Workflow ID in the format wf_&lt;ULID&gt;

type string

Fixed to dynamic_workflow

name / description string

Name and description

status / archived string / bool

status is fixed to published; archived indicates whether the workflow is archived

version int

Published version number. It is 1 after creation

script / input_schema string / object

Complete script and input schema

created_at / updated_at string

Creation and last modification time, ISO 8601

request_id string

Unique 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"
}