0

Install a Card

by
Published Oct 17, 2025

Installs a card by ID into specified contexts. 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
 * Install a Card
7
 * Installs a card by ID into specified contexts.
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(
21
    `https://api.kustomerapp.com/v1/cards/available/${id}/install`,
22
  );
23

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