Create List
One script reply has been approved by the moderators Verified

Add a new List to a Folder.

Created by hugo697 168 days ago
Submitted by hugo697 Bun
Verified 168 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Create List
7
 * Add a new List to a Folder.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  folder_id: string,
12
  body: {
13
    name: string;
14
    content?: string;
15
    markdown_content?: string;
16
    due_date?: number;
17
    due_date_time?: false | true;
18
    priority?: number;
19
    assignee?: number;
20
    status?: string;
21
  },
22
) {
23
  const url = new URL(
24
    `https://api.clickup.com/api/v2/folder/${folder_id}/list`,
25
  );
26

27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41