> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # UpdateBusinessSchedule # Package: siteProperties # Namespace: SitePropertiesV4 # Method link: https://dev.wix.com/docs/api-reference/business-management/site-properties/properties/update-business-schedule.md ## Permission Scopes: Manage Business Schedule: SCOPE.DC-SITEPROP.MANAGE-BUSINESS-SCHEDULE ## Introduction Updates a site's business schedule. > **Note:** This method overwrites the current business schedule. `businessSchedule` is an array, so it must be written in its entirety. Therefore, you must modify the existing array and specify it in the API call. --- ## REST API ### Schema ``` Method: updateBusinessSchedule Description: Updates a site's business schedule. > **Note:** This method overwrites the current business schedule. `businessSchedule` is an array, so it must be written in its entirety. Therefore, you must modify the existing array and specify it in the API call. URL: https://www.wixapis.com/site-properties/v4/properties/business-schedule Method: POST Method parameters: param name: businessSchedule | type: BusinessSchedule | description: Business schedule. Regular and exceptional time periods when the business is open or the service is available. - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." Return type: UpdateBusinessScheduleResponse EMPTY-OBJECT {} Possible Errors: HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site. HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions. ``` ### Examples ### Update site business schedule ```curl curl -X POST \ 'https://www.wixapis.com/site-properties/v4/properties/business-schedule' -H 'Content-Type: application/json' \ -H 'Authorization: ' \ --data-binary '{ "businessSchedule": { "periods": [ { "openDay": "MONDAY", "openTime": "10:20", "closeDay": "MONDAY", "closeTime": "23:00" }, { "openDay": "TUESDAY", "openTime": "10:20", "closeDay": "TUESDAY", "closeTime": "23:00" } ], "specialHourPeriod": [ { "startDate": "2023-12-25T00:00", "endDate": "2024-01-01T24:00", "isClosed": "true", "comment": "Closed for Christmas-New Year break." }, { "startDate": "2024-07-04T00:00", "endDate": "2024-07-04T24:00", "isClosed": "true", "comment": "Closed for Independence Day." } ] } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.siteProperties.SitePropertiesV4.updateBusinessSchedule(businessSchedule) Description: Updates a site's business schedule. > **Note:** This method overwrites the current business schedule. `businessSchedule` is an array, so it must be written in its entirety. Therefore, you must modify the existing array and specify it in the API call. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: businessSchedule Method parameters: param name: businessSchedule | type: BusinessSchedule | description: Business schedule. Regular and exceptional time periods when the business is open or the service is available. | required: true - name: periods | type: array | description: Weekly recurring time periods when the business is regularly open or the service is available. Limited to 100 time periods. - name: openDay | type: DayOfWeek | description: Day of the week the period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time the period starts in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. - name: closeDay | type: DayOfWeek | description: Day of the week the period ends on. - name: closeTime | type: string | description: Time the period ends in 24-hour [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) extended format. Valid values are `00:00` to `24:00`, where `24:00` represents midnight at the end of the specified day. __Note:__ If `openDay` and `closeDay` specify the same day of the week `closeTime` must be later than `openTime`. - name: specialHourPeriod | type: array | description: Exceptions to the business's regular hours. The business can be open or closed during the exception. - name: startDate | type: string | description: Start date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: endDate | type: string | description: End date and time of the exception in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format and [Coordinated Universal Time (UTC)](https://en.wikipedia.org/wiki/Coordinated_Universal_Time). - name: isClosed | type: boolean | description: Whether the business is closed (or the service is not available) during the exception. Default: `true`. - name: comment | type: string | description: Additional info about the exception. For example, "We close earlier on New Year's Eve." Return type: PROMISE EMPTY-OBJECT {} Possible Errors: HTTP Code: 401 | Status Code: UNAUTHENTICATED | Application Code: META_SITE_NOT_FOUND | Description: Couldn't find the site. HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: PERMISSION_DENIED | Description: The [identity](https://dev.wix.com/docs/api-reference/articles/authentication/about-identities.md) used to call the method doesn't have the required permissions. ``` ### Examples ### updateBusinessSchedule() based on user input (with $w) This code is an example of a webpage for users with manager-level access to update the business' schedule. There is a form with checkboxes to indicate addition of another set of opening times (up to a maximum of 5) or the addition of a special hour. If the checkbox is checked, another form will appear with relevant dropdown choices - the values of the options are compatible with the required input (e.g. for 'Monday' option, value is 'MONDAY'). ```javascript /***************************************************** * Backend code - update-business-schedule.web.js/ts * ****************************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { siteProperties } from '@wix/business-tools'; import { auth } from '@wix/essentials'; export const scheduleUpdate = webMethod(Permissions.Anyone, async (businessSchedule) => { try { const elevatedUpdateBusinessSchedule = auth.elevate(siteProperties.updateBusinessSchedule); await elevatedUpdateBusinessSchedule(businessSchedule); console.log('Success! Schedule Updated'); return true; } catch (error) { console.error(error); throw new Error(error); } }); /************* * Page code * ************/ import { scheduleUpdate } from 'backend/update-business-schedule.web'; $w.onReady(() => { $w('#submit').onClick(async () => { const newSchedule = newScheduleAsArrays(); const isUpdated = await scheduleUpdate(newSchedule); if (isUpdated) { console.log('Schedule successfully updated'); $w('#successfulUpdateMsg').show(); setTimeout(() => { $w('#successfulUpdateMsg').hide(); }, 10000); } }); }); function newScheduleAsArrays() { const newPeriods = []; if ($w('#addSchedule1').checked) { newPeriods.push({ openDay: $w('#openDay1').value, openTime: $w('#openTime1').value, closeDay: $w('#closeDay1').value, closeTime: $w('#closeTime1').value }) }; if ($w('#addSchedule2').checked) { newPeriods.push({ openDay: $w('#openDay2').value, openTime: $w('#openTime2').value, closeDay: $w('#closeDay2').value, closeTime: $w('#closeTime2').value }) }; if ($w('#addSchedule3').checked) { newPeriods.push({ openDay: $w('#openDay3').value, openTime: $w('#openTime3').value, closeDay: $w('#closeDay3').value, closeTime: $w('#closeTime3').value }) }; if ($w('#addSchedule4').checked) { newPeriods.push({ openDay: $w('#openDay4').value, openTime: $w('#openTime4').value, closeDay: $w('#closeDay4').value, closeTime: $w('#closeTime4').value }) }; if ($w('#addSchedule5').checked) { newPeriods.push({ openDay: $w('#openDay5').value, openTime: $w('#openTime5').value, closeDay: $w('#closeDay5').value, closeTime: $w('#closeTime5').value }) }; const newSpecialHour = []; if ($w('#addSpecialHour').checked) { newSpecialHour.push({ startDate: $w('#specialDateStart').value, endDate: $w('#specialDateEnd').value, isClosed: $w('#specialDateIsClosed').checked, comment: $w('#specialDateComment').value }) }; return {periods: newPeriods, specialHourPeriod: newSpecialHour}; } ``` ### Update Business Schedule (with elevated permissions) @description: ```javascript import { siteProperties } from '@wix/business-tools'; import { auth } from '@wix/essentials'; /* Sample businessSchedule value: * { * "periods": [ * { * "closeDay": "MONDAY", * "closeTime": "13:00", * "openDay": "MONDAY", * "openTime": "08:00" * }, * { * "closeDay": "TUESDAY", * "closeTime": "13:00", * "openDay": "TUESDAY", * "openTime": "08:00" * }, * { * "closeDay": "WEDNESDAY", * "closeTime": "18:00", * "openDay": "WEDNESDAY", * "openTime": "08:00" * }, * { * "closeDay": "THURSDAY", * "closeTime": "13:00", * "openDay": "THURSDAY", * "openTime": "08:00" * }, * { * "closeDay": "FRIDAY", * "closeTime": "18:00", * "openDay": "FRIDAY", * "openTime": "08:00" * } * ], * "specialHourPeriod": [ * { * "comment": "Closed between Christmas and New Year", * "endDate": "2023-12-31T23:59:00Z", * "isClosed": true, * "startDate": "2023-12-25T00:00:00Z" * } * ] * } */ export async function myUpdateBusinessScheduleFunction(businessSchedule) { try { const elevatedUpdateBusinessSchedule = auth.elevate(siteProperties.updateBusinessSchedule); await elevatedUpdateBusinessSchedule(businessSchedule); console.log('Success! Updated schedule'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### Update Business Schedule @description: ```javascript import { siteProperties } from '@wix/business-tools'; export async function myUpdateBusinessScheduleFunction(businessSchedule) { try { await siteProperties.updateBusinessSchedule(businessSchedule); console.log('Success! Updated schedule'); return true; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to void */ ``` ### updateBusinessSchedule (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { siteProperties } from '@wix/business-tools'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { siteProperties }, // Include the auth strategy and host as relevant }); async function updateBusinessSchedule(businessSchedule) { const response = await myWixClient.siteProperties.updateBusinessSchedule(businessSchedule); }; ``` ---