Bulk Update Opening Hours
This page describes the process of setting the opening hours for a large number of display units using Broadsign Control API via REST.
To bulk update opening hours, we update a day part using PUT and the /day_part/v5 method.
The key to updating opening hours in bulk is the minute_mask parameter. In this section, we describe how to calculate the values for the minute_mask string.
You must encode the field in minutes per week. Each range represents a contiguous block of time, representing each opening hour period.
Count every minute in a week from 0 to 10079.
Keep in mind the following:
- Minute 0 starts at 12:00 AM on Monday
- There are 1440 minutes per day, 10080 minutes per week.
- The last addressable minute in a week is 10079. It represents the minute from 23:59:00 to 24:00:00 on Sunday in a given week.
- The end of a minute range includes the last minute it describes. For example, to end at exactly 5 PM:
- Entering 1019 is correct because it includes the minute from 4:59:00 to 5:00:00.
- Entering 1020 is incorrect because it includes the minute from 5:00:00 to 5:01:00. Therefore, you would need to subtract 1 minute from the end of a range to be accurate.
- You must separate each range with a semi-colon.
To represent opening hours that are 9 AM to 5 PM every day of the week, the minute_mask would be:
Day of the Week | Hours | Encoding |
---|---|---|
Monday | 9 AM - 5 PM | 540-1019 |
Tuesday | 9 AM - 5 PM | 1980-2459 |
Wednesday | 9 AM - 5 PM | 3420-3899 |
Thursday | 9 AM - 5 PM | 4860-5339 |
Friday | 9 AM - 5 PM | 6300-6779 |
Saturday | 9 AM - 5 PM | 7740-8219 |
Sunday | 9 AM - 5 PM | 9180-9659 |
We calculated the encoding in this way:
9 AM on Monday = 9 * 60 minutes = 540
5 PM on Monday = (9 * 60 minutes) + [(8 * 60 mins) - 1] = 1019
9 AM on Tuesday = 33 * 60 mins = 1980
5 PM on Tuesday = (33 * 60 mins) + [(8 * 60 mins) - 1] = 2459
9 AM on Wednesday = (57 * 60 mins) = 3420
5 PM on Wednesday = (57 * 60 mins) + [(8 * 60 mins) - 1] = 3899
You would enter the string in the minute_mask parameter using the following format:
540-1019;1980-2459;3420-3899;4860-5339;6300-6779;7740-8219;9180-9659
In our sample request, we will use the ID# of the day part (id) we created in Add Display Units: Step 2 - Add a Day Part.
Note: The ID#s we use in these samples are for illustration purposes. They are invalid. Be sure to use your own ID#s for your integrations. Also, in our examples, we use the api-sandbox endpoint and HTTP token.
curl -X PUT \
https://api-sandbox.broadsign.com:10889/rest/day_part/v5 \
-H 'authorization: Bearer 3b24e003152ffcd240f0260d1df77ba6' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"id": 3233,
"day_mask": 127,
"domain_id": 123456789,
"start_date": "2017-10-31",
"end_date": "2018-10-31",
"start_time": "00:00:00",
"end_time": "23:59:59",
"impressions_per_hour": -1,
"minute_mask": "0-59;1440-1499;2880-2939;4320-4379;5760-5819;7200-7259;8640-8699",
"name": "day_part_modified_using_rest_api",
"virtual_start_date": "1756-01-01",
"virtual_end_date": "8000-12-31",
"weight": 2,
"active": true
}'