Creating a new Labor Model Rule

Each Deputy install does come with the ability for users to setup their own labor models within the UI, however it is possible to highly customise this and add your own labor models to apply to the shift generation process via the Deputy API.

URL
The URL to add a new labor model is as follows

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

Sample Payload

{
    "data": [
        {
          	"area": 1,
            "metric": "Sales",
            "metricValueType": "currency",
            "metricAmount": "10.00",
            "laborAmount": 1,
            "minLabor": 1,
            "maxLabor": 3,
            "coverage": 2,
            "steps": [
                {
                    "from": 11,
                    "to": 20,
                    "laborAmount": 2
                }
            ],
            "maxMetricAmount": 21,
            "timeframe": 1,
            "useBuffers": true,
            "buffers": {
                "open": {
                    "hours": 1,
                    "minutes": 0,
                    "direction": "before"
                },
                "close": {
                    "hours": 1,
                    "minutes": 0,
                    "direction": "after"
                },
              "subMetric":"forecast"
            },
        }
    ],
}

This example will add a new Labor Model Rule which is using the Range type of model as opposed to the linear model.

ElementData TypeInfo
areaIntegerThe id of the area the labor model should apply to
metricStringThe sales metric which is being applied to the labor model rule
metricValueTypeStringThis is either currency or unit and needs to match the type of metric that the Sales Metric uses in its data storage.
metricAmountIntegerThe initial metric upper limit amount to begin the labor model on. In this example the upper limit for the first range has been set to 10.00 so the initial range is 0-10.00.
minLaborIntegerThe minimum amount of staff for the initial range
maxLaborIntegerThe maximum amount of staff you are allowing under the labor model for the initial range.
coverageIntegerWhether
steps arrayArray with ObjectsThe steps array contains the objects which defines the ranges past the initial range.
steps - fromIntegerThe number where this new range begins.
steps - toIntegerThe number where this new range ends
steps - laborAmountIntegerThe amount of staff to put on under the labor model based on the defined range in the object.
maxMetricAmountIntegerThe maximum number the labor model should be calculated on as a metric
timeframeIntegerWhether the labor model should take into account the opening hours of the business or whether it should be considered that the business is always open.
useBuffersBoolean - true/falseWhen you set the labor model to take into account the opening hours of the business, you can include buffers of pre and post opening to be included in the labor model calculations.
buffersObjectThis object contains information about the buffers which are being defined for the labor model
openObjectThis Object contains information about what the buffer should be. In the example this has been set to include 1 hour before opening time in the labor model calcuations.
open - hoursIntegerThe number of hours to take into account in the buffer.
open - minutesIntegerThe number of minutes to take into account in the buffer.
close - directionStringWhich way this buffer is being set, before the opening time or after the closing time. In this example its before so this means its a before opening buffer time.
closeObjectThis Object contains information about what the closing buffer should be. In the example this has been set to 1 hour after closing time in the labor model calculations.
close - hoursIntegerThe number of hours to take into account in the buffer
close - minutesIntegerThe number of minutes to take into account in the buffer
close - directionStringWhich way this buffer is being set, before the opening time or after the closing time. In the example its after so this means its an after closing buffer time.
subMetricStringThis is either actual or forecast. This will determine whether actual figures from the metric or forecast measures from the metric will be used with the labor model.

Sample Response

{
    "success": true,
    "data": [
        {
            "id": "25",
            "area": 12,
            "metric": "Food",
            "metricValueType": "currency",
            "metricAmount": 10,
            "laborAmount": 1,
            "minLabor": 1,
            "maxLabor": 3,
            "coverage": 2,
            "steps": [
                {
                    "from": 11,
                    "to": 20,
                    "laborAmount": 2
                }
            ],
            "maxMetricAmount": 21,
            "timeframe": 1,
            "useBuffers": true,
            "buffers": {
                "open": {
                    "hours": 1,
                    "minutes": 0,
                    "direction": "before"
                },
                "close": {
                    "hours": 1,
                    "minutes": 0,
                    "direction": "after"
                }
            },
            "subMetric": "forecast"
        }
    ]
}

The response basically repeats the same information that was provided in the API request, which allows you to confirm the data has been set correctly.