0

DeleteMerchantCustomAttributeDefinition

by
Published Oct 17, 2025

Deletes a merchant-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account. Deleting a custom attribute definition also deletes the corresponding custom attribute from the merchant. Only the definition owner can delete a custom attribute definition.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * DeleteMerchantCustomAttributeDefinition
7
 * Deletes a merchant-related [custom attribute definition]($m/CustomAttributeDefinition) from a Square seller account.
8
Deleting a custom attribute definition also deletes the corresponding custom attribute from
9
the merchant.
10
Only the definition owner can delete a custom attribute definition.
11
 */
12
export async function main(auth: Square, key: string) {
13
  const url = new URL(
14
    `https://connect.squareup.com/v2/merchants/custom-attribute-definitions/${key}`,
15
  );
16

17
  const response = await fetch(url, {
18
    method: "DELETE",
19
    headers: {
20
      Authorization: "Bearer " + auth.token,
21
    },
22
    body: undefined,
23
  });
24
  if (!response.ok) {
25
    const text = await response.text();
26
    throw new Error(`${response.status} ${text}`);
27
  }
28
  return await response.json();
29
}
30