The SDK CLI provides a simple browser-based authentication flow:
Copy
Ask AI
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.
Alternative: Client Credentials
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.
The SDK can generate TypeScript types for any app, giving you full autocomplete and type safety:
Copy
Ask AI
# Add types for the apps you want to usenpx zapier-sdk add slack google-sheets# Don't know the app key? Search for itnpx zapier-sdk list-apps --search "google sheets"
Types are generated in your src or lib folder by default. You can customize the output location:
Let’s verify everything works by listing available apps:
Copy
Ask AI
// List the first page of appsconst { 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.
Now let’s execute an action. First, you’ll need a connection for the app you want to use:
Copy
Ask AI
// 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 upconst { data: firstSlackConnection } = await zapier.findFirstConnection({ appKey: "slack", owner: "me",});// List Slack channels using your connectionconst { data: channels } = await zapier.runAction({ appKey: "slack", actionType: "read", actionKey: "channels", connectionId: firstSlackConnection.id,});console.log("Your Slack channels:", channels);