Skip to main content

TodoistApi

A client for interacting with the Todoist Sync API. This class provides methods to manage tasks, projects, sections, labels, and comments in Todoist.

Example

const api = new TodoistApi('your-api-token');

// Get all tasks
const tasks = await api.getTasks();

// Create a new task
const newTask = await api.addTask({
content: 'My new task',
projectId: '12345'
});

Constructors

new TodoistApi()

new TodoistApi(authToken: string, baseUrl?: string): TodoistApi

Parameters

ParameterTypeDescription
authTokenstringYour Todoist API token.
baseUrl?stringOptional custom API base URL. If not provided, defaults to Todoist's standard API endpoint

Returns

TodoistApi

Methods

addComment()

addComment(args: AddCommentArgs, requestId?: string): Promise<Comment>

Adds a comment to a task or project.

Parameters

ParameterTypeDescription
argsAddCommentArgsParameters for creating the comment, such as content and the target task or project ID.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Comment>

A promise that resolves to the created comment.


addLabel()

addLabel(args: AddLabelArgs, requestId?: string): Promise<Label>

Adds a new label.

Parameters

ParameterTypeDescription
argsAddLabelArgsLabel creation parameters such as name.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Label>

A promise that resolves to the created label.


addProject()

addProject(args: AddProjectArgs, requestId?: string): Promise<Project>

Creates a new project with the provided parameters.

Parameters

ParameterTypeDescription
argsAddProjectArgsProject creation parameters such as name or color.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Project>

A promise that resolves to the created project.


addSection()

addSection(args: AddSectionArgs, requestId?: string): Promise<Section>

Creates a new section within a project.

Parameters

ParameterTypeDescription
argsAddSectionArgsSection creation parameters such as name or project ID.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Section>

A promise that resolves to the created section.


addTask()

addTask(args: AddTaskArgs, requestId?: string): Promise<Task>

Creates a new task with the provided parameters.

Parameters

ParameterTypeDescription
argsAddTaskArgsTask creation parameters such as content, due date, or priority.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Task>

A promise that resolves to the created task.


closeTask()

closeTask(id: string, requestId?: string): Promise<boolean>

Closes (completes) a task by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the task to close.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


deleteComment()

deleteComment(id: string, requestId?: string): Promise<boolean>

Deletes a comment by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the comment to delete.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


deleteLabel()

deleteLabel(id: string, requestId?: string): Promise<boolean>

Deletes a label by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the label to delete.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


deleteProject()

deleteProject(id: string, requestId?: string): Promise<boolean>

Deletes a project by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the project to delete.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


deleteSection()

deleteSection(id: string, requestId?: string): Promise<boolean>

Deletes a section by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the section to delete.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


deleteTask()

deleteTask(id: string, requestId?: string): Promise<boolean>

Deletes a task by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the task to delete.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


getComment()

getComment(id: string): Promise<Comment>

Retrieves a specific comment by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the comment to retrieve.

Returns

Promise<Comment>

A promise that resolves to the requested comment.


getComments()

getComments(args: 
| GetTaskCommentsArgs
| GetProjectCommentsArgs): Promise<GetCommentsResponse>

Retrieves all comments associated with a task or project.

Parameters

ParameterTypeDescription
args| GetTaskCommentsArgs | GetProjectCommentsArgsParameters for retrieving comments, such as task ID or project ID.

Returns

Promise<GetCommentsResponse>

A promise that resolves to an array of comments.


getLabel()

getLabel(id: string): Promise<Label>

Retrieves a label by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the label.

Returns

Promise<Label>

A promise that resolves to the requested label.


getLabels()

getLabels(args: GetLabelsArgs): Promise<GetLabelsResponse>

Retrieves all labels.

Parameters

ParameterTypeDescription
argsGetLabelsArgsOptional filter parameters.

Returns

Promise<GetLabelsResponse>

A promise that resolves to an array of labels.


getProject()

getProject(id: string): Promise<Project>

Retrieves a project by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the project.

Returns

Promise<Project>

A promise that resolves to the requested project.


getProjectCollaborators()

getProjectCollaborators(projectId: string, args: GetProjectCollaboratorsArgs): Promise<GetProjectCollaboratorsResponse>

Retrieves a list of collaborators for a specific project.

Parameters

ParameterTypeDescription
projectIdstringThe unique identifier of the project.
argsGetProjectCollaboratorsArgsOptional parameters to filter collaborators.

Returns

Promise<GetProjectCollaboratorsResponse>

A promise that resolves to an array of collaborators for the project.


getProjects()

getProjects(args: GetProjectsArgs): Promise<GetProjectsResponse>

Retrieves all projects with optional filters.

Parameters

ParameterTypeDescription
argsGetProjectsArgsOptional filters for retrieving projects.

Returns

Promise<GetProjectsResponse>

A promise that resolves to an array of projects.


getSection()

getSection(id: string): Promise<Section>

Retrieves a single section by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the section.

Returns

Promise<Section>

A promise that resolves to the requested section.


getSections()

getSections(args: GetSectionsArgs): Promise<GetSectionsResponse>

Retrieves all sections within a specific project or matching criteria.

Parameters

ParameterTypeDescription
argsGetSectionsArgsFilter parameters such as project ID.

Returns

Promise<GetSectionsResponse>

A promise that resolves to an array of sections.


getSharedLabels()

getSharedLabels(args?: GetSharedLabelsArgs): Promise<GetSharedLabelsResponse>

Retrieves a list of shared labels.

Parameters

ParameterTypeDescription
args?GetSharedLabelsArgsOptional parameters to filter shared labels.

Returns

Promise<GetSharedLabelsResponse>

A promise that resolves to an array of shared labels.


getTask()

getTask(id: string): Promise<Task>

Retrieves a single active (non-completed) task by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the task.

Returns

Promise<Task>

A promise that resolves to the requested task.


getTasks()

getTasks(args: GetTasksArgs): Promise<GetTasksResponse>

Retrieves a list of active tasks filtered by specific parameters.

Parameters

ParameterTypeDescription
argsGetTasksArgsFilter parameters such as project ID, label ID, or due date.

Returns

Promise<GetTasksResponse>

A promise that resolves to an array of tasks.


moveTasks()

moveTasks(
ids: string[],
args: MoveTaskArgs,
requestId?: string): Promise<Task[]>

Moves existing tasks by their ID to either a different parent/section/project.

Parameters

ParameterTypeDescription
idsstring[]The unique identifier of the tasks to be moved.
argsMoveTaskArgsThe paramets that should contain only one of projectId, sectionId, or parentId
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Task[]>

  • A promise that resolves to an array of the updated tasks.

quickAddTask()

quickAddTask(args: QuickAddTaskArgs): Promise<Task>

Quickly adds a task using natural language processing for due dates.

Parameters

ParameterTypeDescription
argsQuickAddTaskArgsQuick add task parameters, including content and due date.

Returns

Promise<Task>

A promise that resolves to the created task.


removeSharedLabel()

removeSharedLabel(args: RemoveSharedLabelArgs): Promise<boolean>

Removes a shared label.

Parameters

ParameterTypeDescription
argsRemoveSharedLabelArgsParameters for removing the shared label.

Returns

Promise<boolean>

A promise that resolves to true if successful.


renameSharedLabel()

renameSharedLabel(args: RenameSharedLabelArgs): Promise<boolean>

Renames an existing shared label.

Parameters

ParameterTypeDescription
argsRenameSharedLabelArgsParameters for renaming the shared label, including the current and new name.

Returns

Promise<boolean>

A promise that resolves to true if successful.


reopenTask()

reopenTask(id: string, requestId?: string): Promise<boolean>

Reopens a previously closed (completed) task by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the task to reopen.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<boolean>

A promise that resolves to true if successful.


updateComment()

updateComment(
id: string,
args: UpdateCommentArgs,
requestId?: string): Promise<Comment>

Updates an existing comment by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the comment to update.
argsUpdateCommentArgsUpdate parameters such as new content.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Comment>

A promise that resolves to the updated comment.


updateLabel()

updateLabel(
id: string,
args: UpdateLabelArgs,
requestId?: string): Promise<Label>

Updates an existing label by its ID.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the label to update.
argsUpdateLabelArgsUpdate parameters such as name or color.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Label>

A promise that resolves to the updated label.


updateProject()

updateProject(
id: string,
args: UpdateProjectArgs,
requestId?: string): Promise<Project>

Updates an existing project by its ID with the provided parameters.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the project to update.
argsUpdateProjectArgsUpdate parameters such as name or color.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Project>

A promise that resolves to the updated project.


updateSection()

updateSection(
id: string,
args: UpdateSectionArgs,
requestId?: string): Promise<Section>

Updates a section by its ID with the provided parameters.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the section to update.
argsUpdateSectionArgsUpdate parameters such as name or project ID.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Section>

A promise that resolves to the updated section.


updateTask()

updateTask(
id: string,
args: UpdateTaskArgs,
requestId?: string): Promise<Task>

Updates an existing task by its ID with the provided parameters.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the task to update.
argsUpdateTaskArgsUpdate parameters such as content, priority, or due date.
requestId?stringOptional unique identifier for idempotency.

Returns

Promise<Task>

A promise that resolves to the updated task.