0

Add Guest To Task

by
Published Oct 17, 2025

Share a task with a guest. \ \ ***Note:** This endpoint is only available to Workspaces on our [Enterprise Plan](https://clickup.com/pricing).*

Script clickup Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Add Guest To Task
7
 * Share a task with a guest. \
8
 \
9
***Note:** This endpoint is only available to Workspaces on our [Enterprise Plan](https://clickup.com/pricing).*
10
 */
11
export async function main(
12
  auth: Clickup,
13
  task_id: string,
14
  guest_id: string,
15
  include_shared: string | undefined,
16
  custom_task_ids: string | undefined,
17
  team_id: string | undefined,
18
  body: { permission_level: string },
19
) {
20
  const url = new URL(
21
    `https://api.clickup.com/api/v2/task/${task_id}/guest/${guest_id}`,
22
  );
23
  for (const [k, v] of [
24
    ["include_shared", include_shared],
25
    ["custom_task_ids", custom_task_ids],
26
    ["team_id", team_id],
27
  ]) {
28
    if (v !== undefined && v !== "" && k !== undefined) {
29
      url.searchParams.append(k, v);
30
    }
31
  }
32
  const response = await fetch(url, {
33
    method: "POST",
34
    headers: {
35
      "Content-Type": "application/json",
36
      Authorization: auth.token,
37
    },
38
    body: JSON.stringify(body),
39
  });
40
  if (!response.ok) {
41
    const text = await response.text();
42
    throw new Error(`${response.status} ${text}`);
43
  }
44
  return await response.json();
45
}
46