Build with the Labor API

Use the Labor API to record shifts worked by team members, including the shift's start and end times, job title, pay rate, and breaks. Shift records can be used for payroll, labor cost reporting, and overtime management and to inform scheduling decisions.

Applies to: Labor API | Team API | Locations API

Link to section

Overview

Learn how to start a shift with an assigned job title and pay rate for a team member using the following steps:

  1. Get the ID of the shift location.
  2. Get the ID of the team member.
  3. Verify that the team member doesn't already have an open shift.
  4. Get wage information for the job to be done on the shift.
  5. Create a new shift with the start time and information you collected. This step sets the shift status to OPEN.

This topic also shows how to end the shift using the following steps:

  1. Get the open shift.
  2. Update the shift with the end time. This step sets the shift status to CLOSED.
Link to section

Before you start

  • You need a valid access token - The steps in this topic call Square APIs in the Square Sandbox, so you can use your Sandbox access token in the requests. Square recommends testing with Sandbox credentials when possible.

    Applications that use OAuth access tokens in the production environment require the MERCHANT_PROFILE_READ, EMPLOYEES_READ, TIMECARDS_READ, and TIMECARDS_WRITE permissions to perform these steps. When calling Square APIs in the production environment, change the base URL to https://connect.squareup.com.

  • You need a team member with an assigned wage setting - To create a shift, you must provide the ID of a team member who's active at the shift location. If needed, you can create and set up a team member using the Seller Dashboard or Team API.

Link to section

Start the shift

Link to section

Step 1: Get the shift location

If needed, you can call ListLocations and then copy the ID of the shift location.

List locations

Link to section

Step 2: Get the team member

Call SearchTeamMembers to get active team members for a location using the location_ids and status query filters. Then, copy the ID of the team member who's working the shift.

Search team members

The response returns an array of TeamMember objects representing the active team members for the specified location.

The limit in the example request defines the page size of responses. The cursor in the example response is used to get the next page of results. For more information, see Pagination.

Link to section

Step 3: Get the team member wage types

Call ListTeamMemberWages using the team_member_id query filter to get available wage types for the team member. A team member might have multiple wage types, so you need to find the title and pay rate for the job that the team member is performing for the shift.

List team member wages

The response returns an array of TeamMemberWage objects associated with the team member.

{ "team_member_wages": [ { "id": "iVLHz3adFg6kXJESFpwBvqiH", "team_member_id": "-3oZQKPKVk6gUXU_V5Qa", "title": "Manager", "hourly_rate": { "amount": 2500, "currency": "USD" }, "job_id": "god1UVkdSodJ1F4PCzoA8y6d", "tip_eligible": true } ] }

The first team member wage type in the array represents the team member's primary job.

Link to section

Step 4: Check for an open shift record

Call SearchShifts to search for an open shift for the team member using the status, team_member_ids, and location_ids query filters. A new shift cannot be created for a team member until the previous shift is ended.

Search shifts

This filter always returns zero or one Shift object because a team member can have a maximum of one shift with an OPEN status.

If the team member doesn't have an open shift, the response returns an empty object.

{}
Link to section

Step 5: Build a shift object

Call CreateShift to create a new shift using the location ID and team member ID you copied in previous steps. For the wage field, you can provide the title, pay rate, and tip eligibility from the wage type that corresponds to the job to be done on the shift. The start_at field can be set to local time or GMT. If you use GMT, Square calculates the local time based on the shift location.

Create shift

Important

To record labor cost, you must include the wage field with an hourly_rate. Otherwise, the shift record has no associated pay amount. The job title and pay rate from the team member's primary job aren't used by default.

Link to section

End the shift

Link to section

Step 1: Get the shift to close

Call SearchShifts to get the open shift for the team member using the status, team_member_ids, and location_ids query filters.

Search shifts

The response should return the Shift object you created in the previous section.

Link to section

Verify that any breaks are ended

Inspect the shift for a breaks field, which is added to a shift if the team member took any breaks. If you're following the steps in this topic, you shouldn't see this field because no breaks were taken.

For shifts that do include the breaks field, confirm that each break contains an end_at field with a valid timestamp. If the shift has an open break, you need to end the break before you can end the shift.

Link to section

Step 2: Update the shift

To close a shift, call UpdateShift and add an end_at field to the open shift.

Update shift

The response returns the updated version of the shift with a CLOSED status and an incremented version number.

Note that you can update the wage or declared_cash_tip_money field for the shift at any time.

Link to section

Next steps

Link to section

See also