0

Bulk create conversations

by
Published Oct 17, 2025

Create conversations in bulk. Any one of the following roles is required for this endpoint: |Legacy Role|Equivalent Permission Set Role| |-----|--------| |org.user.conversation.write|org.permission.conversation.create|

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 create conversations
7
 * Create conversations in bulk.
8

9
Any one of the following roles is required for this endpoint:
10

11
|Legacy Role|Equivalent Permission Set Role|
12
|-----|--------|
13
|org.user.conversation.write|org.permission.conversation.create|
14
 */
15
export async function main(
16
  auth: Kustomer,
17
  body: {
18
    id?: string;
19
    customer: string;
20
    externalId?: string;
21
    name?: string;
22
    status?: "open" | "done";
23
    priority?: number;
24
    createdAt?: string;
25
    importedAt?: string;
26
    direction?: "in" | "out";
27
    replyChannel?: string;
28
    tags?: string[];
29
    assignedUsers?: string[];
30
    assignedTeams?: string[];
31
    custom?: {};
32
    defaultLang?: string;
33
    queue?: {} | {};
34
  }[],
35
) {
36
  const url = new URL(`https://api.kustomerapp.com/v1/conversations/bulk`);
37

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