`get_shifts` api return 404

I’m trying to get shift data of the labor using the python sdk, but I get this error:

{'errors': [{'code': 'NOT_FOUND',
   'detail': 'The requested resource could not be found.',
   'field': 'id',
   'category': 'INVALID_REQUEST_ERROR'}]}

This is the code that I’m trying to run:

import uuid
myuuid = uuid.uuid4()
shifts = squareClient.labor.get_shift(myuuid).body

Note 1: Client data is fine and I can retrieve data for other sections (bookings for example) without any problem.
Note 2: I tried the api explorer of Square, and even in there I get the 404 error. (GET /v2/labor/shifts/{id} - Square API Explorer)

What’s your application ID and the shift_id your trying to call the API with? :slightly_smiling_face:

Thanks for responding. I’m not sure what you mean by “application ID” and “Shift ID”. In docs there is no mention of these values and only input for get_shift method is a UUID which I generate automatically with a python package (as intended in docs, for example 60fc4f4b-ba92-40dc-aed9-5820b2dc5736). Would you elaborate on the matter please?

A shift that’s returned by the Labor API will look like this:

{
    "shift": {
        "id": "DC271E2YD609S",
        "employee_id": "A6mpnApGj4jETONcwCKz",
        "location_id": "3Z4V4WHQK64X9",
        "timezone": "America/Los_Angeles",
        "start_at": "2023-12-12T04:00:00-08:00",
        "end_at": "2023-12-12T10:56:00-08:00",
        "wage": {
            "title": "Manager",
            "hourly_rate": {
                "amount": 2500,
                "currency": "USD"
            },
            "job_id": "t5mP1TBHXvx4NivxntXwzTwV"
        },
        "status": "CLOSED",
        "version": 2,
        "created_at": "2023-12-12T17:21:45-08:00",
        "updated_at": "2023-12-12T17:30:51-08:00",
        "team_member_id": "A6mpnApGj4jETONcwCKz"
    }
}

The ID the endpoint GetShift is expecting looks like this DC271E2YD609S which is the ID of the shift.

The application ID can be found in your Developer Dashboard.

  1. Open the Developer Dashboard.
  2. Open the application and choose the Credentials page.
  3. Copy the Application ID. :slightly_smiling_face:

I thought that the API returns the list of all shifts (from all of staff) inside my account. Which API gives me the list of shift_ids? Where can I access them?
my app id is: sq0idp-MfWvxM5gJMsK5nQLQE_nHw

You’ll need to use SearchShifts. You can call it with or without a filter to get the shifts for employees. :slightly_smiling_face:

Yes I’ve tested that but unfortunately it returns an empty object ({}). I want to see the working hours of my staff and I can’t. I have two staff members defined in my Square dashboard.

body = {
    'limit': 100
}
squareClient.labor.search_shifts(body).body

PS: I’ve had forgotten to define shifts in dashboard. Thanks for helping!

Glad to hear you got it working as expected. :slightly_smiling_face: