0

Update instance settings

by
Published Apr 8, 2025

Updates the settings of an instance

Script clerk Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Clerk = {
3
  apiKey: string;
4
};
5
/**
6
 * Update instance settings
7
 * Updates the settings of an instance
8
 */
9
export async function main(
10
  auth: Clerk,
11
  body: {
12
    test_mode?: false | true;
13
    hibp?: false | true;
14
    enhanced_email_deliverability?: false | true;
15
    support_email?: string;
16
    clerk_js_version?: string;
17
    development_origin?: string;
18
    allowed_origins?: string[];
19
    cookieless_dev?: false | true;
20
    url_based_session_syncing?: false | true;
21
  },
22
) {
23
  const url = new URL(`https://api.clerk.com/v1/instance`);
24

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