Adding a new custom metric

Although users are able to add their own metrics via the Deputy UI, there may be times where you as a developer want to add metric types yourself, for a deeper integration experience. This is easy with the Deputy API.

Adding a sales metric allows users to break out sales data into more granular items. For example some customers may want to differentiate sales between front of house and the bar whilst other customers may want to specifically track food and beverage sales seperately.

To add a sales metric to Deputy you will need the following information:

Type - What type of sales metric you want to add, this is also generally the name. For example if you wanted to track food sales as a specific type of metric, you might call this Food
Label - This allows you to define what the metric should be displayed as in the UI. This means for example you could have a type called foodSales but define the label as Food. It is important to note that the label can be updated at any time in the Deputy UI, but the type cannot be once set.
ValueType - This is either unit or currency. The primary difference being the currency sign will not show in Deputy if the value type is unit.
Color - The color the metric will display in, in hex format.
Prediction - This allows you to determine the behaviour of Deputy with regards to automatic forecasting of the metric based on previously entered data.

The options are as follows:
ALLTIME - Uses data from the entire data set to produce forecasting
LAST2 - Uses the last 2 weeks of data to produce forecasting
LAST4 - Uses the last 4 weeks of data to produce forecasting
LAST6 - Uses the last 6 weeks of data to produce forecasting
LAST12 - Uses the last 12 weeks of data to produce forecasting
LASTY - Uses the same week last year to produce forecasting

ForecastMethod - can only be set to prediction
LevelOfDetailsFreq - This should be set to MINUTELY
LevelOfDetailsInterval - This can be 15 or 60 and determines whether the metric is broken down by hours or quarter of hours
Editable - Can be 0 or 1. 1 means the user is allowed to edit this metric in the Deputy UI.

Sample Payload

The URL for adding a new metric is:

curl --request POST --url 'https://{install}.{geo}.deputy.com/api/v1/supervise/metric/config/upsert'
{
    "Type": "Transactions",
    "Label": "Transactions",
    "ValueType": "unit",
    "Color": "#0091ea",
    "Prediction": "NOFORECAST",
    "ForecastMethod": "Prediction",
    "LevelOfDetailsFreq": "MINUTELY",
    "LevelOfDetailsInterval": 60,
    "Editable": 1
}

If the metric is successfully added to Deputy, you will get a response which includes information about all the metrics setup in the Deputy install. This will include your new metric.

{
    "success": true,
    "data": [
        {
            "Type": "Sales",
            "Label": "Sales",
            "ValueType": "currency",
            "Color": "#7cb5ec",
            "SortOrder": 1,
            "Series": 0,
            "Prediction": "ALLTIME",
            "Editable": 1,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Forecast",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Manager forecast",
                    "StateSortOrder": 2,
                    "UserMetric": true
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 3,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "LaborPercentage",
            "Label": "Labor %",
            "ValueType": "unit",
            "Color": "#f56a00",
            "SortOrder": 2,
            "Series": 5,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "plan",
                    "Label": "Scheduled",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 2,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "RequiredStaff",
            "Label": "Required Staff",
            "ValueType": "unit",
            "Color": "#8085e9",
            "SortOrder": 2,
            "Series": 4,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Required staff",
                    "StateSortOrder": 1,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": true,
            "IsByArea": false,
            "DataGroupBy": "maximum"
        },
        {
            "Type": "SalesPerHour",
            "Label": "Sales per hr",
            "ValueType": "currency",
            "Color": "#f56a00",
            "SortOrder": 2,
            "Series": 5,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Forecast",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Scheduled",
                    "StateSortOrder": 2,
                    "UserMetric": true
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 3,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "StaffNumber",
            "Label": "Staff",
            "ValueType": "unit",
            "Color": "#8085e9",
            "SortOrder": 2,
            "Series": 4,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Required staff",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Filled shifts",
                    "StateSortOrder": 2,
                    "UserMetric": false
                },
                {
                    "Id": "plan_all",
                    "Label": "All shifts",
                    "StateSortOrder": 5,
                    "UserMetric": false
                }
            ],
            "IsDeprecated": false,
            "IsByArea": true,
            "DataGroupBy": "maximum"
        },
        {
            "Type": "Food",
            "Label": "Food",
            "ValueType": "currency",
            "Color": "#2962ff",
            "SortOrder": 6,
            "Series": 6,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Forecast",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Manager forecast",
                    "StateSortOrder": 2,
                    "UserMetric": false
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 3,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "Transactions2",
            "Label": "Transactions2",
            "ValueType": "unit",
            "Color": "#0091ea",
            "SortOrder": 7,
            "Series": 7,
            "Prediction": "NOFORECAST",
            "Editable": 1,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Forecast",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Manager forecast",
                    "StateSortOrder": 2,
                    "UserMetric": true
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 3,
                    "UserMetric": true
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "ScheduledStaff",
            "Label": "Scheduled Staff",
            "ValueType": "unit",
            "Color": "#434348",
            "SortOrder": 1000,
            "Series": 1,
            "Prediction": "NONE",
            "Editable": 0,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "plan",
                    "Label": "Filled shifts",
                    "StateSortOrder": 2,
                    "UserMetric": false
                }
            ],
            "IsDeprecated": true,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "HighlightedStaff",
            "Label": "Highlighted Staff",
            "ValueType": "unit",
            "Color": "#079e88",
            "SortOrder": 1001,
            "Series": 2,
            "Prediction": "NONE",
            "Editable": 0,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "forecast",
                    "Label": "Forecast",
                    "StateSortOrder": 1,
                    "UserMetric": true
                },
                {
                    "Id": "plan",
                    "Label": "Manager forecast",
                    "StateSortOrder": 2,
                    "UserMetric": false
                },
                {
                    "Id": "actual",
                    "Label": "Actual",
                    "StateSortOrder": 3,
                    "UserMetric": false
                }
            ],
            "IsDeprecated": true,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "EstimatedCost",
            "Label": "Estimated Cost",
            "ValueType": "currency",
            "Color": "#f7a35c",
            "SortOrder": 1002,
            "Series": 3,
            "Prediction": "NONE",
            "Editable": 0,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "plan",
                    "Label": "Scheduled wages",
                    "StateSortOrder": 2,
                    "UserMetric": false
                }
            ],
            "IsDeprecated": true,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "Wage",
            "Label": "Wages",
            "ValueType": "currency",
            "Color": "#f7a35c",
            "SortOrder": 1002,
            "Series": 3,
            "Prediction": "NONE",
            "Editable": 0,
            "ForecastMethod": "Prediction",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "plan",
                    "Label": "Scheduled wages",
                    "StateSortOrder": 2,
                    "UserMetric": false
                },
                {
                    "Id": "actual",
                    "Label": "Actual wages",
                    "StateSortOrder": 3,
                    "UserMetric": false
                },
                {
                    "Id": "budget",
                    "Label": "Budgeted wages",
                    "StateSortOrder": 4,
                    "UserMetric": true,
                    "Period": "weekly",
                    "Active": false
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        },
        {
            "Type": "StaffHour",
            "Label": "Staff",
            "ValueType": "unit",
            "Color": "#fc03df",
            "SortOrder": 2001,
            "Series": 2001,
            "Prediction": "",
            "Editable": false,
            "ForecastMethod": "",
            "SmartForecast": {},
            "LevelOfDetailsFreq": "MINUTELY",
            "LevelOfDetailsInterval": 60,
            "VisibleInSummary": true,
            "AvailableStates": [
                {
                    "Id": "plan",
                    "Label": "Filled shifts",
                    "StateSortOrder": 2,
                    "UserMetric": false
                },
                {
                    "Id": "actual",
                    "Label": "Actual hours",
                    "StateSortOrder": 3,
                    "UserMetric": false
                },
                {
                    "Id": "budget",
                    "Label": "Budgeted hours",
                    "StateSortOrder": 4,
                    "UserMetric": true,
                    "Period": "weekly",
                    "Active": false
                },
                {
                    "Id": "forecast",
                    "Label": "Required staff",
                    "StateSortOrder": 1,
                    "UserMetric": false
                },
                {
                    "Id": "plan_all",
                    "Label": "All shifts",
                    "StateSortOrder": 5,
                    "UserMetric": false
                }
            ],
            "IsDeprecated": false,
            "IsByArea": false,
            "DataGroupBy": null
        }
    ]
}