0

Create Task

by
Published Jun 6, 2022

Creates a task. [See the docs here](https://developer.todoist.com/rest/v2/#create-a-new-task)

Script todoist Verified

The script

Submitted by hugo697 Bun
Verified 398 days ago
1
import { TodoistApi } from '@doist/todoist-api-typescript'
2
import { v9 as Todoist } from 'todoist'
3

4
type Todoist = {
5
	Token: string
6
}
7

8
export async function main(
9
	resource: Todoist,
10
	task: {
11
		args: {
12
			content: string
13
			description?: string
14
			projectId?: string
15
			sectionId?: string
16
			parentId?: string
17
			order?: number
18
			labels?: string[]
19
			priority?: number
20
			dueLang?: string
21
			assigneeId?: string
22
			dueString?: string
23
			dueDate?: string
24
			dueDatetime?: string
25
			duration?: number
26
			durationUnit?: 'minute' | 'day'
27
		}
28
		requestId?: string
29
	}
30
) {
31
	const api = new TodoistApi(resource.Token)
32
	// @ts-ignore
33
	const taskResponse = await api.addTask(task.args, task.requestId)
34
	return taskResponse
35
}
36