Create a waitpoint token
Creates a new waitpoint token that can be used to pause a run until an external event completes it. The token includes a url which can be called via HTTP POST to complete the waitpoint. Use the token ID with wait.forToken() inside a task to pause execution until the token is completed.
secretKeyAuthorizationBearer <token>Use a named environment API key. It starts with tr_dev_sk_, tr_prod_sk_, tr_stg_sk_, etc.
Create a named API key in the API Keys section of your Trigger.dev project dashboard. Choose the narrowest access preset that supports your integration.
Our TypeScript SDK will default to using the value of the TRIGGER_SECRET_KEY environment variable if it is set. If you are using the SDK in a different environment, you can set the key using the configure function.
import { configure } from "@trigger.dev/sdk";configure({ accessToken: "tr_dev_sk_1234" });application/json- body
idempotencyKey?stringAn optional idempotency key. If you pass the same key twice before it expires, you will receive the original token back. The returned token may already be completed, in which case wait.forToken() will continue immediately.
idempotencyKeyTTL?stringHow long the idempotency key is valid, after which passing the same key creates a new waitpoint. Accepts durations like "30s", "1m", "2h", "3d".
timeout?stringHow long to wait before the token times out. When a run is waiting for a timed-out token, wait.forToken() returns with ok: false. Accepts an ISO 8601 date string or duration shorthand like "30s", "1m", "2h", "3d", "4w".
tags?|array<string>Tags to attach to the waitpoint. You can set up to 10 tags, each under 128 characters. We recommend namespacing tags with a prefix like user:1234567 or org_9876543.
Waitpoint token created successfully
application/json- response
id*stringThe unique ID of the waitpoint token.
isCached*booleantrue if an existing token was returned because the same idempotencyKey was used within its TTL window.
url*stringAn HTTP callback URL. A POST request to this URL (with an optional JSON body) will complete the waitpoint without needing an API key.
import { wait } from "@trigger.dev/sdk";const token = await wait.createToken({ timeout: "1h", tags: ["user:1234567"],});console.log(token.id); // e.g. "waitpoint_abc123"console.log(token.url); // HTTP callback URL to complete externally{ "id": "waitpoint_abc123", "isCached": true, "url": "https://api.trigger.dev/api/v1/waitpoints/tokens/waitpoint_abc123/callback/abc123hash"}Was this page helpful?
Last updated
Edit on GitHub