0

network-tokens

by
Published Oct 17, 2025

network-tokens

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
 * network-tokens
7
 * network-tokens
8
 */
9
export async function main(
10
  auth: Basistheory,
11
  body: {
12
    cardholder_info?: {
13
      address?: {
14
        city?: string;
15
        country_code?: string;
16
        line1?: string;
17
        line2?: string;
18
        line3?: string;
19
        postal_code?: string;
20
        state_code?: string;
21
      };
22
      name?: string;
23
    };
24
    containers?: string[];
25
    data?: {
26
      cvc?: string;
27
      expiration_month?: string;
28
      expiration_year?: string;
29
      number?: string;
30
    };
31
    merchant_id?: string;
32
  },
33
) {
34
  const url = new URL(`https://api.basistheory.com/connections/network-tokens`);
35

36
  const response = await fetch(url, {
37
    method: "POST",
38
    headers: {
39
      "Content-Type": "application/json",
40
      "BT-API-KEY": auth.apiKey,
41
    },
42
    body: JSON.stringify(body),
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50