You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/workflows/build/trigger-workflows.mdx
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,6 +48,12 @@ class_name = "MyWorkflow"
48
48
49
49
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).
50
50
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
+
51
57
```ts title="src/index.ts"
52
58
interfaceEnv {
53
59
MY_WORKFLOW:Workflow;
@@ -81,6 +87,33 @@ export default {
81
87
};
82
88
```
83
89
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 =awaitenv.MY_WORKFLOW.get("abc-123")
96
+
let status =awaitinstance.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
+
84
117
### Explicitly pausing a Workflow
85
118
86
119
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
125
158
126
159
## REST API (HTTP)
127
160
128
-
TODO
161
+
Refer to the [Workflows REST API documentation](/api/paths/accounts-account_id--workflows--workflow_name--instances/post).
0 commit comments