Skip to main content

Resolve shop-day ranges for the company

POST 

/shop-days

Resolves date-range presets, explicit shop-day ranges, and instants against the company's time zone and shop-day start. Each day opens at the shop-day start in force on that day, as a wall-clock time in the company's time zone, so ranges stay aligned across daylight saving changes and changes to the shop-day start.

A shop day that starts before midnight is named by the date whose midnight it precedes.

Ranges are half-open: start is included and end is excluded. startDay and endDay are the first and last shop days of the range, inclusive.

Presets:

  • today, yesterday
  • last7Days, last30Days, last90Days: today and the prior N−1 shop days, ending at the end of today
  • lastWeek, lastMonth, lastYear: the previous complete week, month, or year
  • last2Weeks: last week and this one, ending at the start of next week
  • weekToDate, monthToDate, quarterToDate, yearToDate: the start of the current unit to the end of today

Weeks start on the company's configured first day of the week, Monday unless configured otherwise.

Authentication: a signed-in user's token, or an API key or app token with the reporting or user scope. A token without either scope gets a 403.

Instants (instants and at) need an explicit zone, Z or ±hh:mm up to ±14:00, and instants and days must fall in the years 1900 to 2200 (an instant as a UTC instant).

A 400 reports the first problem found as the single entry in errors[], with field set (e.g. presets[0], days[1].endDay) and one of these codes:

  • UnknownKey: a top-level request key other than presets, days, instants or at
  • UnknownPreset: a preset name that isn't one of the 13 presets
  • TooMany: a list longer than 100 entries
  • InvalidType: the body is an array, a list isn't an array, or a preset isn't a string
  • InvalidDay: a startDay or endDay that isn't a yyyy-MM-dd date in 1900–2200
  • InvalidRange: an endDay before its startDay
  • InvalidDate: an instant or at that isn't a zoned ISO 8601 date-time in 1900–2200

A body that isn't valid JSON, or is a bare JSON string, number or null, gets 400 { "message": "Problem parsing JSON" } without errors[].

Request​

Responses​

The resolved ranges and shop days, in request order