@@ -2656,6 +2656,50 @@ paths:
26562656 name: "my-task-id",
26572657 });
26582658
2659+ " /api/v1/waitpoints/tokens " :
2660+ post :
2661+ operationId : create_waitpoint_token_v1
2662+ summary : Create a waitpoint token
2663+ description : >-
2664+ Creates a new waitpoint token that can be used to pause a run until an external event completes it.
2665+ The token includes a `url` which can be called via HTTP POST to complete the waitpoint.
2666+ Use the token ID with `wait.forToken()` inside a task to pause execution until the token is completed.
2667+ requestBody :
2668+ required : false
2669+ content :
2670+ application/json :
2671+ schema :
2672+ " $ref " : " #/components/schemas/CreateWaitpointTokenRequest"
2673+ responses :
2674+ " 200 " :
2675+ description : Waitpoint token created successfully
2676+ content :
2677+ application/json :
2678+ schema :
2679+ " $ref " : " #/components/schemas/CreateWaitpointTokenResponse"
2680+ " 401 " :
2681+ description : Unauthorized
2682+ " 422 " :
2683+ description : Unprocessable Entity
2684+ " 500 " :
2685+ description : Internal Server Error
2686+ tags :
2687+ - waitpoints
2688+ security :
2689+ - secretKey : []
2690+ x-codeSamples :
2691+ - lang : typescript
2692+ source : |-
2693+ import { wait } from "@trigger.dev/sdk";
2694+
2695+ const token = await wait.createToken({
2696+ timeout: "1h",
2697+ tags: ["user:1234567"],
2698+ });
2699+
2700+ console.log(token.id); // e.g. "waitpoint_abc123"
2701+ console.log(token.url); // HTTP callback URL to complete externally
2702+
26592703components :
26602704 parameters :
26612705 taskIdentifier :
@@ -4216,3 +4260,60 @@ components:
42164260 results :
42174261 type : string
42184262 description : CSV-formatted results
4263+ CreateWaitpointTokenRequest :
4264+ type : object
4265+ properties :
4266+ idempotencyKey :
4267+ type : string
4268+ description : >-
4269+ An optional idempotency key. If you pass the same key twice before it expires,
4270+ you will receive the original token back. The returned token may already be completed,
4271+ in which case `wait.forToken()` will continue immediately.
4272+ example : approval-user-1234567
4273+ idempotencyKeyTTL :
4274+ type : string
4275+ description : >-
4276+ How long the idempotency key is valid, after which passing the same key
4277+ creates a new waitpoint. Accepts durations like "30s", "1m", "2h", "3d".
4278+ example : 1h
4279+ timeout :
4280+ type : string
4281+ description : >-
4282+ How long to wait before the token times out. When a run is waiting for a timed-out
4283+ token, `wait.forToken()` returns with `ok: false`. Accepts an ISO 8601 date string
4284+ or duration shorthand like "30s", "1m", "2h", "3d", "4w".
4285+ example : 1h
4286+ tags :
4287+ oneOf :
4288+ - type : string
4289+ - type : array
4290+ items :
4291+ type : string
4292+ description : >-
4293+ Tags to attach to the waitpoint. You can set up to 10 tags, each under 128 characters.
4294+ We recommend namespacing tags with a prefix like `user:1234567` or `org_9876543`.
4295+ example :
4296+ - " user:1234567"
4297+ - " org:9876543"
4298+ CreateWaitpointTokenResponse :
4299+ type : object
4300+ required :
4301+ - id
4302+ - isCached
4303+ - url
4304+ properties :
4305+ id :
4306+ type : string
4307+ description : The unique ID of the waitpoint token.
4308+ example : waitpoint_abc123
4309+ isCached :
4310+ type : boolean
4311+ description : >-
4312+ `true` if an existing token was returned because the same `idempotencyKey`
4313+ was used within its TTL window.
4314+ url :
4315+ type : string
4316+ description : >-
4317+ An HTTP callback URL. A POST request to this URL (with an optional JSON body)
4318+ will complete the waitpoint without needing an API key.
4319+ example : https://api.trigger.dev/api/v1/waitpoints/tokens/waitpoint_abc123/callback/abc123hash
0 commit comments