0

Get Task Templates

by
Published Oct 17, 2025

View the task templates available in a Workspace.

Script clickup Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Get Task Templates
7
 * View the task templates available in a Workspace.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  team_id: string,
12
  page: string | undefined,
13
  Content_Type: string,
14
) {
15
  const url = new URL(
16
    `https://api.clickup.com/api/v2/team/${team_id}/taskTemplate`,
17
  );
18
  for (const [k, v] of [["page", page]]) {
19
    if (v !== undefined && v !== "" && k !== undefined) {
20
      url.searchParams.append(k, v);
21
    }
22
  }
23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      "Content-Type": Content_Type,
27
      Authorization: auth.token,
28
    },
29
    body: undefined,
30
  });
31
  if (!response.ok) {
32
    const text = await response.text();
33
    throw new Error(`${response.status} ${text}`);
34
  }
35
  return await response.json();
36
}
37