0

Update specific user setting

by
Published Oct 17, 2025

Update settings for a specific user.

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 specific user setting
7
 * Update settings for a specific user.
8
 */
9
export async function main(
10
  auth: Kustomer,
11
  id: string,
12
  app: string,
13
  category: string,
14
  name: string,
15
) {
16
  const url = new URL(
17
    `https://api.kustomerapp.com/v1/users/${id}/settings/${app}/${category}/${name}`,
18
  );
19

20
  const response = await fetch(url, {
21
    method: "PUT",
22
    headers: {
23
      Authorization: "Bearer " + auth.apiKey,
24
    },
25
    body: undefined,
26
  });
27
  if (!response.ok) {
28
    const text = await response.text();
29
    throw new Error(`${response.status} ${text}`);
30
  }
31
  return await response.json();
32
}
33