0

UpdateWorkweekConfig

by
Published Oct 17, 2025

Updates a `WorkweekConfig`.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * UpdateWorkweekConfig
7
 * Updates a `WorkweekConfig`.
8
 */
9
export async function main(
10
  auth: Square,
11
  id: string,
12
  body: {
13
    workweek_config: {
14
      id?: string;
15
      start_of_week: "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN";
16
      start_of_day_local_time: string;
17
      version?: number;
18
      created_at?: string;
19
      updated_at?: string;
20
    };
21
  },
22
) {
23
  const url = new URL(
24
    `https://connect.squareup.com/v2/labor/workweek-configs/${id}`,
25
  );
26

27
  const response = await fetch(url, {
28
    method: "PUT",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41