Back to APIs

Cal.com

cal.com

Manage your own / your teams bookings and calendars.

Using the Cal.com API with Trigger.dev

You can use Trigger.dev with any existing Node SDK or even just using fetch. Using io.runTask makes your Cal.com 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 Cal.com

Below are some working code examples of how you can use Cal.com 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, eventTrigger } from "@trigger.dev/sdk";
2
3
// API reference: https://cal.com/docs/enterprise-features/api/api-reference/
4
// If you get the error 'An error occurred while querying the database', this may because you have
5
// linked calendars in your account. This is a known Cal.com issue.
6
// Please reach out to us on Discord if you need help.
7
client.defineJob({
8
id: "cal-dot-com-find-all-bookings",
9
name: "Cal.com find all bookings",
10
version: "1.0.0",
11
trigger: eventTrigger({
12
name: "cal.com.find.bookings",
13
}),
14
run: async (payload, io, ctx) => {
15
// Wrap any Cal.com API call in io.runTask so it's resumable and displays in logs
16
await io.runTask(
17
"Find all bookings",
18
async () => {
19
const url = `https://api.cal.com/v1/bookings?apiKey=${process.env.CAL_API_KEY}`;
20
const response = await fetch(url);
21
return response.json();
22
},
23
24
// Add metadata to improve how the task displays in the logs
25
{ name: "Find all bookings", icon: "cal" }
26
);
27
},
28
});