0

Proxies Create

by
Published Oct 17, 2025

Proxies Create

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

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