Skip to content

Commit 474a333

Browse files
committed
Updated docs
1 parent 776b7ea commit 474a333

File tree

2 files changed

+46
-135
lines changed

2 files changed

+46
-135
lines changed

docs/wait-for-http-callback.mdx

Lines changed: 0 additions & 135 deletions
This file was deleted.

docs/wait-for-token.mdx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import UpgradeToV4Note from "/snippets/upgrade-to-v4-note.mdx";
77

88
Waitpoint tokens pause task runs until you complete the token. They're commonly used for approval workflows and other scenarios where you need to wait for external confirmation, such as human-in-the-loop processes.
99

10+
You can complete a token using the SDK or by making a POST request to the token's URL.
11+
1012
<UpgradeToV4Note />
1113

1214
## Usage
@@ -52,6 +54,29 @@ await wait.completeToken<ApprovalToken>(tokenId, {
5254
});
5355
```
5456

57+
Or you can make an HTTP POST request to the `url` it returns:
58+
59+
```ts
60+
import { wait } from "@trigger.dev/sdk";
61+
62+
const token = await wait.createToken({
63+
timeout: "10m",
64+
});
65+
66+
const call = await replicate.predictions.create({
67+
version: "27b93a2413e7f36cd83da926f3656280b2931564ff050bf9575f1fdf9bcd7478",
68+
input: {
69+
prompt: "A painting of a cat by Andy Warhol",
70+
},
71+
// pass the provided URL to Replicate's webhook, so they can "callback"
72+
webhook: token.url,
73+
webhook_events_filter: ["completed"],
74+
});
75+
76+
const prediction = await wait.forToken<Prediction>(token).unwrap();
77+
// unwrap() throws a timeout error or returns the result 👆
78+
```
79+
5580
## wait.createToken
5681

5782
Create a waitpoint token.
@@ -85,6 +110,13 @@ The `createToken` function returns a token object with the following properties:
85110
The ID of the token. Starts with `waitpoint_`.
86111
</ParamField>
87112

113+
<ParamField query="url" type="string">
114+
The URL of the token. This is the URL you can make a POST request to in order to complete the token.
115+
116+
The JSON body of the POST request will be used as the output of the token. If there's no body the output will be an empty object `{}`.
117+
118+
</ParamField>
119+
88120
<ParamField query="isCached" type="boolean">
89121
Whether the token is cached. Will return true if the token was created with an idempotency key and
90122
the same idempotency key was used again.
@@ -338,6 +370,13 @@ Each token is an object with the following properties:
338370
The ID of the token.
339371
</ParamField>
340372

373+
<ParamField query="url" type="string">
374+
The URL of the token. This is the URL you can make a POST request to in order to complete the token.
375+
376+
The JSON body of the POST request will be used as the output of the token. If there's no body the output will be an empty object `{}`.
377+
378+
</ParamField>
379+
341380
<ParamField query="status" type="string">
342381
The status of the token.
343382
</ParamField>
@@ -404,6 +443,13 @@ The `retrieveToken` function returns a token object with the following propertie
404443
The ID of the token.
405444
</ParamField>
406445

446+
<ParamField query="url" type="string">
447+
The URL of the token. This is the URL you can make a POST request to in order to complete the token.
448+
449+
The JSON body of the POST request will be used as the output of the token. If there's no body the output will be an empty object `{}`.
450+
451+
</ParamField>
452+
407453
<ParamField query="status" type="string">
408454
The status of the token.
409455
</ParamField>

0 commit comments

Comments
 (0)