Running a Labor Model in Deputy

It is possible using the Deputy API to remotely execute the start of a labor model calculation. To do this you will need to know the location you want to execute the labor model for. Once you have that follow the below guide.

URL

curl --POST 'https://{install}.{geo}.deputy.com/api/v2/labor-model/location/{locationid}/run

Within the body of the request, you need to include two unix time stamps. This will define the period you want the labor model to be run for.

{
    "start": 12345678,
    "end": 12345678
}

Once you execute the API request, the labor model will begin to run. This can take a significant amount of time and it is not an async API so please keep that in mind with your infrastructure requirements. When the model has complete, you will get a JSON summary of what it has produced.

{
    "success": true,
    "data": {
        "hours": 15,
        "minutes": 20,
        "start": "1630245600",
        "end": "1630850400",
        "staffByDay": [
            {
                "date": "2021-08-30T00:00:00Z",
                "staffByArea": [
                    {
                        "area": 1,
                        "hours": 15,
                        "minutes": 20
                    }
                ]
            }
        ]
    }
}

Element

Data Type

Info

success

Boolean true/false

If the model ran successfully this will be true. False if the model encounters an error

data

Object

This object contains information about the result of the labor model execution

hours

Integer

The total amount of required hours the labor model has calculated in the execution

minutes

Integer

The total amount of require minutes the labor model has calculated in the execution

start

String

The starting timestamp in unix time for the labor model

end

String

The ending timestamp in unix time for the labor model

staffByDay

Array

Contains an object entry for each date that was included in the labor model execution

staffByDay - area

Integer

The id of the area being referenced in this object

hours

Integer

The total amount of hours calculated for the area

minutes

Integer

The minutes within the total hours calculated for the area. For example if its 20 hours and minutes is 45, the total is 20 hours and 45 minutes.