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 { TriggerClient, eventTrigger } from "@trigger.dev/sdk";
2
import { z } from "zod";
3
import { TodoistApi } from "@doist/todoist-api-typescript";
4
5
// https://developer.todoist.com/rest/v2/?javascript#getting-started
6
// find your api reference https://todoist.com/help/articles/find-your-api-token-Jpzx9IIlB
7
const todoistClientApi = new TodoistApi(process.env.TODOIST_API_TOKEN!);
8
9
client.defineJob({
10
id: "todoist-add-new-project",
11
name: "Todoist add new project",
12
version: "1.0.0",
13
trigger: eventTrigger({
14
name: "todoist.add.project",
15
schema: z.object({
16
name: z.string(), // name of the project
17
}),
18
}),
19
20
run: async (payload, io, ctx) => {
21
// Wrap an SDK call in io.runTask so it's resumable and displays in logs
22
const user = await io.runTask(
23
"Add New Project",
24
async () => {
25
return await todoistClientApi.addProject({ name: payload.name });
26
},
27
28
// Add metadata to improve how the task displays in the logs
29
{ name: "Add Todoist project", icon: "todoist" }
30
);
31
},
32
});