0

UpdateJob

by
Published Oct 17, 2025

Updates the title or tip eligibility of a job. Changes to the title propagate to all `JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * UpdateJob
7
 * Updates the title or tip eligibility of a job. Changes to the title propagate to all
8
`JobAssignment`, `Shift`, and `TeamMemberWage` objects that reference the job ID. Changes to
9
tip eligibility propagate to all `TeamMemberWage` objects that reference the job ID.
10
 */
11
export async function main(
12
  auth: Square,
13
  job_id: string,
14
  body: {
15
    job: {
16
      id?: string;
17
      title?: string;
18
      is_tip_eligible?: false | true;
19
      created_at?: string;
20
      updated_at?: string;
21
      version?: number;
22
    };
23
  },
24
) {
25
  const url = new URL(
26
    `https://connect.squareup.com/v2/team-members/jobs/${job_id}`,
27
  );
28

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