Delete accounts account persons person

Deletes an existing person’s relationship to the account’s legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.

Script stripe Verified

by hugo697 · 10/30/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 368 days ago
1
type Stripe = {
2
  token: string;
3
};
4
/**
5
 * Delete accounts account persons person
6
 * Deletes an existing person’s relationship to the account’s legal entity. Any person with a relationship for an account can be deleted through the API, except if the person is the account_opener. If your integration is using the executive parameter, you cannot delete the only verified executive on file.
7
 */
8
export async function main(auth: Stripe, account: string, person: string) {
9
  const url = new URL(
10
    `https://api.stripe.com/v1/accounts/${account}/persons/${person}`
11
  );
12

13
  const response = await fetch(url, {
14
    method: "DELETE",
15
    headers: {
16
      "Content-Type": "application/x-www-form-urlencoded",
17
      Authorization: "Bearer " + auth.token,
18
    },
19
    body: undefined,
20
  });
21
  if (!response.ok) {
22
    const text = await response.text();
23
    throw new Error(`${response.status} ${text}`);
24
  }
25
  return await response.json();
26
}
27