0

BulkUpsertBookingCustomAttributes

by
Published Oct 17, 2025

Bulk upserts bookings custom attributes. 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
 * BulkUpsertBookingCustomAttributes
7
 * Bulk upserts bookings custom attributes.
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, body: { values: {} }) {
16
  const url = new URL(
17
    `https://connect.squareup.com/v2/bookings/custom-attributes/bulk-upsert`,
18
  );
19

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