0

Update a Card

by
Published Oct 17, 2025

Updates card attributes. Valid Context Values are: - customer - conversation - company - kobject._yourObjectName_

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 a Card
7
 * Updates card attributes.
8

9
Valid Context Values are:
10
 - customer
11
 - conversation
12
 - company
13
 - kobject._yourObjectName_
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  id: string,
18
  body: { contexts?: string[] },
19
) {
20
  const url = new URL(`https://api.kustomerapp.com/v1/cards/${id}`);
21

22
  const response = await fetch(url, {
23
    method: "PUT",
24
    headers: {
25
      "Content-Type": "application/json",
26
      Authorization: "Bearer " + auth.apiKey,
27
    },
28
    body: JSON.stringify(body),
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.json();
35
}
36