0

Add or edit a credit card

by
Published Oct 17, 2025

__Deprecated__ Please run [Add a payment method](https://techdocs.akamai.com/linode-api/reference/post-payment-method). Adds a credit card Payment Method to your account and sets it as the default method. > --- - __OAuth scopes__. ``` account:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Add or edit a credit card
7
 * __Deprecated__ Please run [Add a payment method](https://techdocs.akamai.com/linode-api/reference/post-payment-method).
8

9
Adds a credit card Payment Method to your account and sets it as the default method.
10

11

12
>
13

14
---
15

16

17
- __OAuth scopes__.
18

19
    ```
20
    account:read_write
21
    ```
22

23
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
24
 */
25
export async function main(
26
  auth: Linode,
27
  apiVersion: "v4" | "v4beta",
28
  body: {
29
    card_number: string;
30
    cvv: string;
31
    expiry_month: number;
32
    expiry_year: number;
33
  },
34
) {
35
  const url = new URL(
36
    `https://api.linode.com/${apiVersion}/account/credit-card`,
37
  );
38

39
  const response = await fetch(url, {
40
    method: "POST",
41
    headers: {
42
      "Content-Type": "application/json",
43
      Authorization: "Bearer " + auth.token,
44
    },
45
    body: JSON.stringify(body),
46
  });
47
  if (!response.ok) {
48
    const text = await response.text();
49
    throw new Error(`${response.status} ${text}`);
50
  }
51
  return await response.json();
52
}
53