Skip to main content
Waitpoint tokens pause a task run indefinitely until you signal it to continue. While a run is waiting, it releases its compute slot — you are not billed for idle time. When you complete the token, the run resumes exactly where it left off. Common use cases:
  • 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

1

Create a token

Create a token from anywhere in your codebase — inside or outside a task:
2

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:
3

Complete the token

When you are ready to resume the run, complete the token from your backend, a webhook handler, or any HTTP client:

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’s url 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:
You can also complete tokens via the REST API from any language:

API reference

wait.createToken

Create a waitpoint token. Can be called from inside or outside a task.
Returns:

wait.forToken

Suspend the current task run until the token is completed or times out. Must be called inside a task’s run 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 with for await:

Idempotency

Pass an idempotencyKey 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.