@@ -2805,6 +2805,93 @@ paths:
28052805 console.log(token.id);
28062806 }
28072807
2808+ " /api/v1/waitpoints/tokens/{waitpointId}/callback/{callbackHash} " :
2809+ post :
2810+ operationId : complete_waitpoint_token_callback_v1
2811+ summary : Complete a waitpoint token via HTTP callback
2812+ description : >-
2813+ Completes a waitpoint token using the pre-signed callback URL returned in the `url`
2814+ field when the token was created. No API key is required — the `callbackHash` in
2815+ the URL acts as the authentication token.
2816+
2817+
2818+ This is designed to be given directly to external services (e.g. as a webhook URL)
2819+ so they can unblock a waiting run without needing access to your API key.
2820+ The entire request body is passed as the output data to the waiting run.
2821+
2822+
2823+ If the token is already completed, this is a no-op and returns `success: true`.
2824+ parameters :
2825+ - in : path
2826+ name : waitpointId
2827+ required : true
2828+ schema :
2829+ type : string
2830+ description : The ID of the waitpoint token.
2831+ example : waitpoint_abc123
2832+ - in : path
2833+ name : callbackHash
2834+ required : true
2835+ schema :
2836+ type : string
2837+ description : >-
2838+ The HMAC hash that authenticates the request. This is embedded in the `url`
2839+ returned when creating the token — do not construct it manually.
2840+ requestBody :
2841+ required : false
2842+ content :
2843+ application/json :
2844+ schema :
2845+ type : object
2846+ description : >-
2847+ Any JSON object. The entire body is passed as the output data to the run
2848+ waiting on this token. If the body is not valid JSON, an empty object is used.
2849+ example :
2850+ status : approved
2851+ comment : Looks good to me!
2852+ responses :
2853+ " 200 " :
2854+ description : Waitpoint token completed successfully
2855+ content :
2856+ application/json :
2857+ schema :
2858+ " $ref " : " #/components/schemas/CompleteWaitpointTokenResponse"
2859+ " 401 " :
2860+ description : Invalid callback URL or hash mismatch
2861+ " 404 " :
2862+ description : Waitpoint token not found
2863+ " 405 " :
2864+ description : Method not allowed
2865+ " 411 " :
2866+ description : Content-Length header is required
2867+ " 413 " :
2868+ description : Request body too large
2869+ " 500 " :
2870+ description : Internal Server Error
2871+ tags :
2872+ - waitpoints
2873+ x-codeSamples :
2874+ - lang : Shell
2875+ label : cURL
2876+ source : |-
2877+ # The full URL is returned as `url` when you create a token
2878+ curl -X POST "https://api.trigger.dev/api/v1/waitpoints/tokens/waitpoint_abc123/callback/abc123hash" \
2879+ -H "Content-Type: application/json" \
2880+ -d '{"status": "approved", "comment": "Looks good to me!"}'
2881+ - lang : typescript
2882+ source : |-
2883+ import { wait } from "@trigger.dev/sdk";
2884+
2885+ // In your task: create the token and send the URL to an external service
2886+ const token = await wait.createToken({ timeout: "1h" });
2887+
2888+ await sendApprovalRequestEmail({
2889+ callbackUrl: token.url, // give this URL to the external service
2890+ });
2891+
2892+ // The external service POSTs to token.url to unblock the run
2893+ const result = await wait.forToken<{ status: string }>(token);
2894+
28082895 " /api/v1/waitpoints/tokens/{waitpointId}/complete " :
28092896 post :
28102897 operationId : complete_waitpoint_token_v1
0 commit comments