0

CreateJob

by
Published Oct 17, 2025

Creates a job in a seller account. A job defines a title and tip eligibility. Note that compensation is defined in a [job assignment]($m/JobAssignment) in a team member's wage setting.

Script square Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Square = {
3
  token: string;
4
};
5
/**
6
 * CreateJob
7
 * Creates a job in a seller account. A job defines a title and tip eligibility. Note that
8
compensation is defined in a [job assignment]($m/JobAssignment) in a team member's wage setting.
9
 */
10
export async function main(
11
  auth: Square,
12
  body: {
13
    job: {
14
      id?: string;
15
      title?: string;
16
      is_tip_eligible?: false | true;
17
      created_at?: string;
18
      updated_at?: string;
19
      version?: number;
20
    };
21
    idempotency_key: string;
22
  },
23
) {
24
  const url = new URL(`https://connect.squareup.com/v2/team-members/jobs`);
25

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