0

Tokens Update

by
Published Oct 17, 2025

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

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