# Instances ## List of workflow instances **get** `/accounts/{account_id}/workflows/{workflow_name}/instances` Lists all instances of a workflow with their execution status. ### Path Parameters - `account_id: string` - `workflow_name: string` ### Query Parameters - `cursor: optional string` `page` and `cursor` are mutually exclusive, use one or the other. - `date_end: optional string` Accepts ISO 8601 with no timezone offsets and in UTC. - `date_start: optional string` Accepts ISO 8601 with no timezone offsets and in UTC. - `direction: optional "asc" or "desc"` should only be used when `cursor` is used, defines a new direction for the cursor - `"asc"` - `"desc"` - `page: optional number` `page` and `cursor` are mutually exclusive, use one or the other. - `per_page: optional number` - `status: optional "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: array of object { id, created_on, ended_on, 5 more }` - `id: string` - `created_on: string` - `ended_on: string` - `modified_on: string` - `started_on: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` - `success: true` - `true` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0 } } ``` ## Get logs and status from instance **get** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}` Retrieves logs and execution status for a specific workflow instance. ### Path Parameters - `account_id: string` - `workflow_name: string` - `instance_id: string` ### Query Parameters - `order: optional "asc" or "desc"` Step ordering: "asc" (default, oldest first) or "desc" (newest first). - `"asc"` - `"desc"` - `simple: optional "true" or "false"` When true, omits step details and returns only metadata with step_count. - `"true"` - `"false"` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { end, error, output, 9 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `output: string or number` - `string` - `number` - `params: unknown` - `queued: string` - `start: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `step_count: number` - `steps: array of object { attempts, config, end, 5 more } or object { end, error, finished, 3 more } or object { trigger, type } or object { end, error, finished, 4 more }` - `object { attempts, config, end, 5 more }` - `attempts: array of object { end, error, start, success }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `start: string` - `success: boolean` - `config: object { retries, timeout }` - `retries: object { delay, limit, backoff }` - `delay: string or number` Specifies the delay duration. - `string` - `number` - `limit: number` - `backoff: optional "constant" or "linear" or "exponential"` - `"constant"` - `"linear"` - `"exponential"` - `timeout: string or number` Specifies the timeout duration. - `string` - `number` - `end: string` - `name: string` - `output: string` - `start: string` - `success: boolean` - `type: "step"` - `"step"` - `object { end, error, finished, 3 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "sleep"` - `"sleep"` - `object { trigger, type }` - `trigger: object { source }` - `source: string` - `type: "termination"` - `"termination"` - `object { end, error, finished, 4 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "waitForEvent"` - `"waitForEvent"` - `output: optional string` - `success: boolean` - `trigger: object { source }` - `source: "unknown" or "api" or "binding" or 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` - `versionId: string` - `success: true` - `true` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances/$INSTANCE_ID \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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", "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" }, "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" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0 } } ``` ## Create a new workflow instance **post** `/accounts/{account_id}/workflows/{workflow_name}/instances` Creates a new instance of a workflow, starting its execution. ### Path Parameters - `account_id: string` - `workflow_name: string` ### Body Parameters - `instance_id: optional string` - `instance_retention: optional object { error_retention, success_retention }` - `error_retention: optional number or string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` Specifies the duration in milliseconds. - `string` - `success_retention: optional number or string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` Specifies the duration in milliseconds. - `string` - `params: optional unknown` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { id, status, version_id, workflow_id }` - `id: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` - `success: true` - `true` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" }, "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0 } } ``` ## Batch create new Workflow instances **post** `/accounts/{account_id}/workflows/{workflow_name}/instances/batch` Creates multiple workflow instances in a single batch operation. ### Path Parameters - `account_id: string` - `workflow_name: string` ### Body Parameters - `body: optional array of object { instance_id, instance_retention, params }` - `instance_id: optional string` - `instance_retention: optional object { error_retention, success_retention }` - `error_retention: optional number or string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` Specifies the duration in milliseconds. - `string` - `success_retention: optional number or string` Specifies the duration in milliseconds or as a string like '5 minutes'. - `number` Specifies the duration in milliseconds. - `string` - `params: optional unknown` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: array of object { id, status, version_id, workflow_id }` - `id: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` - `success: true` - `true` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances/batch \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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" } ], "success": true, "result_info": { "count": 0, "per_page": 0, "total_count": 0, "cursor": "cursor", "page": 0 } } ``` ## Domain Types ### Instance List Response - `InstanceListResponse = object { id, created_on, ended_on, 5 more }` - `id: string` - `created_on: string` - `ended_on: string` - `modified_on: string` - `started_on: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` ### Instance Get Response - `InstanceGetResponse = object { end, error, output, 9 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `output: string or number` - `string` - `number` - `params: unknown` - `queued: string` - `start: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `step_count: number` - `steps: array of object { attempts, config, end, 5 more } or object { end, error, finished, 3 more } or object { trigger, type } or object { end, error, finished, 4 more }` - `object { attempts, config, end, 5 more }` - `attempts: array of object { end, error, start, success }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `start: string` - `success: boolean` - `config: object { retries, timeout }` - `retries: object { delay, limit, backoff }` - `delay: string or number` Specifies the delay duration. - `string` - `number` - `limit: number` - `backoff: optional "constant" or "linear" or "exponential"` - `"constant"` - `"linear"` - `"exponential"` - `timeout: string or number` Specifies the timeout duration. - `string` - `number` - `end: string` - `name: string` - `output: string` - `start: string` - `success: boolean` - `type: "step"` - `"step"` - `object { end, error, finished, 3 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "sleep"` - `"sleep"` - `object { trigger, type }` - `trigger: object { source }` - `source: string` - `type: "termination"` - `"termination"` - `object { end, error, finished, 4 more }` - `end: string` - `error: object { message, name }` - `message: string` - `name: string` - `finished: boolean` - `name: string` - `start: string` - `type: "waitForEvent"` - `"waitForEvent"` - `output: optional string` - `success: boolean` - `trigger: object { source }` - `source: "unknown" or "api" or "binding" or 2 more` - `"unknown"` - `"api"` - `"binding"` - `"event"` - `"cron"` - `versionId: string` ### Instance Create Response - `InstanceCreateResponse = object { id, status, version_id, workflow_id }` - `id: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` ### Instance Bulk Response - `InstanceBulkResponse = object { id, status, version_id, workflow_id }` - `id: string` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `version_id: string` - `workflow_id: string` # Status ## Change status of instance **patch** `/accounts/{account_id}/workflows/{workflow_name}/instances/{instance_id}/status` Changes the execution status of a workflow instance (e.g., pause, resume, terminate). ### Path Parameters - `account_id: string` - `workflow_name: string` - `instance_id: string` ### Body Parameters - `status: "resume" or "pause" or "terminate" or "restart"` Apply action to instance. - `"resume"` - `"pause"` - `"terminate"` - `"restart"` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `result: object { status, timestamp }` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `timestamp: string` Accepts ISO 8601 with no timezone offsets and in UTC. - `success: true` - `true` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances/$INSTANCE_ID/status \ -X PATCH \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -d '{ "status": "resume" }' ``` #### 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 } } ``` ## Domain Types ### Status Edit Response - `StatusEditResponse = object { status, timestamp }` - `status: "queued" or "running" or "paused" or 5 more` - `"queued"` - `"running"` - `"paused"` - `"errored"` - `"terminated"` - `"complete"` - `"waitingForPause"` - `"waiting"` - `timestamp: string` Accepts ISO 8601 with no timezone offsets and in UTC. # Events ## Send event to instance **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. ### Path Parameters - `account_id: string` - `workflow_name: string` - `instance_id: string` - `event_type: string` ### Body Parameters - `body: optional unknown` ### Returns - `errors: array of object { code, message }` - `code: number` - `message: string` - `messages: array of object { code, message }` - `code: number` - `message: string` - `success: true` - `true` - `result: optional unknown` - `result_info: optional object { count, per_page, total_count, 2 more }` - `count: number` - `per_page: number` - `total_count: number` - `cursor: optional string` - `page: optional number` ### Example ```http curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workflows/$WORKFLOW_NAME/instances/$INSTANCE_ID/events/$EVENT_TYPE \ -X POST \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" ``` #### 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 } } ``` ## Domain Types ### Event Create Response - `EventCreateResponse = unknown`