0

Proxies Update

by
Published Oct 17, 2025

Proxies Update

Script basis_theory Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Basistheory = {
3
  apiKey: string;
4
};
5
/**
6
 * Proxies Update
7
 * Proxies Update
8
 */
9
export async function main(
10
  auth: Basistheory,
11
  id: string,
12
  body: {
13
    application?: {
14
      created_at?: string;
15
      created_by?: string;
16
      id?: string;
17
      key?: string;
18
      keys?: {
19
        created_at?: string;
20
        created_by?: string;
21
        id?: string;
22
        key?: string;
23
        version?: string;
24
      }[];
25
      modified_at?: string;
26
      modified_by?: string;
27
      name?: string;
28
      permissions?: string[];
29
      rules?: {
30
        conditions?: {
31
          attribute?: string;
32
          operator?: string;
33
          value?: string;
34
        }[];
35
        container?: string;
36
        description?: string;
37
        permissions?: string[];
38
        priority?: string;
39
        transform?: string;
40
      }[];
41
      tenant_id?: string;
42
      type?: string;
43
    };
44
    configuration?: { commodoc?: string };
45
    destination_url?: string;
46
    name?: string;
47
    request_reactor_id?: string;
48
    request_transform?: {
49
      code?: string;
50
      expression?: string;
51
      matcher?: string;
52
      replacement?: string;
53
      type?: string;
54
    };
55
    require_auth?: string;
56
    response_reactor_id?: string;
57
    response_transform?: {
58
      code?: string;
59
      expression?: string;
60
      matcher?: string;
61
      replacement?: string;
62
      type?: string;
63
    };
64
  },
65
) {
66
  const url = new URL(`https://api.basistheory.com/proxies/${id}`);
67

68
  const response = await fetch(url, {
69
    method: "PUT",
70
    headers: {
71
      "Content-Type": "application/json",
72
      "BT-API-KEY": auth.apiKey,
73
    },
74
    body: JSON.stringify(body),
75
  });
76
  if (!response.ok) {
77
    const text = await response.text();
78
    throw new Error(`${response.status} ${text}`);
79
  }
80
  return await response.json();
81
}
82