1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create List From Template in Space. |
7 | * Create a new List using a List template within a Space. |
8 | This request can be run asynchronously or synchronously via the `return_immediately` parameter. |
9 |
|
10 | */ |
11 | export async function main( |
12 | auth: Clickup, |
13 | space_id: string, |
14 | template_id: string, |
15 | body: { |
16 | name: string; |
17 | options?: { |
18 | return_immediately?: false | true; |
19 | content?: string; |
20 | time_estimate?: number; |
21 | automation?: false | true; |
22 | include_views?: false | true; |
23 | old_due_date?: false | true; |
24 | old_start_date?: false | true; |
25 | old_followers?: false | true; |
26 | comment_attachments?: false | true; |
27 | recur_settings?: false | true; |
28 | old_tags?: false | true; |
29 | old_statuses?: false | true; |
30 | subtasks?: false | true; |
31 | custom_type?: false | true; |
32 | old_assignees?: false | true; |
33 | attachments?: false | true; |
34 | comment?: false | true; |
35 | old_status?: false | true; |
36 | external_dependencies?: false | true; |
37 | internal_dependencies?: false | true; |
38 | priority?: false | true; |
39 | custom_fields?: false | true; |
40 | old_checklists?: false | true; |
41 | relationships?: false | true; |
42 | old_subtask_assignees?: false | true; |
43 | start_date?: string; |
44 | due_date?: string; |
45 | remap_start_date?: false | true; |
46 | skip_weekends?: false | true; |
47 | archived?: 1 | 2; |
48 | }; |
49 | }, |
50 | ) { |
51 | const url = new URL( |
52 | `https://api.clickup.com/api/v2/space/${space_id}/list_template/${template_id}`, |
53 | ); |
54 |
|
55 | const response = await fetch(url, { |
56 | method: "POST", |
57 | headers: { |
58 | "Content-Type": "application/json", |
59 | Authorization: auth.token, |
60 | }, |
61 | body: JSON.stringify(body), |
62 | }); |
63 | if (!response.ok) { |
64 | const text = await response.text(); |
65 | throw new Error(`${response.status} ${text}`); |
66 | } |
67 | return await response.json(); |
68 | } |
69 |
|