0

Create a Card

by
Published Oct 17, 2025

Adds a custom card to make available for installation. 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
 * Create a Card
7
 * Adds a custom card to make available for installation.
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
  body: {
18
    app?: string;
19
    name: string;
20
    description: string;
21
    url: string;
22
    contexts: string[];
23
  },
24
) {
25
  const url = new URL(`https://api.kustomerapp.com/v1/cards/available`);
26

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