- Human approval — pause a content pipeline until a moderator approves
- External webhook callback — pause until Replicate, Stripe, or another service posts a result
- Multi-step forms — pause an onboarding flow until a user completes the next step
- Async third-party jobs — kick off a long job and wait for the completion webhook
If you are waiting for typed data from an input stream, use
inputStream.wait() instead — it wraps waitpoint tokens with full type safety.Basic usage
Wait for the token inside a task
Inside your task’s
run function, call wait.forToken() with the token ID. The task suspends here until the token is completed or times out:Using .unwrap()
wait.forToken() returns a result object ({ ok, output } or { ok, error }). Use .unwrap() to skip the if (result.ok) check — it throws automatically if the token timed out:
Completing via HTTP webhook
The token’surl property is an HTTP callback URL. POST a JSON body to it to complete the token from any service or language. The request body becomes the token’s output:
API reference
wait.createToken
Create a waitpoint token. Can be called from inside or outside a task.| Property | Type | Description |
|---|---|---|
id | string | Token ID (starts with waitpoint_) |
url | string | HTTP callback URL — POST to this to complete the token |
isCached | boolean | true if an idempotency key matched an existing token |
publicAccessToken | string | A Public Access Token scoped to this token |
wait.forToken
Suspend the current task run until the token is completed or times out. Must be called inside a task’srun function.
wait.completeToken
Complete a token with an output payload. Can be called from anywhere.wait.retrieveToken
Fetch the current state and output of a token by its ID.wait.listTokens
List tokens with optional filtering. Returns an async iterable — iterate withfor await:
Idempotency
Pass anidempotencyKey to createToken to avoid creating duplicate tokens if your code runs more than once (e.g. on a task retry):
Next steps
Building with AI
Human-in-the-loop patterns for AI agent workflows.
React hooks
Resume tokens from the browser using the
useWaitToken hook.Realtime overview
Stream task output to your frontend in real-time.