Draft Workflow
draft_workflowCreate and persist PDF processing workflows. Author agent scripts for custom extraction, A/B tests, and human review, or choose a staff catalog template. Optionally run immediately.
Instructions
Author, create, build, or draft a workflow. For custom/agentic work, pass code as a high-level agent workflow script using agent() / parallel() / pipeline() / phase(). Minimal working code: phase("Extract"); const result = await agent("Extract the invoice total.", { label:"extract", schema:{ type:"object", required:["total"], properties:{ total:{ type:"string" } } } }); return { result };. Each agent call must include a task prompt and a JSON Schema under the schema key, e.g. agent("task", { label:"extract", schema:{ type:"object", required:["rows"], properties:{ rows:{ type:"array" } } } }) or agent({ prompt:"task", label:"extract", schema:{...} }). Plain JS acts as the deterministic controller. This is the path for provider A/B tests, N-provider parser fan-out, judge/compare barriers, and human review via an explicit detect/apply phase split. definition and catalog_workflow_id are only for finite catalog pipelines. Returns workflow_id, readiness, blueprint, and AST when available. Persisted to your account — same as POST /v1/workflows.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| run | No | Start a run immediately after creating when the selected runtime is configured. | |
| code | No | High-level agent workflow script. Author in the agent()/parallel()/pipeline()/phase() grammar. Minimal working script: phase("Extract"); const result = await agent("Extract the invoice total.", { label: "extract", schema: { type: "object", required: ["total"], properties: { total: { type: "string" } } } }); return { result }; Every agent step MUST include a `schema` JSON Schema contract: agent("task prompt", { label: "extract", schema: { type: "object", required: ["rows"], properties: { rows: { type: "array" } } } }) or agent({ prompt: "task prompt", label: "extract", schema: {...} }). The contract key is `schema`; do not use returns/output_schema/json_schema. Barriers are explicit with parallel(() => agent(...)) thunks; pipeline(items, mapper) is sequential by default and can fan out over runtime data with { concurrency }. phase() names the user-visible stage, and human review is modeled as a detect/apply phase split. Use this for provider A/B tests, N-provider parser fan-out, judge/compare barriers, redaction/extraction review, and other custom agent work. The script is captured as the workflow source artifact and runs through the hosted JS controller harness when the runtime bindings are configured. | |
| name | No | Human-readable workflow name. | |
| inputs | No | Run inputs, e.g. { files: ["doc-…"] } for invoice extraction or { document_id: "doc_…" } for an agent workflow. Setting this implies run:true. | |
| definition | No | Finite catalog pipeline only: { steps: [{ type, id?, name?, with?, needs? }] } using GET /v1/steps types. Use this for staff/catalog pipelines, not custom agent work. | |
| catalog_workflow_id | No | Instantiate a staff template as your own workflow (e.g. staff.invoice-extraction, staff.table-ingest). |