0

Create event

by
Published Oct 17, 2025

Create a new event.

Script holded Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Holded = {
3
  apiKey: string;
4
};
5
/**
6
 * Create event
7
 * Create a new event.
8
 */
9
export async function main(
10
  auth: Holded,
11
  body: {
12
    name?: string;
13
    contactId?: string;
14
    contactName?: string;
15
    kind?: string;
16
    desc?: string;
17
    startDate?: number;
18
    duration?: number;
19
    status?: number;
20
    tags?: string[];
21
    locationDesc?: string;
22
    leadId?: string;
23
    funnelId?: string;
24
    userId?: string;
25
  },
26
) {
27
  const url = new URL(`https://api.holded.com/api/crm/v1/events`);
28

29
  const response = await fetch(url, {
30
    method: "POST",
31
    headers: {
32
      "Content-Type": "application/json",
33
      key: auth.apiKey,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43