The commands and SDK methods that create, publish, and run Next Gen Zaps are in the beta tier. They are ready to build against, but their shape may still change in a minor release.
@zapier/zapier-durable is pre-1.0.Before you begin
- Node.js 20 or later.
- A Zapier account. Next Gen Zaps are included in every Zapier plan. Free accounts get them through a Professional plan trial in December 2026. On an Enterprise plan, an account owner or super admin must first opt in to Next Gen Zaps on the Beta features page of the Admin Center, for each workspace that needs them.
- jq, to read IDs from command output.
1. Run the CLI init command
Run init where you want the project folder:
init command:
- Creates the
my-first-zapfolder with apackage.json, atsconfig.json, and a starter app insrc/index.ts. - Asks to install the Zapier SDK, the Zapier CLI, TypeScript, and
tsx. - Asks to log you in to Zapier. A browser window opens for you to approve the login.
- Asks to run a sample program. You do not need it, so you can answer no.
@zapier/zapier-durable defines the workflow. Zod is a TypeScript library for describing the shape of data, and the workflow uses it to define its input.
2. Write your first workflow
In the project folder, create a file namedworkflow.ts. The example that follows defines a workflow with no trigger, so it runs only when you start it. It has three steps: one builds a greeting from the input, one formats it with Formatter by Zapier, and one records the time.
workflow.ts
workflow.ts and export the defineDurable() call as the default export.
The format-greeting step runs an action in Formatter by Zapier, a Zapier app that needs no app account or connection. zapier.runAction() works the same way for any of the apps on Zapier.
File name and input rules
File name and input rules
- If the file is missing, Zapier rejects the version with “No workflow entry point found”.
workflow.mts,.js,.mjs,.cjs, and.ctsalso work. - Zapier reads
inputSchemato find the Next Gen Zap’s input fields, so keep it in this file. - Your workflow checks input against
inputSchemaonly when your own code calls it with input, such as in a local test. Zapier does not check the input of the runs it starts. - For every field
defineDurable()accepts, read the package README on GitHub.
3. Test it on your machine
Create a file namedtest-locally.ts that calls the workflow with sample input:
test-locally.ts
done: true, the workflow’s result, and the ID of this execution:
Response
~/.config/zapier-sdk/durable. The Formatter step runs through your Zapier login, but the workflow itself is not on Zapier yet.
If the Formatter step fails with "Request denied by policy"
If the Formatter step fails with "Request denied by policy"
The SDK could not find your Zapier login. Run the test from the project folder that
init created, which has the Zapier CLI installed. If you set the project up another way, install the CLI in it and log in:4. Deploy it to Zapier
Before you deploy, check your code.validate-workflow checks workflow.ts without publishing anything, so you can also run it in CI. It checks connections and triggers only if you pass them:
issues is empty:
Response
issues with a message and the line it is on. The command exits with code 0 even when issues lists errors, so in CI, fail the job when issues is not empty. For example, add | jq -e '.data.issues == []' to the end of the command.
Create an empty Next Gen Zap, then publish workflow.ts as its first version. Publishing turns the Next Gen Zap on. It has no trigger, so --manual marks it as a Next Gen Zap that runs only when you start it.
zap.json and its ID in WORKFLOW_ID. If you use TypeScript, set WORKFLOW_ID to the printed ID before you run the next step: export WORKFLOW_ID=YOUR_ZAP_ID. The publish response includes the new version’s id.
Zapier installs @zapier/zapier-sdk and zod for you, so you do not pass --dependencies. Formatter needs no connection, so you do not pass --connections. In production, set exact versions so each publish installs the same code. To set them, check “Choose package versions” below.
About the beta setting
About the beta setting
ZAPIER_STABILITY=beta turns on the CLI’s beta commands for your terminal session. You can pass --stability beta to each command instead. Without it, the CLI stops with error: unknown command 'create-workflow', and WORKFLOW_ID is empty, so the publish command fails too.The TypeScript example imports from @zapier/zapier-sdk/beta and needs no setting. Each beta command and method prints a warning that it is in the beta tier. The warning does not affect the result.Choose package versions
Choose package versions
- Zapier installs zod unless you add your own version to
--dependencies. It also installs@zapier/zapier-sdkwhen your workflow imports it. - Without
--zapier-durable-version, Zapier uses its default version of@zapier/zapier-durable. Set the version with this flag, not--dependencies. - For
@zapier/zapier-durableand@zapier/zapier-sdk,latestresolves when you publish to the newest release that has been on npm for at least 24 hours. Zapier stores the exact version with the published version, so its runs always use the same code. - If your workflow imports other npm packages, add them to
--dependencieswith exact versions. - In production and CI, set exact versions for every package, so that each publish installs the same code.
5. Run your Next Gen Zap
Start the Next Gen Zap with sample input. The command waits up to 60 seconds for the run to finish and then returns it.status is finished and output holds the value your run function returned:
Response
If the run is still going or failed
If the run is still going or failed
If If
status is still started when the command returns, the run is still going, for example while a step retries. Check it again later with the run’s id:status is failed, error.message names the step that failed. Fix workflow.ts, then publish a new version and run it again.6. Check your Next Gen Zap in the Workflow Manager
Open the Workflow Manager link fromzap.json:
- Each step is a card, titled with the step’s name.
- The code of the published version is read-only. To change it, select Edit Zap.
- Agentic management is on by default. When a run fails, the agent investigates and suggests a fix.
Keep your local code and the Next Gen Zap in sync
Keep your local code and the Next Gen Zap in sync
Your local To download unpublished edits from the Workflow Manager, use
workflow.ts and the Next Gen Zap do not sync. Publishing sends a copy of your code to Zapier, and edits in the Workflow Manager stay on Zapier. Before you edit locally, download the latest published code with the version’s id:get-workflow-draft with the draft’s ID from list-workflow-drafts.Change a live Next Gen Zap and test it for free
Change a live Next Gen Zap and test it for free
To change a Next Gen Zap without affecting its live runs, work in a draft:
create-workflow-draftcopies the live version into a new draft.update-workflow-draftsaves your newworkflow.tsto the draft.run-workflow-draftruns the draft on Zapier. Pass the draft’s ID and itsdraft_revisionfrom the last create or update response. Draft runs do not use tasks.publish-workflow-draftmakes the draft the new live version.
If publishing fails with open_drafts_exist
If publishing fails with open_drafts_exist
The Next Gen Zap has an open draft with unpublished edits, or a draft copied from an older version. If you publish directly, that draft could later overwrite your new version. To fix it, choose one:
- Publish the draft with
publish-workflow-draft. - Delete the draft with
discard-workflow-draft. - Publish anyway with
--ignore-open-drafts.
Next steps
Call apps from a Next Gen Zap
Use apps that need a connection, such as Gmail and Google Sheets.
Add a trigger
Run the Next Gen Zap when something happens in an app, such as a new form response.
Run on your own servers
Keep your code on your servers while Zapier stores the journal and resumes executions.
How Next Gen Zaps in code work
Learn how steps, waits, callbacks, and replays work.