Back to APIs

Organize your tasks and manage projects.

Using the Todoist API with Trigger.dev

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

Below are some working code examples of how you can use Todoist 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 { createHmac } from "crypto";
2
import { TriggerClient } from "@trigger.dev/sdk";
3
4
// Click on Profile > Settings > Integrations > Developer
5
// Click on "Build Integrations"
6
// Create a new app, enter the Webhook callback URL, and obtain the client_secret
7
// To test the app for yourself, self-authenticate via
8
// https://developer.todoist.com/sync/v9/#webhooks:~:text=is%20not%20available).-,Webhook,-Activation%20%26%20Personal%20Use
9
// Create a note in Todoist to trigger the webhook
10
const todoist = client.defineHttpEndpoint({
11
id: "todoist",
12
source: "todoist.com",
13
icon: "todoist",
14
verify: async (request) => {
15
const bodyText = await request.text();
16
const hash = createHmac("sha256", process.env.TODOIST_CLIENT_SECRET!)
17
.update(bodyText)
18
.digest("base64");
19
const reqHash = request.headers.get("x-todoist-hmac-sha256");
20
if (hash !== reqHash)
21
return { success: false, reason: "Failed sha256 verification." };
22
return { success: true };
23
},
24
});
25
26
client.defineJob({
27
id: "http-todoist",
28
name: "HTTP Todoist",
29
version: "1.0.0",
30
enabled: true,
31
// Create a trigger from the HTTP endpoint
32
trigger: todoist.onRequest(),
33
run: async (request, io, ctx) => {
34
const body = await request.json();
35
await io.logger.info(`Body`, body);
36
},
37
});