Skip to content

Commit 8f5ff19

Browse files
authored
docs: update workflow trigger example urls (#383)
* docs: update workflow trigger example urls The change is to make it more obvious that - Urls should be from users deployments - And also they should contain the route(not just base url) * add small trigger code in the getting started
1 parent 2a78c7b commit 8f5ff19

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

workflow/basics/client.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Client } from "@upstash/workflow";
2626

2727
const client = new Client({ token: "<QSTASH_TOKEN>" })
2828
const { workflowRunId } = await client.trigger({
29-
url: "https://workflow-endpoint.com",
29+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
3030
body: "hello there!", // optional body
3131
headers: { ... }, // optional headers
3232
workflowRunId: "my-workflow", // optional workflow run id

workflow/getstarted.mdx

+35
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,41 @@ async def onboarding_workflow(context: AsyncWorkflowContext[InitialData]) -> Non
254254
platform-specific function timeouts.
255255
</Tip>
256256

257+
Once your endpoint is ready, you can trigger the workflow via our SDKs or using plain REST.
258+
See [here](/workflow/howto/start) for details.
259+
<CodeGroup>
260+
```ts ts SDK(recommended)
261+
import { Client } from "@upstash/workflow";
262+
263+
const client = new Client({ token: "<QSTASH_TOKEN>" });
264+
265+
const { workflowRunId } = await client.trigger({
266+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
267+
body: "hello there!", // Optional body
268+
headers: { ... }, // Optional headers
269+
workflowRunId: "my-workflow", // Optional workflow run ID
270+
retries: 3 // Optional retries for the initial request
271+
});
272+
```
273+
274+
```py python SDK
275+
from qstash import AsyncQStash
276+
277+
client = AsyncQStash("<QSTASH_TOKEN>")
278+
279+
res = await client.message.publish_json(
280+
url="https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
281+
body={"hello": "there!"},
282+
headers={...},
283+
retries=3,
284+
)
285+
```
286+
287+
```bash REST
288+
curl -X POST https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE> -b '{"hello": "there!"}'
289+
```
290+
</CodeGroup>
291+
257292
The above example should give you a rough idea of how a workflow looks in code. For step-by-step instructions on setting up your first workflow with images along the way, see our [Next.js Quickstart](/workflow/quickstarts/vercel-nextjs) or [FastAPI Quickstart](/workflow/quickstarts/fastapi).
258293

259294
---

workflow/howto/start.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { Client } from "@upstash/workflow";
2424
const client = new Client({ token: "<QSTASH_TOKEN>" });
2525

2626
const { workflowRunId } = await client.trigger({
27-
url: "https://workflow-endpoint.com",
27+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
2828
body: "hello there!", // Optional body
2929
headers: { ... }, // Optional headers
3030
workflowRunId: "my-workflow", // Optional workflow run ID
@@ -43,7 +43,7 @@ import { Client } from "@upstash/qstash";
4343
const client = new Client({ token: "<QSTASH_TOKEN>" });
4444

4545
const { messageId } = await client.publishJSON({
46-
url: "https://workflow-endpoint.com",
46+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
4747
body: { hello: "there!" },
4848
headers: { ... },
4949
retries: 3
@@ -57,7 +57,7 @@ from qstash import AsyncQStash
5757
client = AsyncQStash("<QSTASH_TOKEN>")
5858

5959
res = await client.message.publish_json(
60-
url="https://workflow-endpoint.com",
60+
url="https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
6161
body={"hello": "there!"},
6262
headers={...},
6363
retries=3,
@@ -74,14 +74,14 @@ message_id = res.message_id
7474
<Tabs>
7575
<Tab title="curl">
7676
```bash
77-
curl -X POST https://workflow-endpoint.com \
77+
curl -X POST https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE> \
7878
-H "my-header: foo" \
7979
-b '{"foo": "bar"}'
8080
```
8181
</Tab>
8282
<Tab title="fetch (TypeScript)">
8383
```js
84-
await fetch("https://workflow-endpoint.com", {
84+
await fetch("https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>", {
8585
method: "POST",
8686
body: JSON.stringify({ "foo": "bar" }),
8787
headers: {
@@ -95,7 +95,7 @@ message_id = res.message_id
9595
import requests
9696

9797
requests.post(
98-
"https://workflow-endpoint.com", json={"foo": "bar"}, headers={"my-header": "foo"}
98+
"https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>", json={"foo": "bar"}, headers={"my-header": "foo"}
9999
)
100100

101101
```

workflow/integrations/ai-sdk.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ import { Client } from "@upstash/workflow";
155155

156156
const client = new Client({ token: "<QSTASH_TOKEN>" });
157157
const { workflowRunId } = await client.trigger({
158-
url: "<WORKFLOW_ENDPOINT>",
158+
url: "https://<YOUR_WORKFLOW_ENDPOINT>/<YOUR-WORKFLOW-ROUTE>",
159159
body: { "prompt": "How is the weather in San Francisco around this time?" },
160160
});
161161
```

0 commit comments

Comments
 (0)