About Locations
With the Locations API, site owners can define multiple physical locations for their business. This allows them to set individual opening hours for each location.
The Locations API allows you to:
- Get, list, and query existing locations.
- Create, update, and archive locations.
- Set a default location that is reflected in the site properties.
Learn more about how site owners can manage their location-specific bookings.
Terminology
- Default location: Location reflected in the site properties. This location is used on invoices.
- Type: Describes whether a location is an office, reception, branch or the headquarters.
- Status: Indicates whether a location is
ACTIVE
orINACTIVE
. - Business Schedule: Describes the location's regular and exceptional opening hours.
- Period: Regular, weekly recurring opening hours of the location.
- Special Hour Period: Exception to the location's regular hours. The location can be either open or closed during the Special Hour Period.
Before you begin
It’s important to note the following points before starting to code:
- The Wix Bookings API doesn't support the
businessSchedule
object. - You can't delete a location. Instead, you can archive a location using the
archiveLocation()
function. - You can't archive the default location.
- Archived locations can't be unarchived.
- The
updateLocation()
function replaces an existing location with a new location. Currently, you can't partially update a location. - Currently, the location type is just informational and doesn't affect a location's functionality.
- The status
INACTIVE
isn't currently supported.
Setup
To use the Locations API, install the @wix/business-tools
package using npm or Yarn:
1npm install @wix/business-tools
or
1yarn add @wix/business-tools
Then import { locations }
from @wix/business-tools
:
1import { locations } from '@wix/business-tools'
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Archives a location.
The archiveLocation()
function returns a Promise that resolves to the archived location.
The archiveLocation()
function changes a location's archived
property to true
.
Notes:
- A location's status isn't affected by this function.
- An archived location can't be updated.
- It's currently not possible to unarchive locations.
- A default location can't be archived.
Permission Scopes
For app development, you must have one of the following permission scopes:function archiveLocation(_id: string): Promise<ArchiveLocationResponse>
ID of the location to archive.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a location.
The createLocation()
function returns a Promise that resolves to the created location.
Permission Scopes
For app development, you must have one of the following permission scopes:function createLocation(location: Location): Promise<Location>
Location to create.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a location.
The getLocation()
function returns a Promise that resolves to the retrieved location.
Permission Scopes
For app development, you must have one of the following permission scopes:function getLocation(_id: string): Promise<Location>
ID of the location to retrieve.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a list of locations.
Retrieves a list of up to 1,000 locations, given the provided filters, sorting, and paging.
Permission Scopes
For app development, you must have one of the following permission scopes:function listLocations(options: ListLocationsOptions): Promise<ListLocationsResponse>
Options to use when retrieving a list of locations.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a query to retrieve a list of locations.
The queryLocations()
function builds a query to retrieve a list of up to 1,000 locations and returns a LocationsQueryBuilder
object.
The returned object contains the query definition which is typically used to run the query using the find()
function.
You can refine the query by chaining LocationsQueryBuilder
functions onto the query. LocationsQueryBuilder
functions enable you to sort, filter, and control the results that queryLocations()
returns. The functions that are chained to queryLocations()
are applied in the order they are called.
queryLocations()
runs with the following LocationsQueryBuilder
defaults that you can override:
skip
:0
limit
:50
The following QueryLocationsBuilder
functions are supported for the queryLocations()
function. For a full description of the Locations object, see the object returned for the items
property in LocationsQueryResult
.
Permission Scopes
For app development, you must have one of the following permission scopes:function queryLocations(): LocationsQueryBuilder
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Sets a new default location.
The setDefaultLocation()
function returns a Promise that resolves to the new default location.
Notes:
- There can be only one default location per site.
- The
setDefaultLocation()
function changes the value of thedefault
property of both the new and old default locations objects. - The default location can't be archived.
Permission Scopes
For app development, you must have one of the following permission scopes:function setDefaultLocation(_id: string): Promise<SetDefaultLocationResponse>
ID of the location to set as the default location.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a location.
The updateLocation()
function returns a Promise that resolves to the updated location.
Each time a location is updated, its revision
increments by 1. The current revision
must be passed when updating the comment. This ensures you're working with the latest location and prevents unintended overwrites.
Notes:
- Currently, it isn't possible to partially update a location. You must pass the full location object in the
location
parameter. - Any fields which are not included in the
location
parameter will be overwritten tonull
.
Permission Scopes
For app development, you must have one of the following permission scopes:function updateLocation(_id: string, location: UpdateLocation): Promise<Location>
Location ID.
Updated location details.