0

Tokens Create

by
Published Oct 17, 2025

Tokens 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
 * Tokens Create
7
 * Tokens Create
8
 */
9
export async function main(
10
  auth: Basistheory,
11
  body: {
12
    containers?: string[];
13
    data?: { nullable?: false | true };
14
    deduplicate_token?: string;
15
    expires_at?: string;
16
    fingerprint_expression?: string;
17
    id?: string;
18
    mask?: { nullable?: false | true };
19
    metadata?: { laboris_aa?: string };
20
    privacy?: {
21
      classification?: string;
22
      impact_level?: string;
23
      restriction_policy?: string;
24
    };
25
    search_indexes?: string[];
26
    token_intent_id?: string;
27
    type?: string;
28
  },
29
) {
30
  const url = new URL(`https://api.basistheory.com/tokens`);
31

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