Skip to main content
Steps in a workflow can run actions in any of 10,000+ apps through the Zapier SDK. In this guide, you build a workflow that welcomes a new customer: it saves them to Google Sheets, sends a welcome email from Gmail, waits, and sends a follow-up email. Like the quick start, the workflow has no trigger, so it runs only when you start it.

Before you begin

  • Complete the quick start. This guide uses the same project, login, and ZAPIER_STABILITY=beta setting.
  • A Google Sheet with the column headings Name, Email, and Signed up in row 1.

1. Write a workflow that uses your apps

Replace the contents of workflow.ts with this workflow:
workflow.ts
  • zapier.runAction() runs an app action. connection names a connection alias, such as sheets, that you map to a real connection in the next step. COL$A to COL$C are the Google Sheets action’s fields for columns A to C, and worksheet: "0" is the first sheet.
  • ctx.step({ ... }) is the object form of a step. Put the function in run, next to retry settings such as maxAttempts and retryDelaySeconds.
  • ctx.wait() pauses the workflow for a number of seconds without holding a server open.
  • The SDK client sits at the top of the file. If you create it inside run, the workflow stops with a DeterminismViolation error.
You can swap Gmail or Google Sheets for any app on Zapier. For each step you change, use the Zapier SDK CLI to find three values: the app, the action, and the action’s input fields.
  1. Find the app’s key:
  2. List the app’s actions. Use key as action and action_type as actionType:
  3. List the action’s input fields. Use each key in inputs:
    For the fields as JSON Schema, which coding agents read more reliably, run get-action-input-fields-schema with the same values.
Then give the step a connection alias for the new app, and map it in step 2.If an app has no action for what you need, a step can call the app’s API directly with zapier.fetch(), using your connection. Some Enterprise accounts block these calls. For details, check Make custom API calls with fetch.

2. Point the workflow at your apps

The workflow needs a Gmail connection, a Google Sheets connection, and the ID of your sheet. Use the Zapier SDK CLI to find your connections.
  1. List your connections for each app and copy the id of the one to use:
  2. Create a file named .zapierrc that maps each alias in the code to a connection ID:
    .zapierrc
  3. Copy your spreadsheet ID from the sheet’s URL. It is the part between /d/ and /edit. Replace YOUR_SPREADSHEET_ID in workflow.ts with it.
If list-connections returns nothing for an app, you have no connection to it yet. Connect the app in Zapier, then run list-connections again.To start from your terminal instead, get a link to connect the app and open it in the browser where you are logged in to Zapier:

3. Test it on your machine

Create a file named test-onboarding.ts. Use your own email address so the emails come to you:
test-onboarding.ts
Run it:
A new row appears in your sheet and the welcome email arrives. The output shows done: false, because the workflow paused at the wait. After the 5-second wait ends, create resume-onboarding.ts with the executionId from the output, and run it:
resume-onboarding.ts
The tips email arrives and the output shows done: true with the result.
On your machine, a paused workflow continues only when you call it again with its executionId. The first run returns:
Response
When you resume, the steps that already finished do not run again, so you get no second row and no second welcome email. On Zapier, waits end on their own, so you do not need to resume.

4. Deploy it with your connections

Create a Next Gen Zap for the workflow and save its ID:
Publish the workflow with your connections. .zapierrc works on your machine only, so pass the same connection IDs in --connections. Zapier installs @zapier/zapier-sdk and zod for you. In production, set exact versions so each publish installs the same code. To set them, check Choose package versions:
The response lists both connections under connections.
Always pass --connections when the workflow uses apps. Without it, publishing succeeds, but every run fails at the first app step. If a connection ID is not in your account, publishing fails with a connection-not-found error that names the alias.
To run the Next Gen Zap when something happens in an app, such as a new form response, publish with --trigger instead of --manual. Use the Zapier SDK CLI to find each value:
  1. List the app’s triggers. Use key as action and app_key as selectedApi:
  2. List the trigger’s input fields. Use each key in params:
  3. Find the connection to use, the same way as in step 2. Its id is the authenticationId.
  4. Publish with the trigger, and leave out --manual:
You cannot pass both --trigger and --manual. A trigger that needs no connection, such as one in Schedule by Zapier, does not need authenticationId.The Next Gen Zap runs once for each new trigger record, such as each new form response, and run receives that record as input. inputSchema sets the type of input in your code, but Zapier does not check the record against it. Parse the record in run before you use its fields. You can still run the Next Gen Zap manually. For manual runs, Zapier uses inputSchema to find the input fields.

5. Run it on Zapier

Start the Next Gen Zap with your own email address:
A new row and both emails arrive, and the response shows status: "finished" with output set to { "savedTo": "Sheet1", "emailsSent": 2 }. You can also start the Next Gen Zap from the Workflow Manager. If it uses apps, the Workflow Manager asks you to confirm the app connections before the run starts. If a step fails, Zapier retries it, so status can stay started for a few minutes before it changes to failed. Zapier also emails you, and the agent in the Workflow Manager explains the cause and suggests a fix.
If the version has no connections, the save-customer step fails:
Response
error.message names the step. error.details.cause.message gives the reason. To fix this example, publish again with --connections. You cannot change a published version, so each fix publishes a new one.

Next steps

CLI reference

Every option for publish-workflow-version, including --trigger.

How Next Gen Zaps in code work

Learn how steps, waits, callbacks, and replays work.
Last modified on December 1, 2026