Skip to content

Commit e11c6f3

Browse files
committed
trigger
1 parent 08afc80 commit e11c6f3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/content/docs/workflows/build/trigger-workflows.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ class_name = "MyWorkflow"
4848

4949
The `binding = "MY_WORKFLOW"` line defines the JavaScript variable that our Workflow methods are accessible on, including `create` (which triggers a new instance) or `get` (which returns the status of an existing instance).
5050

51+
The following example shows how to:
52+
53+
* Retrieve the status of an existing Workflow instance by its ID
54+
* Create (trigger) a new Workflow instance
55+
* Return the status of a given instance ID.
56+
5157
```ts title="src/index.ts"
5258
interface Env {
5359
MY_WORKFLOW: Workflow;
@@ -81,6 +87,33 @@ export default {
8187
};
8288
```
8389

90+
### Inspect a Workflow's status
91+
92+
You can inspect the status of any running Workflow instance by calling `status` against a specific instance ID. This allows you to programmatically inspect whether an instance is queued (waiting to be scheduled), actively running, paused or errored.
93+
94+
```ts
95+
let instance = await env.MY_WORKFLOW.get("abc-123")
96+
let status = await instance.status() // Returns an InstanceStatus
97+
```
98+
99+
The possible values of status are as follows:
100+
101+
```ts
102+
status:
103+
| "queued" // means that instance is waiting to be started (see concurrency limits)
104+
| "running"
105+
| "paused"
106+
| "errored"
107+
| "terminated" // user terminated the instance while it was running
108+
| "complete"
109+
| "waiting" // instance is hibernating and waiting for sleep or event to finish
110+
| "waitingForPause" // instance is finishing the current work to pause
111+
| "unknown";
112+
error?: string;
113+
output?: object;
114+
};
115+
```
116+
84117
### Explicitly pausing a Workflow
85118

86119
You can explicitly pause a Workflow instance (and later resume it) by calling `pause` against a specific instance ID.
@@ -125,7 +158,7 @@ Restarting an instance will immediately cancel any in-progress steps, erase any
125158

126159
## REST API (HTTP)
127160

128-
TODO
161+
Refer to the [Workflows REST API documentation](/api/paths/accounts-account_id--workflows--workflow_name--instances/post).
129162

130163
## Command line (CLI)
131164

0 commit comments

Comments
 (0)