//native
type Clickup = {
token: string;
};
/**
* Create Webhook
* Set up a webhook to monitor for events. We do not have a dedicated IP address for webhooks. We use our domain name and dynamic addressing.
*/
export async function main(
auth: Clickup,
team_id: string,
body: {
endpoint: string;
events: string[];
space_id?: number;
folder_id?: number;
list_id?: number;
task_id?: string;
},
) {
const url = new URL(`https://api.clickup.com/api/v2/team/${team_id}/webhook`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago