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
*`options` - optional properties to pass when creating an instance.
174
+
*`options` - optional properties to pass when creating an instance, includng a user-provided ID and payload parameters.
175
175
176
-
An ID is automatically generated, but a user-provided ID can be specified (up to 64 characters [^1]). This can be useful when mapping Workflows to users, merchants or other identifiers in your system.
176
+
An ID is automatically generated, but a user-provided ID can be specified (up to 64 characters [^1]). This can be useful when mapping Workflows to users, merchants or other identifiers in your system. You can also provide a JSON object as the `params` property, allowing you to pass data for the Workflow instance to act on as its [`WorkflowEvent`](/workflows/build/events-and-parameters/).
177
177
178
178
```ts
179
-
// Create a new Workflow instance with your own ID:
180
-
let instance =awaitenv.MY_WORKFLOW.create({ id: myIdDefinedFromOtherSystem })
179
+
// Create a new Workflow instance with your own ID and pass params to the Workflow instance
180
+
let instance =awaitenv.MY_WORKFLOW.create({
181
+
id: myIdDefinedFromOtherSystem,
182
+
params: { "hello": "world }
183
+
})
181
184
returnResponse.json({
182
185
id: instance.id,
183
186
details: awaitinstance.status(),
@@ -186,6 +189,42 @@ return Response.json({
186
189
187
190
Returns a `WorkflowInstance`.
188
191
192
+
<Render file="workflows-type-parameters">
193
+
194
+
To provide an optional type parameter to the `Workflow`, pass a type argument with your type when defining your Workflow bindings:
195
+
196
+
```ts
197
+
interfaceUser {
198
+
email: string;
199
+
createdTimestamp: number;
200
+
}
201
+
202
+
interfaceEnv {
203
+
// Pass our User type as the type parameter to the Workflow definition
204
+
MY_WORKFLOW: Workflow<User>;
205
+
}
206
+
207
+
exportdefault {
208
+
async fetch(request, env, ctx) {
209
+
// More likely to come from your database or via the request body!
0 commit comments