Labor API

Troubleshoot problems with the Labor API

Web
Employees API
Labor API
cURL (Command Line)

Labor API problems
Permalink Get a link to this section

Find problems and solutions related to opening, adding breaks, and closing shifts using the Labor API.

I cannot create a new open Shift for an employee
Permalink Get a link to this section

Square's error response says that the new Shift overlaps other Shifts for an employee who has no other shifts on this day.

Cause

The employee 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 value and sending an UpdateShift request for the shift to be closed.

curl https://connect.squareupstaging.com/v2/labor/shifts/search \
 -H 'Content-Type: application/json'                       \
 -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'     \
 -d '{
    "query": {
        "filter": {
            "status": "OPEN", 
            "employee_id": ["AN_EMPLOYEE_ID"]
        }
    }
}'

The response to the shift search request is an empty object if the employee does not have an OPEN shift.

{}

My createShift call returns the shift I opened in a previous create operation.
Permalink Get a link to this section

Cause

A new idempotency key was not 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
Permalink Get a link to this section

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.
Permalink Get a link to this section

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 does not 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.