0

Bulk batch update notes

by
Published Oct 17, 2025

Updates a bulk batch of notes. Use the `ids` query param to update multiple notes in bulk with the same data. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.note.write|org.permission.note.update|

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 batch update notes
7
 * Updates a bulk batch of notes.
8

9
Use the `ids` query param to update multiple notes in bulk with the same data.
10

11
Any one of the following roles is required for this endpoint:
12

13
|Legacy Role|Equivalent Permission Set Role|
14
|-----|--------|
15
|org.user.note.write|org.permission.note.update|
16
 */
17
export async function main(
18
  auth: Kustomer,
19
  ids: string | undefined,
20
  body: {
21
    id: string;
22
    conversation?: string;
23
    externalId?: string;
24
    body?: string;
25
    userMentions?: { user?: string; team?: string }[];
26
    deleted?: false | true;
27
    attachments?: {
28
      _id: string;
29
      name: string;
30
      contentType: string;
31
      contentLength: number;
32
      sourceId?: string;
33
    }[];
34
    createdAt?: string;
35
    modifiedAt?: string;
36
    updatedAt?: string;
37
    createdBy?: string;
38
    modifiedBy?: string;
39
    lang?: string;
40
  }[],
41
) {
42
  const url = new URL(`https://api.kustomerapp.com/v1/notes/bulk`);
43
  for (const [k, v] of [["ids", ids]]) {
44
    if (v !== undefined && v !== "" && k !== undefined) {
45
      url.searchParams.append(k, v);
46
    }
47
  }
48
  const response = await fetch(url, {
49
    method: "PUT",
50
    headers: {
51
      "Content-Type": "application/json",
52
      Authorization: "Bearer " + auth.apiKey,
53
    },
54
    body: JSON.stringify(body),
55
  });
56
  if (!response.ok) {
57
    const text = await response.text();
58
    throw new Error(`${response.status} ${text}`);
59
  }
60
  return await response.json();
61
}
62