0

Send a message

by
Published Oct 17, 2025

This endpoint creates a top level message.

Script clickup Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Clickup = {
3
  token: string;
4
};
5
/**
6
 * Send a message
7
 * This endpoint creates a top level message.
8
 */
9
export async function main(
10
  auth: Clickup,
11
  workspace_id: string,
12
  channel_id: string,
13
  body: {
14
    assignee?: string;
15
    group_assignee?: string;
16
    triaged_action?: 1 | 2;
17
    triaged_object_id?: string;
18
    triaged_object_type?: number;
19
    type: "message" | "post";
20
    content: string;
21
    reactions?: { date: number; reaction: string; user_id: string }[];
22
    followers?: string[];
23
    content_format?: "text/md" | "text/plain";
24
    post_data?: { title: string; subtype: { id: string } };
25
  },
26
) {
27
  const url = new URL(
28
    `https://api.clickup.com/api/v3/workspaces/${workspace_id}/chat/channels/${channel_id}/messages`,
29
  );
30

31
  const response = await fetch(url, {
32
    method: "POST",
33
    headers: {
34
      "Content-Type": "application/json",
35
      Authorization: auth.token,
36
    },
37
    body: JSON.stringify(body),
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