Add approvals

Pause a workflow at a waitForApproval step: its run waits until a person approves, then carries on.

Before you start

You need a workflow. See Build a workflow.

Add an approval

  1. In your project, open Building blocks > Workflows.

  2. Click Create workflow.

  3. Enter approve-refund as the Name.

  4. Replace the Source code with a workflow that waits for approval before it issues a refund:

    TypeScript
    import { tool } from "veryfront/tool";import { step, waitForApproval, workflow } from "veryfront/workflow"; const issueRefund = tool({  id: "issue-refund",  description: "Issue a refund for an amount.",  inputSchema: {    type: "object",    properties: { amount: { type: "number" } },    required: ["amount"],    additionalProperties: false,  },  execute: async ({ amount }) => ({ refunded: amount, status: "issued" }),}); export default workflow({  id: "approve-refund",  description: "Issue a refund once a person approves it.",  steps: [    waitForApproval("manager-approval", {      message: "Approve this refund?",      timeout: "24h",    }),    step("issue-refund", {      tool: issueRefund,      input: (ctx) => ({ amount: (ctx.input as { amount: number }).amount }),    }),  ],});
  5. Click Create workflow.

  6. Open the ⋯ menu.

  7. Click Run workflow.

  8. Paste the Payload:

    JSON
    { "amount": 25 }
  9. Click Create run. The run shows Waiting, with manager-approval under Pending approvals.

  10. Ask a teammate who can run workflows to open Orchestration > Runs.

  11. They click the run.

  12. They click Approve.

  13. Open the run again. You should now see it Completed, with "refunded": 25 under Output.

Troubleshooting

If Studio says "You started this run, so someone else has to approve it", the person who starts a run can't approve it. Ask a teammate to approve it.

Next steps