Find problems and solutions related to opening shifts, adding breaks, and closing shifts using the Labor API.
I cannot create a new open Shift for a team member
Square's error response says that the new Shift
overlaps other shifts for a team member who has no other shifts on this day.
Cause
The team member has an open shift from a previous day that needs to be closed.
Solution
Find the previous shift and verify that the end_at
field is null or missing. Close the shift by setting an end_at
value and sending an UpdateShift request for the shift to be closed.
When checking for an open shift, use code like the following example and provide the ID of the team member associated with the open shift:
The response to the shift search request is an empty object if the team member doesn't have an OPEN
shift:
My createShift call returns the shift I opened in a previous create operation
Cause
A new idempotency key wasn't generated for this operation.
Solution
Generate a new idempotency key and retry the operation.
On closing a shift, the API was unable to service the request
There are no overlapping shifts for the employee and the body of the close request is formed correctly.
Cause
The Shift
to be closed has an open Break.
Solution
Iterate the Break
objects in the shift. When a Break
with no end_at
property is found, set the property to the current time.
My shift query returns too many shifts
Cause
A filter field is invalid (REST only) or an enum value is invalid (REST and SDK). When the search endpoint receives a filter field or enum value it doesn't recognize, the related filter criteria is ignored.
Solution
Enums and JSON field names are case-sensitive. Confirm that the field name is correct and lowercase (REST) and the provided enum values match their definition in the Technical Reference.