# Workflows ## List all Workflows `client.workflows.list(WorkflowListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/workflows` Lists all workflows configured for the account. ### Parameters - `params: WorkflowListParams` - `account_id: string` Path param - `page?: number` Query param - `per_page?: number` Query param - `search?: string` Query param: Allows filtering workflows` name. ### Returns - `WorkflowListResponse` - `id: string` - `class_name: string` - `created_on: string` - `instances: Instances` - `complete?: number` - `errored?: number` - `paused?: number` - `queued?: number` - `rollingBack?: number` - `running?: number` - `terminated?: number` - `waiting?: number` - `waitingForPause?: number` - `modified_on: string` - `name: string` - `script_name: string` - `triggered_on: string | null` - `schedules?: Array` - `cron: string` - `next_instance: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const workflowListResponse of client.workflows.list({ account_id: 'account_id' })) { console.log(workflowListResponse.id); } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "instances": { "complete": 0, "errored": 0, "paused": 0, "queued": 0, "rollingBack": 0, "running": 0, "terminated": 0, "waiting": 0, "waitingForPause": 0 }, "modified_on": "2019-12-27T18:11:19.117Z", "name": "x", "script_name": "script_name", "triggered_on": "2019-12-27T18:11:19.117Z", "schedules": [ { "cron": "cron", "next_instance": "next_instance" } ] } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Get Workflow details `client.workflows.get(stringworkflowName, WorkflowGetParamsparams, RequestOptionsoptions?): WorkflowGetResponse` **get** `/accounts/{account_id}/workflows/{workflow_name}` Retrieves configuration and metadata for a specific workflow. ### Parameters - `workflowName: string` - `params: WorkflowGetParams` - `account_id: string` ### Returns - `WorkflowGetResponse` - `id: string` - `class_name: string` - `created_on: string` - `instances: Instances` - `complete?: number` - `errored?: number` - `paused?: number` - `queued?: number` - `rollingBack?: number` - `running?: number` - `terminated?: number` - `waiting?: number` - `waitingForPause?: number` - `modified_on: string` - `name: string` - `script_name: string` - `triggered_on: string | null` - `schedules?: Array` - `cron: string` - `next_instance: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const workflow = await client.workflows.get('x', { account_id: 'account_id' }); console.log(workflow.id); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "instances": { "complete": 0, "errored": 0, "paused": 0, "queued": 0, "rollingBack": 0, "running": 0, "terminated": 0, "waiting": 0, "waitingForPause": 0 }, "modified_on": "2019-12-27T18:11:19.117Z", "name": "x", "script_name": "script_name", "triggered_on": "2019-12-27T18:11:19.117Z", "schedules": [ { "cron": "cron", "next_instance": "next_instance" } ] }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Create/modify Workflow `client.workflows.update(stringworkflowName, WorkflowUpdateParamsparams, RequestOptionsoptions?): WorkflowUpdateResponse` **put** `/accounts/{account_id}/workflows/{workflow_name}` Creates a new workflow or updates an existing workflow definition. ### Parameters - `workflowName: string` - `params: WorkflowUpdateParams` - `account_id: string` Path param - `class_name: string` Body param - `script_name: string` Body param - `limits?: Limits` Body param - `steps?: number` - `schedules?: Array` Body param - `cron: string` ### Returns - `WorkflowUpdateResponse` - `id: string` - `class_name: string` - `created_on: string` - `is_deleted: number` - `modified_on: string` - `name: string` - `script_name: string` - `terminator_running: number` - `triggered_on: string | null` - `version_id: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const workflow = await client.workflows.update('x', { account_id: 'account_id', class_name: 'x', script_name: 'x', }); console.log(workflow.id); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "is_deleted": 0, "modified_on": "2019-12-27T18:11:19.117Z", "name": "x", "script_name": "script_name", "terminator_running": 0, "triggered_on": "2019-12-27T18:11:19.117Z", "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Deletes a Workflow `client.workflows.delete(stringworkflowName, WorkflowDeleteParamsparams, RequestOptionsoptions?): WorkflowDeleteResponse` **delete** `/accounts/{account_id}/workflows/{workflow_name}` Deletes a Workflow. This only deletes the Workflow and does not delete or modify any Worker associated to this Workflow or bounded to it. ### Parameters - `workflowName: string` - `params: WorkflowDeleteParams` - `account_id: string` ### Returns - `WorkflowDeleteResponse` - `status: "ok"` - `"ok"` - `success: boolean | null` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const workflow = await client.workflows.delete('x', { account_id: 'account_id' }); console.log(workflow.status); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "status": "ok", "success": true }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Domain Types ### Workflow List Response - `WorkflowListResponse` - `id: string` - `class_name: string` - `created_on: string` - `instances: Instances` - `complete?: number` - `errored?: number` - `paused?: number` - `queued?: number` - `rollingBack?: number` - `running?: number` - `terminated?: number` - `waiting?: number` - `waitingForPause?: number` - `modified_on: string` - `name: string` - `script_name: string` - `triggered_on: string | null` - `schedules?: Array` - `cron: string` - `next_instance: string` ### Workflow Get Response - `WorkflowGetResponse` - `id: string` - `class_name: string` - `created_on: string` - `instances: Instances` - `complete?: number` - `errored?: number` - `paused?: number` - `queued?: number` - `rollingBack?: number` - `running?: number` - `terminated?: number` - `waiting?: number` - `waitingForPause?: number` - `modified_on: string` - `name: string` - `script_name: string` - `triggered_on: string | null` - `schedules?: Array` - `cron: string` - `next_instance: string` ### Workflow Update Response - `WorkflowUpdateResponse` - `id: string` - `class_name: string` - `created_on: string` - `is_deleted: number` - `modified_on: string` - `name: string` - `script_name: string` - `terminator_running: number` - `triggered_on: string | null` - `version_id: string` ### Workflow Delete Response - `WorkflowDeleteResponse` - `status: "ok"` - `"ok"` - `success: boolean | null` # Instances ## List of workflow instances `client.workflows.instances.list(stringworkflowName, InstanceListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/workflows/{workflow_name}/instances` Lists all instances of a workflow with their execution status. ### Parameters - `workflowName: string` - `params: InstanceListParams` - `account_id: string` Path param - `cursor?: string` Query param: Opaque token for cursor-based pagination. Mutually exclusive with `page`. - `date_end?: string` Query param: Accepts ISO 8601 with no timezone offsets and in UTC. - `date_start?: string` Query param: Accepts ISO 8601 with no timezone offsets and in UTC. - `direction?: "asc" | "desc"` Query param: Defines the direction for cursor-based pagination. - `"asc"` - `"desc"` - `page?: number` Query param: Deprecated: use `cursor` for pagination instead. - `per_page?: number` Query param - `status?: "queued" | "running" | "paused" | 6 more` Query param - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` ### Returns - `InstanceListResponse` - `id: string` - `created_on: string` - `ended_on: string | null` - `modified_on: string` - `started_on: string | null` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const instanceListResponse of client.workflows.instances.list('x', { account_id: 'account_id', })) { console.log(instanceListResponse.id); } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": [ { "id": "x", "created_on": "2019-12-27T18:11:19.117Z", "ended_on": "2019-12-27T18:11:19.117Z", "modified_on": "2019-12-27T18:11:19.117Z", "started_on": "2019-12-27T18:11:19.117Z", "status": "queued", "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "trigger_source": "unknown" } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Get logs and status from instance `client.workflows.instances.get(stringinstanceID, InstanceGetParamsparams, RequestOptionsoptions?): InstanceGetResponse` **get** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}` Retrieves logs and execution status for a specific workflow instance. ### Parameters - `instanceID: string` Instance identifier. User-created instances match `^[a-zA-Z0-9_][a-zA-Z0-9-_]*$` (max 100 characters); cron-triggered instances can use a longer, system-generated id derived from the cron expression. - `params: InstanceGetParams` - `account_id: string` Path param - `workflow_name: string` Path param - `order?: "asc" | "desc"` Query param: Step ordering: "asc" (default, oldest first) or "desc" (newest first). - `"asc"` - `"desc"` - `simple?: "true" | "false"` Query param: When true, omits step details and returns only metadata with step_count. - `"true"` - `"false"` ### Returns - `InstanceGetResponse` - `end: string | null` - `error: Error | null` - `message: string` - `name: string` - `output: string | number` - `string` - `number` - `params: unknown` - `queued: string` - `rollback: Rollback | null` - `error: Error | null` - `message: string` - `name: string` - `outcome: "complete" | "failed"` - `"complete"` - `"failed"` - `start: string | null` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `step_count: number` - `steps: Array` - `UnionMember0` - `attempts: Array` - `end: string | null` - `error: Error | null` - `message: string` - `name: string` - `start: string` - `success: boolean | null` - `config: Config` - `retries: Retries` - `delay: string | number` Specifies the delay duration. '[dynamic]' indicates the delay is computed by a user-supplied function. - `string` - `number` - `limit: number` - `backoff?: "constant" | "linear" | "exponential"` - `"constant"` - `"linear"` - `"exponential"` - `timeout: string | number` Specifies the timeout duration. - `string` - `number` - `sensitive?: "output"` When set to 'output', step output is redacted from log and step output responses. - `"output"` - `end: string | null` - `name: string` - `output: string | null` - `start: string` - `success: boolean | null` - `type: "step" | "rollback"` - `"step"` - `"rollback"` - `UnionMember1` - `end: string` - `error: Error | null` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "sleep"` - `"sleep"` - `UnionMember2` - `trigger: Trigger` - `source: string` - `type: "termination"` - `"termination"` - `UnionMember3` - `end: string` - `error: Error | null` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "waitForEvent"` - `"waitForEvent"` - `output?: string` - `success: boolean | null` - `trigger: Trigger` - `source: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` - `versionId: string` - `schedule?: Schedule` - `cron: string` - `scheduledTime: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.workflows.instances.get('x', { account_id: 'account_id', workflow_name: 'x', }); console.log(instance.end); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "end": "2019-12-27T18:11:19.117Z", "error": { "message": "message", "name": "name" }, "output": "string", "params": {}, "queued": "2019-12-27T18:11:19.117Z", "rollback": { "error": { "message": "message", "name": "name" }, "outcome": "complete" }, "start": "2019-12-27T18:11:19.117Z", "status": "queued", "step_count": 0, "steps": [ { "attempts": [ { "end": "2019-12-27T18:11:19.117Z", "error": { "message": "message", "name": "name" }, "start": "2019-12-27T18:11:19.117Z", "success": true } ], "config": { "retries": { "delay": "string", "limit": 0, "backoff": "constant" }, "timeout": "string", "sensitive": "output" }, "end": "2019-12-27T18:11:19.117Z", "name": "name", "output": "output", "start": "2019-12-27T18:11:19.117Z", "success": true, "type": "step" } ], "success": true, "trigger": { "source": "unknown" }, "versionId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "schedule": { "cron": "cron", "scheduledTime": 0 } }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Create a new workflow instance `client.workflows.instances.create(stringworkflowName, InstanceCreateParamsparams, RequestOptionsoptions?): InstanceCreateResponse` **post** `/accounts/{account_id}/workflows/{workflow_name}/instances` Creates a new instance of a workflow, starting its execution. ### Parameters - `workflowName: string` - `params: InstanceCreateParams` - `account_id: string` Path param - `instance_id?: string` Body param - `instance_retention?: InstanceRetention` Body param - `error_retention?: number | string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` - `string` - `success_retention?: number | string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` - `string` - `params?: unknown` Body param ### Returns - `InstanceCreateResponse` - `id: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const instance = await client.workflows.instances.create('x', { account_id: 'account_id' }); console.log(instance.id); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "x", "status": "queued", "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "trigger_source": "unknown" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Batch create new Workflow instances `client.workflows.instances.bulk(stringworkflowName, InstanceBulkParamsparams, RequestOptionsoptions?): SinglePage` **post** `/accounts/{account_id}/workflows/{workflow_name}/instances/batch` Creates multiple workflow instances in a single batch operation. ### Parameters - `workflowName: string` - `params: InstanceBulkParams` - `account_id: string` Path param - `body?: Array` Body param - `instance_id?: string` - `instance_retention?: InstanceRetention` - `error_retention?: number | string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` - `string` - `success_retention?: number | string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` - `string` - `params?: unknown` ### Returns - `InstanceBulkResponse` - `id: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const instanceBulkResponse of client.workflows.instances.bulk('x', { account_id: 'account_id', })) { console.log(instanceBulkResponse.id); } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": [ { "id": "x", "status": "queued", "version_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "trigger_source": "unknown" } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Get full step output from instance `client.workflows.instances.step(stringinstanceID, InstanceStepParamsparams, RequestOptionsoptions?): InstanceStepResponse` **get** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/step` Retrieves the full, untruncated output for a specific step on a workflow instance. Returns a flat status-shaped JSON body with step `status` ('running' | 'waiting' | 'complete' | 'errored'), `error` (nullable), and `output` (the step value, or null while running/waiting/errored). When the step returned a ReadableStream from step.do, the response is served as 'application/octet-stream' with the raw bytes as the body instead of JSON. A `status='running'` response with non-null `error` indicates the step is currently retrying after a prior attempt failed. ### Parameters - `instanceID: string` Instance identifier. User-created instances match `^[a-zA-Z0-9_][a-zA-Z0-9-_]*$` (max 100 characters); cron-triggered instances can use a longer, system-generated id derived from the cron expression. - `params: InstanceStepParams` - `account_id: string` Path param - `workflow_name: string` Path param - `name: string` Query param: Exact step name from the instance logs response, including the generated counter suffix. - `type: "step" | "waitForEvent"` Query param: Step type to disambiguate step.do and waitForEvent entries that share the same name. - `"step"` - `"waitForEvent"` - `attempt?: number` Query param: Specific attempt number to retrieve output or error for. ### Returns - `InstanceStepResponse` - `error: Error | null` Error details when status='errored'; null otherwise. - `message: string` - `name: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `output?: unknown` Full step output or waitForEvent payload without truncation. Sensitive outputs are returned as '[REDACTED]'. Populated when status='complete'. May be a ReadableStream when the step returned one from step.do; stream outputs are served as application/octet-stream rather than JSON. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.workflows.instances.step('x', { account_id: 'account_id', workflow_name: 'x', name: 'x', type: 'step', }); console.log(response.error); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "error": { "message": "message", "name": "name" }, "status": "queued", "output": {} }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Domain Types ### Instance List Response - `InstanceListResponse` - `id: string` - `created_on: string` - `ended_on: string | null` - `modified_on: string` - `started_on: string | null` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Instance Get Response - `InstanceGetResponse` - `end: string | null` - `error: Error | null` - `message: string` - `name: string` - `output: string | number` - `string` - `number` - `params: unknown` - `queued: string` - `rollback: Rollback | null` - `error: Error | null` - `message: string` - `name: string` - `outcome: "complete" | "failed"` - `"complete"` - `"failed"` - `start: string | null` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `step_count: number` - `steps: Array` - `UnionMember0` - `attempts: Array` - `end: string | null` - `error: Error | null` - `message: string` - `name: string` - `start: string` - `success: boolean | null` - `config: Config` - `retries: Retries` - `delay: string | number` Specifies the delay duration. '[dynamic]' indicates the delay is computed by a user-supplied function. - `string` - `number` - `limit: number` - `backoff?: "constant" | "linear" | "exponential"` - `"constant"` - `"linear"` - `"exponential"` - `timeout: string | number` Specifies the timeout duration. - `string` - `number` - `sensitive?: "output"` When set to 'output', step output is redacted from log and step output responses. - `"output"` - `end: string | null` - `name: string` - `output: string | null` - `start: string` - `success: boolean | null` - `type: "step" | "rollback"` - `"step"` - `"rollback"` - `UnionMember1` - `end: string` - `error: Error | null` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "sleep"` - `"sleep"` - `UnionMember2` - `trigger: Trigger` - `source: string` - `type: "termination"` - `"termination"` - `UnionMember3` - `end: string` - `error: Error | null` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "waitForEvent"` - `"waitForEvent"` - `output?: string` - `success: boolean | null` - `trigger: Trigger` - `source: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` - `versionId: string` - `schedule?: Schedule` - `cron: string` - `scheduledTime: number` ### Instance Create Response - `InstanceCreateResponse` - `id: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Instance Bulk Response - `InstanceBulkResponse` - `id: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `version_id: string` - `workflow_id: string` - `trigger_source?: "unknown" | "api" | "binding" | 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` ### Instance Step Response - `InstanceStepResponse` - `error: Error | null` Error details when status='errored'; null otherwise. - `message: string` - `name: string` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `output?: unknown` Full step output or waitForEvent payload without truncation. Sensitive outputs are returned as '[REDACTED]'. Populated when status='complete'. May be a ReadableStream when the step returned one from step.do; stream outputs are served as application/octet-stream rather than JSON. # Status ## Change status of instance `client.workflows.instances.status.edit(stringinstanceID, StatusEditParamsparams, RequestOptionsoptions?): StatusEditResponse` **patch** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status` Changes the execution status of a workflow instance (e.g., pause, resume, terminate). ### Parameters - `instanceID: string` Instance identifier. User-created instances match `^[a-zA-Z0-9_][a-zA-Z0-9-_]*$` (max 100 characters); cron-triggered instances can use a longer, system-generated id derived from the cron expression. - `StatusEditParams = Variant0 | Variant1 | Variant2 | Variant3` - `StatusEditParamsBase` - `account_id: string` Path param - `workflow_name: string` Path param - `status: "pause"` Body param - `"pause"` - `Variant0 extends StatusEditParamsBase` - `Variant1 extends StatusEditParamsBase` - `Variant2 extends StatusEditParamsBase` - `Variant3 extends StatusEditParamsBase` ### Returns - `StatusEditResponse` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `timestamp: string` Accepts ISO 8601 with no timezone offsets and in UTC. ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.workflows.instances.status.edit('x', { account_id: 'account_id', workflow_name: 'x', status: 'pause', }); console.log(response.status); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "status": "queued", "timestamp": "2019-12-27T18:11:19.117Z" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Domain Types ### Status Edit Response - `StatusEditResponse` - `status: "queued" | "running" | "paused" | 6 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `"rollingBack"` - `timestamp: string` Accepts ISO 8601 with no timezone offsets and in UTC. # Events ## Send event to instance `client.workflows.instances.events.create(stringeventType, EventCreateParamsparams, RequestOptionsoptions?): EventCreateResponse` **post** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/events/{event_type}` Sends an event to a running workflow instance to trigger state transitions. ### Parameters - `eventType: string` - `params: EventCreateParams` - `account_id: string` Path param - `workflow_name: string` Path param - `instance_id: string` Path param: Instance identifier. User-created instances match `^[a-zA-Z0-9_][a-zA-Z0-9-_]*$` (max 100 characters); cron-triggered instances can use a longer, system-generated id derived from the cron expression. - `body?: unknown` Body param ### Returns - `EventCreateResponse = unknown` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const event = await client.workflows.instances.events.create('x', { account_id: 'account_id', workflow_name: 'x', instance_id: 'x', }); console.log(event); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "success": true, "result": {}, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Domain Types ### Event Create Response - `EventCreateResponse = unknown` # Versions ## List deployed Workflow versions `client.workflows.versions.list(stringworkflowName, VersionListParamsparams, RequestOptionsoptions?): V4PagePaginationArray` **get** `/accounts/{account_id}/workflows/{workflow_name}/versions` Lists all deployed versions of a workflow. ### Parameters - `workflowName: string` - `params: VersionListParams` - `account_id: string` Path param - `page?: number` Query param - `per_page?: number` Query param ### Returns - `VersionListResponse` - `id: string` - `class_name: string` - `created_on: string` - `has_dag: boolean` - `language: "javascript" | "python"` The programming language of the workflow implementation - `"javascript"` - `"python"` - `modified_on: string` - `workflow_id: string` - `limits?: Limits` - `steps?: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const versionListResponse of client.workflows.versions.list('x', { account_id: 'account_id', })) { console.log(versionListResponse.id); } ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "has_dag": true, "language": "javascript", "modified_on": "2019-12-27T18:11:19.117Z", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "limits": { "steps": 1 } } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Get Workflow version details `client.workflows.versions.get(stringversionID, VersionGetParamsparams, RequestOptionsoptions?): VersionGetResponse` **get** `/accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}` Retrieves details for a specific deployed workflow version. ### Parameters - `versionID: string` - `params: VersionGetParams` - `account_id: string` - `workflow_name: string` ### Returns - `VersionGetResponse` - `id: string` - `class_name: string` - `created_on: string` - `has_dag: boolean` - `language: "javascript" | "python"` The programming language of the workflow implementation - `"javascript"` - `"python"` - `modified_on: string` - `workflow_id: string` - `limits?: Limits` - `steps?: number` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const version = await client.workflows.versions.get('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id', workflow_name: 'x', }); console.log(version.id); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "has_dag": true, "language": "javascript", "modified_on": "2019-12-27T18:11:19.117Z", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "limits": { "steps": 1 } }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Get Workflow version graph `client.workflows.versions.graph(stringversionID, VersionGraphParamsparams, RequestOptionsoptions?): VersionGraphResponse` **get** `/accounts/{account_id}/workflows/{workflow_name}/versions/{version_id}/graph` Retrieves the graph visualization of a workflow version. ### Parameters - `versionID: string` - `params: VersionGraphParams` - `account_id: string` - `workflow_name: string` ### Returns - `VersionGraphResponse` - `id: string` - `class_name: string` - `created_on: string` - `graph: Graph | null` Versioned workflow graph payload. - `version: number` - `workflow: Workflow` A parsed workflow entrypoint with its step graph. - `class_name: string` - `functions: Record` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `nodes: Array` - `UnionMember0` - `duration: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `name: string` - `type: "step_sleep"` - `"step_sleep"` - `resolves?: number` - `starts?: number` - `UnionMember1` - `config: Config` Configuration for a step (retries and timeout). - `retries: Retries` Retry policy for a step. - `backoff: "constant" | "linear" | "exponential"` Backoff strategy for step retries. - `"constant"` - `"linear"` - `"exponential"` - `delay: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `limit: number` - `timeout: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "step_do"` - `"step_do"` - `resolves?: number` - `starts?: number` - `UnionMember2` - `name: string` - `options: Options | null` Options for a waitForEvent step. - `event_type: string` - `timeout: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `type: "step_wait_for_event"` - `"step_wait_for_event"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `resolves?: number` - `starts?: number` - `UnionMember3` - `name: string` - `timestamp: string` - `type: "step_sleep_until"` - `"step_sleep_until"` - `resolves?: number` - `starts?: number` - `UnionMember4` - `nodes: Array` Child nodes (recursive). - `type: "loop"` - `"loop"` - `UnionMember5` - `kind: "all" | "any" | "all_settled" | "race"` Parallel execution strategy. - `"all"` - `"any"` - `"all_settled"` - `"race"` - `nodes: Array` Child nodes (recursive). - `type: "parallel"` - `"parallel"` - `UnionMember6` - `catch_block: CatchBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `finally_block: FinallyBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `try_block: TryBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `type: "try"` - `"try"` - `UnionMember7` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `UnionMember8` - `branches: Array` - `condition: string | null` - `nodes: Array` Child nodes (recursive). - `type: "if"` - `"if"` - `UnionMember9` - `branches: Array` - `condition: string | null` - `nodes: Array` Child nodes (recursive). - `discriminant: string` - `type: "switch"` - `"switch"` - `UnionMember10` - `class_name: string` - `functions: Record` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `nodes: Array` Child nodes (recursive). - `type: "start"` - `"start"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `UnionMember11` - `name: string` - `type: "function_call"` - `"function_call"` - `resolves?: number` - `starts?: number` - `UnionMember12` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `UnionMember13` - `kind: "break" | "return"` Break or return from a loop. - `"break"` - `"return"` - `type: "break"` - `"break"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `modified_on: string` - `workflow_id: string` ### Example ```typescript import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.workflows.versions.graph('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', { account_id: 'account_id', workflow_name: 'x', }); console.log(response.id); ``` #### Response ```json { "errors": [ { "code": 0, "message": "message" } ], "messages": [ { "code": 0, "message": "message" } ], "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "class_name": "class_name", "created_on": "2019-12-27T18:11:19.117Z", "graph": { "version": 0, "workflow": { "class_name": "class_name", "functions": { "foo": { "name": "name", "nodes": [ {} ], "type": "function_def" } }, "nodes": [ { "duration": 0, "name": "name", "type": "step_sleep", "resolves": 0, "starts": 0 } ], "payload": { "type": "unknown" } } }, "modified_on": "2019-12-27T18:11:19.117Z", "workflow_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0, "total_pages": 0 } } ``` ## Domain Types ### Version List Response - `VersionListResponse` - `id: string` - `class_name: string` - `created_on: string` - `has_dag: boolean` - `language: "javascript" | "python"` The programming language of the workflow implementation - `"javascript"` - `"python"` - `modified_on: string` - `workflow_id: string` - `limits?: Limits` - `steps?: number` ### Version Get Response - `VersionGetResponse` - `id: string` - `class_name: string` - `created_on: string` - `has_dag: boolean` - `language: "javascript" | "python"` The programming language of the workflow implementation - `"javascript"` - `"python"` - `modified_on: string` - `workflow_id: string` - `limits?: Limits` - `steps?: number` ### Version Graph Response - `VersionGraphResponse` - `id: string` - `class_name: string` - `created_on: string` - `graph: Graph | null` Versioned workflow graph payload. - `version: number` - `workflow: Workflow` A parsed workflow entrypoint with its step graph. - `class_name: string` - `functions: Record` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `nodes: Array` - `UnionMember0` - `duration: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `name: string` - `type: "step_sleep"` - `"step_sleep"` - `resolves?: number` - `starts?: number` - `UnionMember1` - `config: Config` Configuration for a step (retries and timeout). - `retries: Retries` Retry policy for a step. - `backoff: "constant" | "linear" | "exponential"` Backoff strategy for step retries. - `"constant"` - `"linear"` - `"exponential"` - `delay: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `limit: number` - `timeout: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "step_do"` - `"step_do"` - `resolves?: number` - `starts?: number` - `UnionMember2` - `name: string` - `options: Options | null` Options for a waitForEvent step. - `event_type: string` - `timeout: number | string` Duration as milliseconds (number) or human-readable string. - `number` - `string` - `type: "step_wait_for_event"` - `"step_wait_for_event"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `resolves?: number` - `starts?: number` - `UnionMember3` - `name: string` - `timestamp: string` - `type: "step_sleep_until"` - `"step_sleep_until"` - `resolves?: number` - `starts?: number` - `UnionMember4` - `nodes: Array` Child nodes (recursive). - `type: "loop"` - `"loop"` - `UnionMember5` - `kind: "all" | "any" | "all_settled" | "race"` Parallel execution strategy. - `"all"` - `"any"` - `"all_settled"` - `"race"` - `nodes: Array` Child nodes (recursive). - `type: "parallel"` - `"parallel"` - `UnionMember6` - `catch_block: CatchBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `finally_block: FinallyBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `try_block: TryBlock | null` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `type: "try"` - `"try"` - `UnionMember7` - `nodes: Array` Child nodes (recursive). - `type: "block"` - `"block"` - `UnionMember8` - `branches: Array` - `condition: string | null` - `nodes: Array` Child nodes (recursive). - `type: "if"` - `"if"` - `UnionMember9` - `branches: Array` - `condition: string | null` - `nodes: Array` Child nodes (recursive). - `discriminant: string` - `type: "switch"` - `"switch"` - `UnionMember10` - `class_name: string` - `functions: Record` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `nodes: Array` Child nodes (recursive). - `type: "start"` - `"start"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `UnionMember11` - `name: string` - `type: "function_call"` - `"function_call"` - `resolves?: number` - `starts?: number` - `UnionMember12` - `name: string` - `nodes: Array` Child nodes (recursive). - `type: "function_def"` - `"function_def"` - `UnionMember13` - `kind: "break" | "return"` Break or return from a loop. - `"break"` - `"return"` - `type: "break"` - `"break"` - `payload?: Type | UnionMember1` Shape descriptor for JSON payloads. - `Type` - `type: "unknown"` - `"unknown"` - `UnionMember1` - `fields: Record` Nested JsonShape fields (recursive structure). - `type: "object"` - `"object"` - `modified_on: string` - `workflow_id: string`