Add tags from time entries
One script reply has been approved by the moderators Verified

Add a label to a time entry.

Created by hugo697 168 days ago
Submitted by hugo697 Bun
Verified 168 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Add tags from time entries
7
 * Add a label to a time entry.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  team_id: string,
12
  body: {
13
    time_entry_ids: string[];
14
    tags: { name: string; tag_fg: string; tag_bg: string }[];
15
  },
16
) {
17
  const url = new URL(
18
    `https://api.clickup.com/api/v2/team/${team_id}/time_entries/tags`,
19
  );
20

21
  const response = await fetch(url, {
22
    method: "POST",
23
    headers: {
24
      "Content-Type": "application/json",
25
      Authorization: auth.token,
26
    },
27
    body: JSON.stringify(body),
28
  });
29
  if (!response.ok) {
30
    const text = await response.text();
31
    throw new Error(`${response.status} ${text}`);
32
  }
33
  return await response.json();
34
}
35