0

Get Bulk Tasks' Time in Status

by
Published Oct 17, 2025

View how long two or more tasks have been in each status. The Total time in Status ClickApp must first be enabled by the Workspace owner or an admin.

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 Bulk Tasks' Time in Status
7
 * View how long two or more tasks have been in each status. The Total time in Status ClickApp must first be enabled by the Workspace owner or an admin.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  task_ids: string | undefined,
12
  custom_task_ids: string | undefined,
13
  team_id: string | undefined,
14
  Content_Type: string,
15
) {
16
  const url = new URL(
17
    `https://api.clickup.com/api/v2/task/bulk_time_in_status/task_ids`,
18
  );
19
  for (const [k, v] of [
20
    ["task_ids", task_ids],
21
    ["custom_task_ids", custom_task_ids],
22
    ["team_id", team_id],
23
  ]) {
24
    if (v !== undefined && v !== "" && k !== undefined) {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "GET",
30
    headers: {
31
      "Content-Type": Content_Type,
32
      Authorization: auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42