Skip to main content
This guide walks you through installing the SDK, authenticating, and running your first action.

Prerequisites

  • Node.js 18+ installed
  • A Zapier account (free tier works)
  • At least one app connected to your Zapier account

Step 1: Install the SDK

Create a new project (or use an existing one) and install the required packages:
# Create a new project (optional)
mkdir my-zapier-project && cd my-zapier-project
npm init -y

# Install the SDK and CLI
npm install @zapier/zapier-sdk
npm install -D @zapier/zapier-sdk-cli @types/node typescript

# Initialize TypeScript (if starting fresh)
npx tsc --init
Set "type": "module" in your package.json to use ES modules, which the examples in this guide assume.

Step 2: Authenticate

The SDK CLI provides a simple browser-based authentication flow:
npx zapier-sdk login
This opens your browser to authenticate with Zapier. Your token is stored locally, and as long as you have the CLI package installed as a development dependency, the SDK will automatically use it.
For server-side applications, you can use client credentials instead. See the API Reference for the full SDK API and CLI Reference for creating credentials via the CLI.
const zapier = createZapierSdk({
  credentials: {
    clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
    clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
  },
});
You can also provide a token directly:
const zapier = createZapierSdk({
  credentials: process.env.ZAPIER_CREDENTIALS,
});

Step 3: Generate Types for Your Apps

The SDK can generate TypeScript types for any app, giving you full autocomplete and type safety:
# Add types for the apps you want to use
npx zapier-sdk add slack google-sheets

# Don't know the app key? Search for it
npx zapier-sdk list-apps --search "google sheets"
Types are generated in your src or lib folder by default. You can customize the output location:
npx zapier-sdk add slack --types-output ./types

Step 4: Initialize the SDK

Create a new file (e.g., index.ts) and initialize the SDK:
import { createZapierSdk } from "@zapier/zapier-sdk";

// Initialize with browser-based auth (from `zapier-sdk login`)
const zapier = createZapierSdk();

Step 5: List Your Connected Apps

Let’s verify everything works by listing available apps:

// List the first page of apps
const { data: apps } = await zapier.listApps();

console.log(
  "Available apps:",
  apps.map((app) => app.title)
);
This returns the first page of results. For large datasets, use .items() to iterate over all results or maxItems to limit the total. See the API Reference for pagination patterns.
Run your script:
npx tsx index.ts

Step 6: Run Your First Action

Now let’s execute an action. First, you’ll need a connection for the app you want to use:

// Get Slack connection

// Option 1: Use listConnections when you need to filter or 
// work with multiple connections.
const { data: allSlackConnections } = await zapier.listConnections({
  appKey: "slack",
  owner: "me",
  isExpired: false,
});

const acmeSlackConnection = allSlackConnections.find(c => c?.title?.toLowerCase().includes("acme"))
if (!acmeSlackConnection) {
  console.log(
    "Slack connection matching filter not found. Connect Slack at https://zapier.com/app/assets/connections"
  );
}

// Option 2: Use findFirstConnection when you just need the first 
// available connection and let any errors bubble up
const { data: firstSlackConnection } = await zapier.findFirstConnection({
  appKey: "slack",
  owner: "me",
});

// List Slack channels using your connection
const { data: channels } = await zapier.runAction({
  appKey: "slack",
  actionType: "read",
  actionKey: "channels",
  connectionId: firstSlackConnection.id,
});

console.log("Your Slack channels:", channels);

Step 7: Use the Proxy Pattern (Optional)

For a cleaner syntax, use the app proxy pattern:

const { data: firstSlackConnection } = await zapier.findFirstConnection({
  appKey: "slack",
  owner: "me",
  isExpired: false,
});

// Create a bound Slack instance
const mySlack = zapier.apps.slack({
  connectionId: firstSlackConnection.id,
});

// Now use it with a clean syntax
const { data: channels } = await mySlack.read.channels({});

console.log("Channels:", channels);

// Or pass auth inline without binding
const { data: users } = await zapier.apps.slack.search.user_by_email({
  inputs: { email: "colleague@company.com" },
  connectionId: firstSlackConnection.id,
});

Step 8: Make Custom API Calls with fetch (Optional)

When you need to call an API that doesn’t have a built-in action, use fetch to make authenticated requests through the Zapier SDK:

// Get your Slack connection
const { data: slackConnection } = await zapier.findFirstConnection({
  appKey: "slack",
  owner: "me",
  isExpired: false,
});

if (!slackConnection) {
  console.log(
    "No Slack connection found. Connect Slack at https://zapier.com/app/assets/connections"
  );
  process.exit(1);
}

// Make a custom API call—Zapier injects the user's credentials
const response = await zapier.fetch("https://slack.com/api/users.list", {
  method: "GET",
  connectionId: slackConnection.id,
});

const users = await response.json();

Complete Example

Here’s a full example that sends a Slack message:
import { createZapierSdk } from "@zapier/zapier-sdk";

async function main() {
  const zapier = createZapierSdk();

  // Get Slack connection
  const { data: firstSlackConnection } = await zapier.findFirstConnection({
    appKey: "slack",
    owner: "me",
    isExpired: false,
  });

  // Create bound Slack instance
  const slack = zapier.apps.slack({
    connectionId: firstSlackConnection.id,
  });

  // Get available channels
  const { data: channels } = (await slack.read.channels({})) as {
    data: Array<{ id: string; name: string }>;
  };
  const testChannel = channels.find((c) => c.name === "testing");

  if (!testChannel) {
    throw new Error("Could not find #testing channel");
  }

  // Send a message
  const { data: result } = await slack.write.channel_message({
    inputs: {
      channel: testChannel.id,
      text: "Hello from the Zapier SDK!",
    },
  });

  console.log("Message sent!", result);
}

main().catch(console.error);

Next Steps