0

Update note attributes by ID

by
Published Oct 17, 2025

Updates one or more note attibutes based on the unique note ID.

Script kustomer Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Kustomer = {
3
  apiKey: string;
4
};
5
/**
6
 * Update note attributes by ID
7
 * Updates one or more note attibutes based on the unique note ID.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  id: string,
12
  body: {
13
    conversation?: string;
14
    externalId?: string;
15
    body?: string;
16
    userMentions?: { user?: string; team?: string }[];
17
    deleted?: false | true;
18
    attachments?: {
19
      _id: string;
20
      name: string;
21
      contentType: string;
22
      contentLength: number;
23
      sourceId?: string;
24
    }[];
25
    createdAt?: string;
26
    modifiedAt?: string;
27
    updatedAt?: string;
28
    createdBy?: string;
29
    modifiedBy?: string;
30
    lang?: string;
31
  },
32
) {
33
  const url = new URL(`https://api.kustomerapp.com/v1/notes/${id}`);
34

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