Workflow Cancellable Export banner
vercel-labs vercel-labs

Workflow Cancellable Export

Productivity community

Description

cancellable-export — Workflow DevKit Example

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Cancellable Invoicing

A bulk invoice generation workflow with cancellation support built with Vercel Workflow DevKit. Spot wrong prices mid-batch? Cancel before more customers get billed incorrectly.

What This Example Demonstrates

  • Run management: Using start() to get a Run object with runId
  • Run retrieval: Using getRun(runId) to access an existing run
  • Cancellation: Using run.cancel() to stop a running workflow
  • Status checking: Using run.status, run.startedAt, run.completedAt properties
  • Progress streaming: Real-time progress updates via getWritable() and run.readable
  • Graceful interruption: Sleep points where cancellation can occur cleanly

Project Structure

05-cancellable-export/
├── app/
│   ├── api/
│   │   ├── start/
│   │   │   └── route.ts      # POST - Start invoicing workflow
│   │   ├── status/
│   │   │   └── route.ts      # GET - Check workflow status
│   │   ├── cancel/
│   │   │   └── route.ts      # POST - Cancel running workflow
│   │   └── stream/
│   │       └── [runId]/
│   │           └── route.ts  # GET - Stream progress (SSE)
│   ├── globals.css
│   ├── layout.tsx
│   └── page.tsx
├── workflows/
│   └── report-generator.ts      # The report generation workflow
├── next.config.ts               # Uses withWorkflow() wrapper
├── package.json
├── tsconfig.json
├── .env.example
└── README.md

Getting Started

  1. Install dependencies:
pnpm install
  1. Run the development server:
pnpm dev

API Reference

POST /api/start

Start a new invoicing workflow.

**Request Body:**

{
  "accountId": "acct_1",
  "total": 50,
  "delay": "1s"
}
Parameter Type Default Description
accountId string - Required. Account identifier
total number 50 Number of invoices to g