0

Get Task

by
Published Oct 17, 2025

View information about a task. You can only view task information of tasks you can access. \ \ Tasks with attachments will return an "attachments" response. \ \ Docs attached to a task are not returned.

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
7
 * View information about a task. You can only view task information of tasks you can access. \
8
 \
9
Tasks with attachments will return an "attachments" response. \
10
 \
11
Docs attached to a task are not returned.
12
 */
13
export async function main(
14
  auth: Clickup,
15
  task_id: string,
16
  team_id: string | undefined,
17
  include_subtasks: string | undefined,
18
  include_markdown_description: string | undefined,
19
  custom_fields: string | undefined,
20
) {
21
  const url = new URL(`https://api.clickup.com/api/v2/task/${task_id}`);
22
  for (const [k, v] of [
23
    ["team_id", team_id],
24
    ["include_subtasks", include_subtasks],
25
    ["include_markdown_description", include_markdown_description],
26
    ["custom_fields", custom_fields],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: auth.token,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.json();
44
}
45