@upstash/workflow 1.4.0 → 1.5.1-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +9 -0
  2. package/astro.d.mts +19 -2
  3. package/astro.d.ts +19 -2
  4. package/astro.js +670 -159
  5. package/astro.mjs +1 -1
  6. package/{chunk-DRHEHWMS.mjs → chunk-J3PXPHSB.mjs} +828 -317
  7. package/cloudflare.d.mts +17 -2
  8. package/cloudflare.d.ts +17 -2
  9. package/cloudflare.js +670 -159
  10. package/cloudflare.mjs +1 -1
  11. package/docs/agents/examples.mdx +8 -0
  12. package/docs/agents/features.mdx +375 -0
  13. package/docs/agents/getting-started.mdx +139 -0
  14. package/docs/agents/overview.mdx +40 -0
  15. package/docs/agents/patterns/evaluator-optimizer.mdx +72 -0
  16. package/docs/agents/patterns/orchestrator-workers.mdx +95 -0
  17. package/docs/agents/patterns/parallelization.mdx +77 -0
  18. package/docs/agents/patterns/prompt-chaining.mdx +84 -0
  19. package/docs/basics/best-practices/at-least-one-step.mdx +57 -0
  20. package/docs/basics/best-practices/business-logic-in-steps.mdx +52 -0
  21. package/docs/basics/best-practices/deterministic-code.mdx +132 -0
  22. package/docs/basics/best-practices/idempotency.mdx +38 -0
  23. package/docs/basics/best-practices/nested-context-methods.mdx +38 -0
  24. package/docs/basics/best-practices/overview.mdx +35 -0
  25. package/docs/basics/best-practices/promise-any.mdx +9 -0
  26. package/docs/basics/best-practices/return-step-results.mdx +80 -0
  27. package/docs/basics/best-practices/workflow-limits.mdx +62 -0
  28. package/docs/basics/client/cancel.mdx +137 -0
  29. package/docs/basics/client/dlq/callback.mdx +21 -0
  30. package/docs/basics/client/dlq/delete.mdx +120 -0
  31. package/docs/basics/client/dlq/list.mdx +96 -0
  32. package/docs/basics/client/dlq/restart.mdx +164 -0
  33. package/docs/basics/client/dlq/resume.mdx +167 -0
  34. package/docs/basics/client/logs.mdx +139 -0
  35. package/docs/basics/client/notify.mdx +79 -0
  36. package/docs/basics/client/trigger.mdx +139 -0
  37. package/docs/basics/client/waiters.mdx +31 -0
  38. package/docs/basics/client.mdx +40 -0
  39. package/docs/basics/how.mdx +65 -0
  40. package/docs/basics/serve/advanced.mdx +435 -0
  41. package/docs/basics/serve.mdx +142 -0
  42. package/docs/changelog.mdx +174 -0
  43. package/docs/examples/allInOne.mdx +377 -0
  44. package/docs/examples/authWebhook.mdx +575 -0
  45. package/docs/examples/customRetry.mdx +309 -0
  46. package/docs/examples/customerOnboarding.mdx +230 -0
  47. package/docs/examples/dynamicWorkflow.mdx +203 -0
  48. package/docs/examples/eCommerceOrderFulfillment.mdx +281 -0
  49. package/docs/examples/imageProcessing.mdx +339 -0
  50. package/docs/examples/paymentRetry.mdx +438 -0
  51. package/docs/examples/waitForEvent.mdx +201 -0
  52. package/docs/features/dlq/callback.mdx +42 -0
  53. package/docs/features/dlq/delete.mdx +29 -0
  54. package/docs/features/dlq/restart.mdx +33 -0
  55. package/docs/features/dlq/resume.mdx +37 -0
  56. package/docs/features/dlq.mdx +39 -0
  57. package/docs/features/failure-callback.mdx +102 -0
  58. package/docs/features/failureFunction/advanced.mdx +36 -0
  59. package/docs/features/failureFunction/reliability.mdx +33 -0
  60. package/docs/features/flow-control/monitor.mdx +22 -0
  61. package/docs/features/flow-control/parallelism.mdx +45 -0
  62. package/docs/features/flow-control/rate-period.mdx +46 -0
  63. package/docs/features/flow-control.mdx +164 -0
  64. package/docs/features/invoke/serveMany.mdx +109 -0
  65. package/docs/features/invoke.mdx +39 -0
  66. package/docs/features/notify.mdx +127 -0
  67. package/docs/features/parallel-steps.mdx +41 -0
  68. package/docs/features/retries/prevent-retries.mdx +140 -0
  69. package/docs/features/retries.mdx +93 -0
  70. package/docs/features/wait-for-event.mdx +104 -0
  71. package/docs/features/wait.mdx +44 -0
  72. package/docs/features/webhooks.mdx +116 -0
  73. package/docs/getstarted.mdx +200 -0
  74. package/docs/howto/cancel.mdx +50 -0
  75. package/docs/howto/changes.mdx +33 -0
  76. package/docs/howto/configure.mdx +42 -0
  77. package/docs/howto/failures.mdx +185 -0
  78. package/docs/howto/get-token.mdx +18 -0
  79. package/docs/howto/local-development/development-server.mdx +130 -0
  80. package/docs/howto/local-development/local-tunnel.mdx +73 -0
  81. package/docs/howto/middlewares.mdx +263 -0
  82. package/docs/howto/migrations.mdx +335 -0
  83. package/docs/howto/multi-region.mdx +107 -0
  84. package/docs/howto/parallel-runs.mdx +52 -0
  85. package/docs/howto/readonly-token.mdx +19 -0
  86. package/docs/howto/realtime/basic.mdx +315 -0
  87. package/docs/howto/realtime/human-in-the-loop.mdx +454 -0
  88. package/docs/howto/redact-fields.mdx +61 -0
  89. package/docs/howto/retry-now.mdx +41 -0
  90. package/docs/howto/schedule.mdx +114 -0
  91. package/docs/howto/security.mdx +143 -0
  92. package/docs/howto/singleton.mdx +137 -0
  93. package/docs/howto/start.mdx +69 -0
  94. package/docs/howto/use-webhooks.mdx +256 -0
  95. package/docs/integrations/aisdk.mdx +316 -0
  96. package/docs/integrations/anthropic.mdx +51 -0
  97. package/docs/integrations/datadog.mdx +69 -0
  98. package/docs/integrations/openai.mdx +87 -0
  99. package/docs/integrations/prometheus.mdx +65 -0
  100. package/docs/integrations/resend.mdx +82 -0
  101. package/docs/llms-txt.mdx +4 -0
  102. package/docs/openapi.yaml +2946 -0
  103. package/docs/pricing.mdx +22 -0
  104. package/docs/quickstarts/astro.mdx +185 -0
  105. package/docs/quickstarts/cloudflare-workers.mdx +190 -0
  106. package/docs/quickstarts/express.mdx +190 -0
  107. package/docs/quickstarts/fastapi.mdx +282 -0
  108. package/docs/quickstarts/flask.mdx +282 -0
  109. package/docs/quickstarts/hono.mdx +221 -0
  110. package/docs/quickstarts/nextjs-fastapi.mdx +147 -0
  111. package/docs/quickstarts/nextjs-flask.mdx +147 -0
  112. package/docs/quickstarts/nuxt.mdx +169 -0
  113. package/docs/quickstarts/platforms.mdx +78 -0
  114. package/docs/quickstarts/solidjs.mdx +161 -0
  115. package/docs/quickstarts/svelte.mdx +170 -0
  116. package/docs/quickstarts/tanstack-start.mdx +205 -0
  117. package/docs/quickstarts/vercel-nextjs.mdx +233 -0
  118. package/docs/roadmap.mdx +8 -0
  119. package/docs/sdk/workflow-js.mdx +4 -0
  120. package/docs/sdk/workflow-py.mdx +4 -0
  121. package/docs/steps/api.mdx +64 -0
  122. package/docs/steps/call.mdx +183 -0
  123. package/docs/steps/cancel.mdx +25 -0
  124. package/docs/steps/createWebhook.mdx +40 -0
  125. package/docs/steps/invoke.mdx +100 -0
  126. package/docs/steps/notify.mdx +105 -0
  127. package/docs/steps/run.mdx +150 -0
  128. package/docs/steps/sleep.mdx +97 -0
  129. package/docs/steps/sleepUntil.mdx +88 -0
  130. package/docs/steps/waitForEvent.mdx +60 -0
  131. package/docs/steps/waitForWebhook.mdx +78 -0
  132. package/docs/steps.mdx +108 -0
  133. package/docs/troubleshooting/general.mdx +331 -0
  134. package/docs/troubleshooting/vercel.mdx +82 -0
  135. package/express.d.mts +19 -2
  136. package/express.d.ts +19 -2
  137. package/express.js +670 -159
  138. package/express.mjs +1 -1
  139. package/h3.d.mts +19 -2
  140. package/h3.d.ts +19 -2
  141. package/h3.js +670 -159
  142. package/h3.mjs +1 -1
  143. package/hono.d.mts +17 -2
  144. package/hono.d.ts +17 -2
  145. package/hono.js +670 -159
  146. package/hono.mjs +1 -1
  147. package/index.d.mts +50 -21
  148. package/index.d.ts +50 -21
  149. package/index.js +686 -171
  150. package/index.mjs +17 -13
  151. package/nextjs.d.mts +40 -2
  152. package/nextjs.d.ts +40 -2
  153. package/nextjs.js +670 -159
  154. package/nextjs.mjs +1 -1
  155. package/package.json +1 -1
  156. package/react-router.d.mts +16 -2
  157. package/react-router.d.ts +16 -2
  158. package/react-router.js +670 -159
  159. package/react-router.mjs +1 -1
  160. package/{serve-many-CG3BFvO3.d.mts → serve-many-BKukvLNl.d.mts} +1 -1
  161. package/{serve-many-iJF1IUXk.d.ts → serve-many-CrLKQpuZ.d.ts} +1 -1
  162. package/solidjs.d.mts +10 -1
  163. package/solidjs.d.ts +10 -1
  164. package/solidjs.js +670 -159
  165. package/solidjs.mjs +1 -1
  166. package/src/platforms/astro.ts +84 -0
  167. package/src/platforms/cloudflare.ts +127 -0
  168. package/src/platforms/express.ts +147 -0
  169. package/src/platforms/h3.ts +105 -0
  170. package/src/platforms/hono.ts +103 -0
  171. package/src/platforms/nextjs.ts +193 -0
  172. package/src/platforms/react-router.ts +92 -0
  173. package/src/platforms/solidjs.ts +59 -0
  174. package/src/platforms/svelte.ts +99 -0
  175. package/src/platforms/tanstack.ts +96 -0
  176. package/src/src/client/dlq.ts +387 -0
  177. package/src/src/client/filter-types.ts +166 -0
  178. package/src/src/client/index.ts +350 -0
  179. package/src/src/client/types.ts +501 -0
  180. package/src/src/client/utils.ts +307 -0
  181. package/src/src/constants.ts +82 -0
  182. package/src/src/context/api/anthropic.ts +58 -0
  183. package/src/src/context/api/base.ts +52 -0
  184. package/src/src/context/api/index.ts +24 -0
  185. package/src/src/context/api/openai.ts +125 -0
  186. package/src/src/context/api/resend.ts +57 -0
  187. package/src/src/context/auto-executor.ts +707 -0
  188. package/src/src/context/context.ts +681 -0
  189. package/src/src/context/index.ts +1 -0
  190. package/src/src/context/provider.ts +37 -0
  191. package/src/src/context/steps.ts +965 -0
  192. package/src/src/error.ts +203 -0
  193. package/src/src/index.ts +13 -0
  194. package/src/src/middleware/default-callbacks.ts +20 -0
  195. package/src/src/middleware/index.ts +2 -0
  196. package/src/src/middleware/logging.ts +39 -0
  197. package/src/src/middleware/manager.ts +148 -0
  198. package/src/src/middleware/middleware.ts +46 -0
  199. package/src/src/middleware/types.ts +72 -0
  200. package/src/src/qstash/headers.ts +397 -0
  201. package/src/src/qstash/step-config.ts +268 -0
  202. package/src/src/qstash/submit-steps.ts +284 -0
  203. package/src/src/serve/authorization.ts +118 -0
  204. package/src/src/serve/index.ts +475 -0
  205. package/src/src/serve/multi-region/handlers.ts +225 -0
  206. package/src/src/serve/multi-region/utils.ts +88 -0
  207. package/src/src/serve/options.ts +241 -0
  208. package/src/src/serve/serve-many.ts +117 -0
  209. package/src/src/serve/utils.ts +11 -0
  210. package/src/src/types.ts +590 -0
  211. package/src/src/utils.ts +141 -0
  212. package/src/src/workflow-parser.ts +472 -0
  213. package/src/src/workflow-requests.ts +575 -0
  214. package/svelte.d.mts +17 -2
  215. package/svelte.d.ts +17 -2
  216. package/svelte.js +670 -159
  217. package/svelte.mjs +1 -1
  218. package/tanstack.d.mts +15 -2
  219. package/tanstack.d.ts +15 -2
  220. package/tanstack.js +670 -159
  221. package/tanstack.mjs +1 -1
  222. package/{types-CekOpKvz.d.ts → types-CrgK5P6p.d.mts} +372 -32
  223. package/{types-CekOpKvz.d.mts → types-CrgK5P6p.d.ts} +372 -32
@@ -0,0 +1,335 @@
1
+ ---
2
+ title: "Migration Guide"
3
+ ---
4
+
5
+ This guide covers migration between different versions of Upstash Workflow.
6
+
7
+ <AccordionGroup>
8
+ <Accordion title="January 2026 - Major Release 1.0.0" defaultOpen>
9
+ In January 2026, we released 1.0.0 version of the TypeScript SDK with several breaking changes to improve the developer experience, reduce bundle size, and simplify configuration.
10
+
11
+ ## Agents API → Separate Package
12
+
13
+ The Agents API has been moved to a separate package to remove the AI SDK dependency from the core workflow package.
14
+
15
+ ### Migration Steps
16
+
17
+ 1. Install the new package:
18
+
19
+ ```bash
20
+ npm install @upstash/workflow-agents
21
+ ```
22
+
23
+ 2. Update your imports:
24
+
25
+ ```typescript
26
+ // Old
27
+ import { serve } from "@upstash/workflow/nextjs";
28
+
29
+ export const { POST } = serve(async (context) => {
30
+ const model = context.agents.openai('gpt-3.5-turbo');
31
+ const agent = context.agents.agent({ ... });
32
+ const task = context.agents.task({ ... });
33
+ });
34
+
35
+ // New
36
+ import { serve } from "@upstash/workflow/nextjs";
37
+ import { agentWorkflow } from "@upstash/workflow-agents";
38
+
39
+ export const { POST } = serve(async (context) => {
40
+ const agents = agentWorkflow(context)
41
+
42
+ const model = agents.openai('gpt-3.5-turbo');
43
+ const agent = agents.agent({ ... });
44
+ const task = agents.task({ ... });
45
+ });
46
+ ```
47
+
48
+ See [Agents documentation](/workflow/agents/overview) for more details.
49
+
50
+ ## Removed `keepTriggerConfig` and `useFailureFunction`
51
+
52
+ These parameters are no longer needed in `client.trigger()` as both are now `true` by default.
53
+
54
+ ### Migration Steps
55
+
56
+ Simply remove these parameters from your trigger calls:
57
+
58
+ ```typescript
59
+ // Old
60
+ const { workflowRunId } = await client.trigger({
61
+ url: "https://your-app.com/api/workflow",
62
+ retries: 3,
63
+ keepTriggerConfig: true,
64
+ useFailureFunction: true
65
+ });
66
+
67
+ // New
68
+ const { workflowRunId } = await client.trigger({
69
+ url: "https://your-app.com/api/workflow",
70
+ retries: 3
71
+ });
72
+ ```
73
+
74
+ Configuration passed to `trigger()` now automatically applies to the entire workflow.
75
+
76
+ ## Configuration Moved from `serve` to `trigger`
77
+
78
+ The `retries`, `flowControl`, `retryDelay`, and `failureUrl` options have been removed from `serve()` and should now be passed in `client.trigger()`.
79
+
80
+ ### Migration Steps
81
+
82
+ Move configuration from serve options to trigger:
83
+
84
+ ```typescript
85
+ // Old
86
+ export const { POST } = serve(
87
+ async (context) => { ... },
88
+ {
89
+ retries: 3,
90
+ retryDelay: "1000 * (1 + retried)",
91
+ flowControl: { key: "my-key", rate: 10 }
92
+ }
93
+ );
94
+
95
+ // Trigger call
96
+ await client.trigger({ url: "..." });
97
+
98
+ // New
99
+ export const { POST } = serve(
100
+ async (context) => { ... }
101
+ // No configuration here anymore
102
+ );
103
+
104
+ // Configuration in trigger call
105
+ await client.trigger({
106
+ url: "...",
107
+ retries: 3,
108
+ retryDelay: "1000 * (1 + retried)",
109
+ flowControl: { key: "my-key", rate: 10 }
110
+ });
111
+ ```
112
+
113
+ This change makes it easier to configure different behavior for different workflow runs of the same endpoint.
114
+
115
+ <Note>
116
+ In the Python SDK, these options remain in the `serve` decorator as they were before.
117
+ </Note>
118
+
119
+ ## Removed `stringifyBody` from `context.call` and `context.invoke`
120
+
121
+ The `stringifyBody` parameter has been removed. The `body` parameter now expects a string.
122
+
123
+ ### Migration Steps
124
+
125
+ Update your call and invoke methods to use `JSON.stringify()`:
126
+
127
+ ```typescript
128
+ // Old
129
+ const result = await context.call("call-api", {
130
+ url: "https://api.example.com/endpoint",
131
+ method: "POST",
132
+ body: { key: "value" },
133
+ stringifyBody: true
134
+ });
135
+
136
+ // New
137
+ const result = await context.call("call-api", {
138
+ url: "https://api.example.com/endpoint",
139
+ method: "POST",
140
+ body: JSON.stringify({ key: "value" })
141
+ });
142
+ ```
143
+
144
+ The same applies to `context.invoke()`:
145
+
146
+ ```typescript
147
+ // Old
148
+ await context.invoke("invoke-workflow", {
149
+ workflow: otherWorkflow,
150
+ body: { key: "value" },
151
+ stringifyBody: true
152
+ });
153
+
154
+ // New
155
+ await context.invoke("invoke-workflow", {
156
+ workflow: otherWorkflow,
157
+ body: JSON.stringify({ key: "value" })
158
+ });
159
+ ```
160
+
161
+ ## Logger → Middleware System
162
+
163
+ The logging system has been replaced with a more flexible middleware system.
164
+
165
+ ### Migration Steps
166
+
167
+ Replace the old logger with the new middleware:
168
+
169
+ ```typescript
170
+ // Old
171
+ // Logging was automatic or controlled via verbose option
172
+ export const { POST } = serve(
173
+ async (context) => { ... },
174
+ { verbose: true }
175
+ );
176
+
177
+ // New
178
+ import { loggingMiddleware } from "@upstash/workflow";
179
+
180
+ export const { POST } = serve(
181
+ async (context) => { ... },
182
+ {
183
+ middlewares: [loggingMiddleware]
184
+ }
185
+ );
186
+ ```
187
+
188
+ You can also create custom middlewares for more control. See [Middlewares documentation](/workflow/howto/middlewares) for details.
189
+
190
+ ## Removed `onStepFinish`
191
+
192
+ The `onStepFinish` callback has been removed. Use middlewares instead.
193
+
194
+ ### Migration Steps
195
+
196
+ Replace `onStepFinish` with a custom middleware:
197
+
198
+ ```typescript
199
+ // Old
200
+ export const { POST } = serve(
201
+ async (context) => { ... },
202
+ {
203
+ onStepFinish: (stepName, result) => {
204
+ console.log(`Step ${stepName} finished with:`, result);
205
+ }
206
+ }
207
+ );
208
+
209
+ // New
210
+ import { WorkflowMiddleware } from "@upstash/workflow";
211
+
212
+ const stepFinishMiddleware = new WorkflowMiddleware({
213
+ name: "step-finish",
214
+ callbacks: {
215
+ afterExecution: async ({ stepName, result }) => {
216
+ console.log(`Step ${stepName} finished with:`, result);
217
+ }
218
+ }
219
+ });
220
+
221
+ export const { POST } = serve(
222
+ async (context) => { ... },
223
+ {
224
+ middlewares: [stepFinishMiddleware]
225
+ }
226
+ );
227
+ ```
228
+
229
+ See [Middlewares documentation](/workflow/howto/middlewares) for more details.
230
+
231
+ </Accordion>
232
+
233
+ <Accordion title="October 2024 - Migrate from @upstash/qstash">
234
+ In October 2024, we released a new SDK, `@upstash/workflow`, for Upstash Workflow, separating its development from the QStash SDK. Although Upstash Workflow is built on QStash, our goal is to improve the developer experience and support with a dedicated SDK. Development for Upstash Workflow will occur in `@upstash/workflow`, and Workflow-related imports will be removed from `@upstash/qstash` in future releases.
235
+
236
+ If you started using Upstash Workflow with `@upstash/qstash`, you will need to migrate to `@upstash/workflow`. We have made some backward-incompatible changes, but we aim to make the transition as smooth as possible.
237
+ In this guide, we will explain the changes you may need to make for migration.
238
+
239
+ ### Install `@upstash/workflow`
240
+
241
+ First, we will need to install the new package with:
242
+
243
+ <Tabs>
244
+ <Tab title="npm">
245
+ ```bash
246
+ npm install @upstash/workflow
247
+ ```
248
+ </Tab>
249
+ <Tab title="pnpm">
250
+ ```bash
251
+ pnpm install @upstash/workflow
252
+ ```
253
+ </Tab>
254
+ <Tab title="bun">
255
+ ```bash
256
+ bun add @upstash/workflow
257
+ ```
258
+ </Tab>
259
+ </Tabs>
260
+
261
+
262
+ If you were using `@upstash/qstash` only for workflow, you can uninstall it from your project.
263
+
264
+ ### Serve methods
265
+
266
+ You will need to change the imports from `@upstash/qstash` to @upstash/workflow:
267
+
268
+ ```ts
269
+ // old
270
+ import { serve } from "@upstash/qstash/nextjs"
271
+
272
+ // new
273
+ import { serve } from "@upstash/workflow/nextjs"
274
+ ```
275
+
276
+ We have updated what our `serve` methods return. We made this change to make it
277
+ easier to extend the API in the future.
278
+
279
+ For instance, Next.js method changed like this:
280
+
281
+ ```javascript
282
+ // old
283
+ export const POST = serve(...);
284
+
285
+ // new
286
+ export const { POST } = serve(...);
287
+ ```
288
+
289
+ We kept the `serve` method of `Hono` the same. The rest are updated in a similar way.
290
+ See [the quickstarts](/workflow/quickstarts/platforms) for the new way `serve`
291
+ should be used.
292
+
293
+ Additionally, `@upstash/workflow/nuxt` import is removed. You should use `@upstash/workflow/h3`
294
+ instead. This change was made because `nuxt` uses `h3` under the hood and our `serve` method
295
+ for `nuxt` can work with any project using `h3`.
296
+
297
+ ### Updating `context.call`
298
+
299
+ If you were using [`context.call` method](/workflow/steps/call) in your workflow, you will need to change
300
+ how it's called and what it returns. Here is what the change looks like:
301
+
302
+ ```javascript
303
+ // old
304
+ const result = await context.call("call step", "<call-url>", "POST", ...)
305
+
306
+ // new
307
+ const {
308
+ status, // response status
309
+ headers, // response headers
310
+ body // response body
311
+ } = await context.call("call step", {
312
+ url: "<call-url>",
313
+ method: "POST",
314
+ ...
315
+ })
316
+ ```
317
+
318
+ In the old version, we only returned the response body. Also, if the request
319
+ to the url failed, [the workflow run would fail](/workflow/howto/failures).
320
+
321
+ In the new version, we update how the parameters are passed to the `context.call`.
322
+ Additionally, we change the fail behavior: if the request fails, it doesn't make the
323
+ workflow fail. Instead, the status and the body is simply returned and workflow
324
+ continues as usual.
325
+
326
+ If you have ongoing workflow runs which call `context.call` during your transition,
327
+ `status` and `headers` fields may not be available in these old runs. After your
328
+ transition, all workflow runs will have all three fields.
329
+
330
+ ### Renaming Errors
331
+
332
+ The errors in Workflow were renamed from `QStashWorkflowError` and `QStashWorkflowAbort` to `WorkflowError` and `WorkflowAbort`.
333
+
334
+ </Accordion>
335
+ </AccordionGroup>
@@ -0,0 +1,107 @@
1
+ ---
2
+ title: Select an Upstash Workflow Region
3
+ sidebarTitle: Select a Region
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ Upstash Workflow operates on top of QStash, which is available in two distinct regions: **EU region** and **US region**. Each region is completely independent with its own infrastructure, pricing, resources, and workflow runs.
9
+
10
+ ## Regional URLs
11
+
12
+ - **EU Region**: `https://qstash-eu-central-1.upstash.io`, or `https://qstash.upstash.io`
13
+ - **US Region**: `https://qstash-us-east-1.upstash.io`
14
+
15
+ ## Key Concepts
16
+
17
+ Each region maintains:
18
+ - Usage in each region is tracked and billed independently
19
+ - Workflow runs, events, and configurations are region-specific
20
+ - Each region has its own API tokens and signing keys
21
+
22
+ ### Migration Between Regions
23
+
24
+ If you don't have any active resources (active workflow runs, schedules, url groups etc), you can simply update your environment variables with the new region to migrate. If you have active resources, you will need to migrate more gracefully, as described below.
25
+
26
+ You can migrate your Workflow resources from one region to another using the Upstash Console:
27
+
28
+ 1. Navigate to the [Workflow tab on Upstash Console](https://console.upstash.com/workflow)
29
+ 2. Click the **Migrate** button
30
+ 3. Follow the guided migration process
31
+
32
+ <img src="/img/workflow/local-mode-workflow.png" alt="Local Workflow server flow diagram" />
33
+
34
+ The migration tool will:
35
+ - Help you set up migration-mode environment variables
36
+ - Copy and update your QStash resources (schedules, url groups, queues)
37
+
38
+ Your workflow logs or DLQ aren't part of the migration. They will remain in the old region.
39
+
40
+ <Info>
41
+ After migration, your app will be able to handle requests from both regions simultaneously to ensure a smooth transition.
42
+ </Info>
43
+
44
+ ## Operating Modes
45
+
46
+ Workflow SDK supports two modes of operation:
47
+
48
+ ### Single-Region Mode (Default)
49
+
50
+ When `QSTASH_REGION` environment variable is **not set**, the SDK operates in single-region mode:
51
+
52
+ - Uses `QSTASH_TOKEN` and `QSTASH_URL` (or defaults to EU region)
53
+ - All workflow triggers are sent through the configured region
54
+ - Incoming workflow requests are verified using default signing keys
55
+
56
+ ```bash
57
+ # Single-region configuration (EU)
58
+ QSTASH_URL="https://qstash.upstash.io"
59
+ QSTASH_TOKEN="your_eu_token"
60
+ QSTASH_CURRENT_SIGNING_KEY="your_eu_current_key"
61
+ QSTASH_NEXT_SIGNING_KEY="your_eu_next_key"
62
+ ```
63
+
64
+ ### Migration Mode
65
+
66
+ When `QSTASH_REGION` is set to `US_EAST_1` or `EU_CENTRAL_1`, the SDK enables migration mode:
67
+
68
+ - Uses region-specific credentials for the primary region (`QSTASH_REGION`)
69
+ - Automatically handles region detection for incoming workflow requests
70
+ - Supports receiving workflow calls from multiple regions simultaneously
71
+
72
+ <Note>
73
+ If a workflow run was started in one region, all its steps will execute in that region.
74
+ </Note>
75
+
76
+ Environment variables:
77
+
78
+ ```bash
79
+ # Migration mode configuration with US as primary
80
+ QSTASH_REGION="US_EAST_1"
81
+
82
+ US_EAST_1_QSTASH_URL="https://qstash-us-east-1.upstash.io"
83
+ US_EAST_1_QSTASH_TOKEN="your_us_token"
84
+ US_EAST_1_QSTASH_CURRENT_SIGNING_KEY="your_us_current_key"
85
+ US_EAST_1_QSTASH_NEXT_SIGNING_KEY="your_us_next_key"
86
+
87
+ EU_CENTRAL_1_QSTASH_URL="https://qstash-eu-central-1.upstash.io"
88
+ EU_CENTRAL_1_QSTASH_TOKEN="your_eu_token"
89
+ EU_CENTRAL_1_QSTASH_CURRENT_SIGNING_KEY="your_eu_current_key"
90
+ EU_CENTRAL_1_QSTASH_NEXT_SIGNING_KEY="your_eu_next_key"
91
+ ```
92
+
93
+ <Warning>
94
+ Migration mode relies on environment variables being available via `process.env`. It won't work on platforms where `process.env` is not available, such as Cloudflare Workers.
95
+ </Warning>
96
+
97
+ ## SDK Requirements
98
+
99
+ Migration support requires:
100
+ - `@upstash/workflow` >= 1.1.0
101
+ - `@upstash/qstash` >= 2.9.0
102
+
103
+ Update your dependencies:
104
+
105
+ ```bash
106
+ npm install @upstash/workflow@latest @upstash/qstash@latest
107
+ ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ title: "Parallel Runs"
3
+ ---
4
+
5
+ <Note>
6
+ This feature is not yet available in
7
+ [workflow-py](https://github.com/upstash/workflow-py). See our
8
+ [Roadmap](/workflow/roadmap) for feature parity plans and
9
+ [Changelog](/workflow/changelog) for updates.
10
+ </Note>
11
+
12
+ Just like you can execute multiple JavaScript promises at the same time using `Promise.all`, you can run multiple workflow steps at the same time:
13
+
14
+ ```typescript
15
+ const [result1, result2, result3] =
16
+ await Promise.all([
17
+ ctx.run("parallel-step-1", async () => { ... }),
18
+ ctx.run("parallel-step-2", async () => { ... }),
19
+ ctx.run("parallel-step-3", async () => { ... }),
20
+ ])
21
+ ```
22
+
23
+ In a complete code example, your workflow could look like this:
24
+
25
+ ```typescript app/api/workflow/route.ts
26
+ import { serve } from "@upstash/workflow/nextjs";
27
+ import { checkInventory, brewCoffee, printReceipt } from "@/utils";
28
+
29
+ export const { POST } = serve(async (ctx) => {
30
+ const [coffeeBeansAvailable, cupsAvailable, milkAvailable] =
31
+ await Promise.all([
32
+ ctx.run("check-coffee-beans", () => checkInventory("coffee-beans")),
33
+ ctx.run("check-cups", () => checkInventory("cups")),
34
+ ctx.run("check-milk", () => checkInventory("milk")),
35
+ ]);
36
+
37
+ // If all ingedients available, brew coffee
38
+ if (coffeeBeansAvailable && cupsAvailable && milkAvailable) {
39
+ const price = await ctx.run("brew-coffee", async () => {
40
+ return await brewCoffee({ style: "cappuccino" });
41
+ });
42
+
43
+ await printReceipt(price);
44
+ }
45
+ });
46
+ ```
47
+
48
+ After running your workflow, your dashboard shows each step in detail:
49
+
50
+ <Frame>
51
+ <img src="/img/qstash/parallel-workflow-runs.png" alt="Parallel workflow runs in the Upstash Console" />
52
+ </Frame>
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: Upstash Workflow Read-only Token
3
+ sidebarTitle: "Read-only Token"
4
+ ---
5
+
6
+ You can use a read-only version of your token to safely share it with your team or AI agents.
7
+ This token has access to your logs, messages, schedules, and other resources, but it cannot be used to publish messages, create new resources such as schedules or URL Groups, or modify existing resources.
8
+
9
+ You can get your read-only token from the dashboard by clicking "Read-only token" in the Quickstart section:
10
+
11
+ <Frame>
12
+ <img src="/img/qstash/readonly-token.png" alt="Read-only QStash token in the Upstash Console" />
13
+ </Frame>
14
+
15
+ <Info>
16
+ Note that a read-only token can still access sensitive data such as logs and messages.
17
+
18
+ If you want to share your token without exposing sensitive data, you can use the ["Redact Fields"](/workflow/howto/redact-fields) feature to hide sensitive data from the logs and resources.
19
+ </Info>