Back to APIs

Build automated workflows using Zapier's 3000+ integrations.

Using the Zapier API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your Zapier background job resumable and appear in our dashboard.

Use io.runTask() and the official SDK or fetch.

Use our HTTP endpoint to subscribe to webhooks

Example code using Zapier

Below are some working code examples of how you can use Zapier with Trigger.dev. These samples are open source and maintained by the community, you can copy and paste them into your own projects.

1
import { TriggerClient } from "@trigger.dev/sdk";
2
3
// Create a workflow in Zapier
4
// Select Webhooks by Zapier
5
// Set the Webhook URL
6
// By default, no auth is added, hence look for user-agent: Zapier
7
// Add basic auth by piping the username|password
8
// Now, look for the authorization header
9
const zapier = client.defineHttpEndpoint({
10
id: "zapier",
11
source: "zapier.com",
12
icon: "zapier",
13
verify: async (request) => {
14
const secret = process.env.ZAPIER_TRIGGER_SECRET;
15
if (!secret) {
16
return {
17
success: false,
18
reason: "The Zapier secret needs to be set in the environment.",
19
};
20
}
21
if (secret !== request.headers.get("x-trigger-secret")) {
22
return {
23
success: false,
24
reason: "The secret does not match.",
25
};
26
}
27
return { success: true };
28
},
29
});
30
31
client.defineJob({
32
id: "http-zapier",
33
name: "HTTP Zapier",
34
version: "1.0.0",
35
enabled: true,
36
trigger: zapier.onRequest(),
37
run: async (request, io, ctx) => {
38
const body = await request.json();
39
await io.logger.info(`Body`, body);
40
},
41
});