> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: listLocations(options: ListLocationsOptions)

# Method package: wixBusinessToolsV2

# Method menu location: wixBusinessToolsV2 --> locations --> listLocations

# Method Link: https://dev.wix.com/docs/velo/apis/wix-business-tools-v2/locations/list-locations.md

# Method Description:

Retrieves locations, given the specified filters, sorting, and paging.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## List all locations (dashboard page code) 

```javascript
import { locations } from 'wix-business-tools.v2';
import { elevate } from 'wix-auth';

export async function myGetLocationFunction(_id) {
  try {
    const elevatedGetLocation = elevate(locations.getLocation);
    const myLocations = await elevatedGetLocation(_id);
    console.log('Locations:', myLocations);
    
    return myLocations;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "locations": [
 *     {
 *       "_id": "6a7a7356-a122-4de6-943c-3ea9e66f0d0a",
 *       "address": {
 *         "city": "Costa Mesa",
 *         "country": "US",
 *         "formatted": "Location1980, Placentia Avenue, Costa Mesa, CA, USA",
 *         "location": {
 *           "latitude": 33.6463497,
 *           "longitude": -117.931867
 *         },
 *         "postalCode": "92627"
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Placentia Avenue",
 *           "number": "1980"
 *         },
 *         "subdivision": "CA",
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": true,
 *       "email": "",
 *       "fax": "",
 *       "name": "Costa Mesa Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "America/Los_Angeles"
 *     },
 *     {
 *       "_id": "6a0c5611-0610-4fc2-9eda-a5614ffaf141",
 *       "address": {
 *         "city": "Kingston",
 *         "country": "CA",
 *         "formatted": "222, Stuart Street, Kingston, ON, Canada",
 *         "location": {
 *           "latitude": 44.2236494,
 *           "longitude": -76.4992216
 *         },
 *         "postalCode": "K7L 2W1"
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Stuart Street",
 *           "number": "222"
 *         },
 *         "subdivision": "ON",
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": false,
 *       "email": "",
 *       "fax": "",
 *       "name": "Kingston Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "America/Los_Angeles"
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "count": 2,
 *     "hasNext": false
 *   }
 * }
 */

```

## List all locations (export from backend code) 

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { locations } from 'wix-business-tools.v2';
import { elevate } from 'wix-auth';

export const myListLocationsFunction = webMethod(Permissions.Anyone, async () => {
  try {
    const elevatedListLocations = elevate(locations.listLocations);
    const myLocations = await elevatedListLocations();
    console.log('Locations:', myLocations);

    return myLocations;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/* Promise resolves to:
 * {
 *   "locations": [
 *     {
 *       "_id": "6a7a7356-a122-4de6-943c-3ea9e66f0d0a",
 *       "address": {
 *         "city": "Costa Mesa",
 *         "country": "US",
 *         "formatted": "Location1980, Placentia Avenue, Costa Mesa, CA, USA",
 *         "location": {
 *           "latitude": 33.6463497,
 *           "longitude": -117.931867
 *         },
 *         "postalCode": "92627"
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Placentia Avenue",
 *           "number": "1980"
 *         },
 *         "subdivision": "CA",
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": true,
 *       "email": "",
 *       "fax": "",
 *       "name": "Costa Mesa Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "America/Los_Angeles"
 *     },
 *     {
 *       "_id": "6a0c5611-0610-4fc2-9eda-a5614ffaf141",
 *       "address": {
 *         "city": "Kingston",
 *         "country": "CA",
 *         "formatted": "222, Stuart Street, Kingston, ON, Canada",
 *         "location": {
 *           "latitude": 44.2236494,
 *           "longitude": -76.4992216
 *         },
 *         "postalCode": "K7L 2W1"
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Stuart Street",
 *           "number": "222"
 *         },
 *         "subdivision": "ON",
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": false,
 *       "email": "",
 *       "fax": "",
 *       "name": "Kingston Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "America/Los_Angeles"
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "count": 2,
 *     "hasNext": false
 *   }
 * }
 */

```

## List all locations 

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { locations } from 'wix-business-tools.v2';
import { elevate } from 'wix-auth';

/* Sample options value:
 * {
 *   includeArchived: true,
 *   paging: {
 *     limit: 3,
 *     offset: 0
 *   },
 *   sort: {
 *     fieldName: 'name',
 *     order: 'ASC'
 *   }
 * }
 */

export const myListLocationsFunction = webMethod(Permissions.Anyone, async (options) => {
  try {
    const elevatedListLocations = elevate(locations.listLocations);
    const myLocations = await elevatedListLocations(options);
    console.log('Locations:', myLocations);

    return myLocations;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/* Promise resolves to:
 * {
 *   "locations": [
 *     {
 *       "_id": "6a0c5611-0610-4fc2-9eda-a5614ffaf141",
 *       "address": {
 *         "city": "Buenos Aires",
 *         "country": "AR",
 *         "formatted": "456, Example Street, Buenos Aires, Argentina",
 *         "location": {
 *           "latitude": -34.6037,
 *           "longitude": -58.3816
 *         },
 *         "postalCode": "C1234",
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Example Street",
 *           "number": "456"
 *         },
 *         "subdivision": ""
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": false,
 *       "email": "",
 *       "fax": "",
 *       "name": "Buenos Aires Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "America/Argentina/Buenos_Aires"
 *     },
 *     {
 *       "_id": "6a0c5611-0610-4fc2-9eda-a5614ffaf142",
 *       "address": {
 *         "city": "Paris",
 *         "country": "FR",
 *         "formatted": "789, Rue de l'Exemple, Paris, France",
 *         "location": {
 *           "latitude": 48.8566,
 *           "longitude": 2.3522
 *         },
 *         "postalCode": "75001",
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Rue de l'Exemple",
 *           "number": "789"
 *         },
 *         "subdivision": ""
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": false,
 *       "email": "",
 *       "fax": "",
 *       "name": "Paris Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "Europe/Paris"
 *     },
 *     {
 *       "_id": "6a7a7356-a122-4de6-943c-3ea9e66f0d0a",
 *       "address": {
 *         "city": "Vienna",
 *         "country": "AT",
 *         "formatted": "Examplestraße 123, Vienna, Austria",
 *         "location": {
 *           "latitude": 48.8566,
 *           "longitude": 2.3522
 *         },
 *         "postalCode": "12345",
 *         "streetAddress": {
 *           "apt": "",
 *           "name": "Examplestraße",
 *           "number": "123"
 *         },
 *         "subdivision": ""
 *       },
 *       "archived": false,
 *       "businessSchedule": {
 *         "periods": [],
 *         "specialHourPeriod": []
 *       },
 *       "default": true,
 *       "email": "",
 *       "fax": "",
 *       "name": "Vienna Store",
 *       "phone": "",
 *       "revision": "1",
 *       "status": "ACTIVE",
 *       "timeZone": "Europe/Vienna"
 *     }
 *   ],
 *   "pagingMetadata": {
 *     "count": 3,
 *     "hasNext": true
 *   }
 * }
 */

```

## Archive a location 

```javascript
/******************************************
 * Backend code - archive-location.web.js *
 *****************************************/

import { Permissions, webMethod } from 'wix-web-module';
import { locations } from 'wix-business-tools.v2';
import { elevate } from 'wix-auth';

export const archiveLocationById = webMethod(Permissions.Anyone, async (locationId) => {
  try {
    const elevatedArchiveLocation = elevate(locations.archiveLocation);
    const archivedLocation = await elevatedArchiveLocation(locationId);

    return archivedLocation;
  } catch (error) {
    console.error(error);
    throw new Error(error);
  }
});

export const listLocations = webMethod(Permissions.Anyone, async () => {
  try {
    const elevatedListLocations = elevate(locations.listLocations);
    const results = await elevatedListLocations();

    return results.locations;
  } catch (error) {
    console.error(error);
    throw new Error(error);
  }
});


/*************
 * Page code *
 ************/

import { archiveLocationById, listLocations } from 'backend/archive-location.web';

$w.onReady(async () => {
  await populateStoresDropdown();

  $w('#archiveLocationBtn').onClick(async () => {
    const locationId = $w('#locationsDropdown').value;
    const archivedLocation = await archiveLocationById(locationId);

    console.log('The following location has been archived', archivedLocation);
    $w('#archivedMessage').show();
  });
});

async function populateStoresDropdown() {
  const locations = await listLocations();
  const dropdownOptions = locations.map((location) => {
    return {
      label: location.name,
      value: location._id
    }
  });

  $w('#locationsDropdown').options = dropdownOptions;
}

```

---