//native
type Clickup = {
token: string;
};
/**
* Create List From Template in Folder
* Create a new list using a list template in a folder
This request runs synchronously by default with `return_immediately=true`. The request returns the future List ID immediatly, but the List might not created at the time of the request returning.
Small temmplates can be applied syncronously, which guarantees that all sub objects are created. In case of a timeout on syncronous requests, the of objects from the template will continue to be created past the timeout.
*/
export async function main(
auth: Clickup,
folder_id: string,
template_id: string,
body: {
name: string;
options?: {
return_immediately?: false | true;
content?: string;
time_estimate?: number;
automation?: false | true;
include_views?: false | true;
old_due_date?: false | true;
old_start_date?: false | true;
old_followers?: false | true;
comment_attachments?: false | true;
recur_settings?: false | true;
old_tags?: false | true;
old_statuses?: false | true;
subtasks?: false | true;
custom_type?: false | true;
old_assignees?: false | true;
attachments?: false | true;
comment?: false | true;
old_status?: false | true;
external_dependencies?: false | true;
internal_dependencies?: false | true;
priority?: false | true;
custom_fields?: false | true;
old_checklists?: false | true;
relationships?: false | true;
old_subtask_assignees?: false | true;
start_date?: string;
due_date?: string;
remap_start_date?: false | true;
skip_weekends?: false | true;
archived?: 1 | 2;
};
},
) {
const url = new URL(
`https://api.clickup.com/api/v2/folder/${folder_id}/list_template/${template_id}`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 168 days ago