0

DeleteBookingCustomAttribute

by
Published Oct 17, 2025

Deletes a bookings custom attribute. To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope. To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope. For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus* or *Appointments Premium*.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * DeleteBookingCustomAttribute
7
 * Deletes a bookings custom attribute.
8

9
To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
10
To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
11

12
For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
13
or *Appointments Premium*.
14
 */
15
export async function main(auth: Square, booking_id: string, key: string) {
16
  const url = new URL(
17
    `https://connect.squareup.com/v2/bookings/${booking_id}/custom-attributes/${key}`,
18
  );
19

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