0

Get time entries within a date range

by
Published Oct 17, 2025

View time entries filtered by start and end date. \ \ By default, this endpoint returns time entries from the last 30 days created by the authenticated user. \ \ To retrieve time entries for other users, you must include the `assignee` query parameter. \ \ Only one of the following location filters can be included at a time: `space_id`, `folder_id`, `list_id`, or `task_id`. \ \ ***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 time entries within a date range
7
 * View time entries filtered by start and end date. \
8
 \
9
By default, this endpoint returns time entries from the last 30 days created by the authenticated user. \
10
 \
11
To retrieve time entries for other users, you must include the `assignee` query parameter. \
12
 \
13
Only one of the following location filters can be included at a time: `space_id`, `folder_id`, `list_id`, or `task_id`. \
14
 \
15
***Note:** A time entry that has a negative duration means that timer is currently running for that user.*
16
 */
17
export async function main(
18
  auth: Clickup,
19
  team_Id: string,
20
  start_date: string | undefined,
21
  end_date: string | undefined,
22
  assignee: string | undefined,
23
  include_task_tags: string | undefined,
24
  include_location_names: string | undefined,
25
  include_approval_history: string | undefined,
26
  include_approval_details: string | undefined,
27
  space_id: string | undefined,
28
  folder_id: string | undefined,
29
  list_id: string | undefined,
30
  task_id: string | undefined,
31
  custom_task_ids: string | undefined,
32
  team_id: string | undefined,
33
  is_billable: string | undefined,
34
  Content_Type: string,
35
) {
36
  const url = new URL(
37
    `https://api.clickup.com/api/v2/team/${team_Id}/time_entries`,
38
  );
39
  for (const [k, v] of [
40
    ["start_date", start_date],
41
    ["end_date", end_date],
42
    ["assignee", assignee],
43
    ["include_task_tags", include_task_tags],
44
    ["include_location_names", include_location_names],
45
    ["include_approval_history", include_approval_history],
46
    ["include_approval_details", include_approval_details],
47
    ["space_id", space_id],
48
    ["folder_id", folder_id],
49
    ["list_id", list_id],
50
    ["task_id", task_id],
51
    ["custom_task_ids", custom_task_ids],
52
    ["team_id", team_id],
53
    ["is_billable", is_billable],
54
  ]) {
55
    if (v !== undefined && v !== "" && k !== undefined) {
56
      url.searchParams.append(k, v);
57
    }
58
  }
59
  const response = await fetch(url, {
60
    method: "GET",
61
    headers: {
62
      "Content-Type": Content_Type,
63
      Authorization: auth.token,
64
    },
65
    body: undefined,
66
  });
67
  if (!response.ok) {
68
    const text = await response.text();
69
    throw new Error(`${response.status} ${text}`);
70
  }
71
  return await response.json();
72
}
73