0

Bulk create notes

by
Published Oct 17, 2025

Creates a bulk batch of notes. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.note.write|org.permission.note.create|

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Bulk create notes
7
 * Creates a bulk batch of notes.
8

9
Any one of the following roles is required for this endpoint:
10

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.user.note.write|org.permission.note.create|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  body: {
18
    id?: string;
19
    conversation: string;
20
    externalId?: string;
21
    body: string;
22
    userMentions?: { user?: string; team?: string }[];
23
    attachments?: {
24
      _id: string;
25
      name: string;
26
      contentType: string;
27
      contentLength: number;
28
      sourceId?: string;
29
    }[];
30
    createdAt?: string;
31
    modifiedAt?: string;
32
    createdBy?: string;
33
    modifiedBy?: string;
34
    importedAt?: string;
35
    lang?: string;
36
  }[],
37
) {
38
  const url = new URL(`https://api.kustomerapp.com/v1/notes/bulk`);
39

40
  const response = await fetch(url, {
41
    method: "POST",
42
    headers: {
43
      "Content-Type": "application/json",
44
      Authorization: "Bearer " + auth.apiKey,
45
    },
46
    body: JSON.stringify(body),
47
  });
48
  if (!response.ok) {
49
    const text = await response.text();
50
    throw new Error(`${response.status} ${text}`);
51
  }
52
  return await response.json();
53
}
54