0

Create customer search

by
Published Oct 17, 2025

Searches across customer data with criteria based on standard Object data and any custom attribute data for standard Objects, including Message, Conversation, and Company objects.

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 customer search
7
 * Searches across customer data with criteria based on standard Object data and any custom attribute data for standard Objects, including Message, Conversation, and Company objects.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  body: {
12
    searchHash?: string;
13
    queryContext?: string;
14
    includeDeleted?: false | true;
15
    timeZone?: string;
16
    and?: {} | {}[];
17
    or?: {} | {}[];
18
    not?: {} | {}[];
19
    sort?: {} | {}[];
20
    aggs?: {};
21
    fields?: {}[];
22
  },
23
) {
24
  const url = new URL(`https://api.kustomerapp.com/v1/customers/search`);
25

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