Skip to main content

Overview

Completes a waitpoint token, unblocking any run that is currently paused on wait.forToken(). An optional data payload can be included and will be returned to the waiting run as the result. If the token is already completed, this is a no-op and returns success: true.
This endpoint accepts both secret API keys and the short-lived public JWT embedded in the token’s url. This makes it safe to call directly from frontend clients or email links without exposing your secret key.

Endpoint

POST https://api.trigger.dev/api/v1/waitpoints/tokens/{waitpointId}/complete

Path parameters

waitpointId
string
required
The ID of the waitpoint token to complete, prefixed with waitpoint_.

Request body

All fields are optional.
data
any
Any JSON-serializable value to pass back to the run waiting on this token. The data is available as result.output inside the run after wait.forToken() returns.

Response

success
boolean
Always true when the request succeeds.

Examples

import { wait } from "@trigger.dev/sdk";

// Complete and pass structured data back to the waiting run
await wait.completeToken("waitpoint_abc123", {
  status: "approved",
  approvedBy: "[email protected]",
  comment: "Looks good to me!",
});

Response example

{
  "success": true
}

Receiving the data in your task

After completing the token, the waiting run resumes and wait.forToken() returns:
export const approvalTask = task({
  id: "approval-task",
  run: async (payload: { userId: string }) => {
    const token = await wait.createToken({ timeout: "24h" });

    // … send token.url to the approver …

    const result = await wait.forToken(token);

    if (!result.ok) {
      // Token timed out
      return { approved: false };
    }

    // result.output contains the data passed to completeToken
    console.log(result.output.status);   // "approved"
    console.log(result.output.comment);  // "Looks good to me!"

    return { approved: true, ...result.output };
  },
});

Build docs developers (and LLMs) love