0

Get running time entry

by
Published Oct 17, 2025

View a time entry that's currently tracking time for the authenticated user. \ \ ***Note:** A time entry that has a negative duration means that timer is currently running for that user.*

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 running time entry
7
 * View a time entry that's currently tracking time for the authenticated user. \
8
 \
9
***Note:** A time entry that has a negative duration means that timer is currently running for that user.*
10
 */
11
export async function main(
12
  auth: Clickup,
13
  team_id: string,
14
  assignee: string | undefined,
15
  Content_Type: string,
16
) {
17
  const url = new URL(
18
    `https://api.clickup.com/api/v2/team/${team_id}/time_entries/current`,
19
  );
20
  for (const [k, v] of [["assignee", assignee]]) {
21
    if (v !== undefined && v !== "" && k !== undefined) {
22
      url.searchParams.append(k, v);
23
    }
24
  }
25
  const response = await fetch(url, {
26
    method: "GET",
27
    headers: {
28
      "Content-Type": Content_Type,
29
      Authorization: auth.token,
30
    },
31
    body: undefined,
32
  });
33
  if (!response.ok) {
34
    const text = await response.text();
35
    throw new Error(`${response.status} ${text}`);
36
  }
37
  return await response.json();
38
}
39