0

Find User

by
Published Jun 6, 2022

Searches by email for a user who is connected/shared with your account. [See the docs here](https://developer.todoist.com/sync/v9/#read-resources)

Script todoist Verified

The script

Submitted by hugo697 Bun
Verified 398 days ago
1
type Todoist = {
2
	Token: string
3
}
4

5
interface Response {
6
	collaborators: {
7
		email: string
8
		full_name: string
9
		id: string
10
		image_id: null
11
		timezone: string
12
	}[]
13
}
14

15
export async function main(resource: Todoist, email: string) {
16
	const response = await fetch('https://api.todoist.com/sync/v9/sync', {
17
		method: 'POST',
18
		headers: {
19
			Authorization: `Bearer ${resource.Token}`,
20
			'Content-Type': 'application/x-www-form-urlencoded'
21
		},
22
		body: new URLSearchParams({
23
			sync_token: '*',
24
			resource_types: '["all"]'
25
		})
26
	})
27
	const data = (await response.json()) as Response
28
	return data.collaborators.find((x) => x.email === email)
29
}
30