> 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

## Resource: Sample Flows

## Article: Sample Flows

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/sample-flows.md

## Article Content:

# Areas: Sample Flows

This article presents possible use cases and corresponding sample flows that you can support. It provides a
useful starting point as you plan your implementation.

## Set up a new business

A business that just installed Arrivals needs its areas, entrances, and plans in place before site collaborators can
scan clients in. Most sites already have their first area, created at install.

To set up a new business, your app can:

1. Call [Query Areas](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/query-areas.md) to get the area created when Arrivals was installed, with one
   entrance (the location's default entrance), at the site's default location. Both have a default name in the
   site's language; the response below is from an English site ("Main area", "Main entrance"). When the site
   already has an area, your app doesn't create the first one; creating one of its own leaves the site with two.
   The response carries the area's `id`, `locationId`, `revision`, and its entrance's `id`:

    ```json
    {
      "areas": [
        {
          "id": "<MAIN_AREA_ID>",
          "revision": "1",
          "name": "Main area",
          "locationId": "<DEFAULT_LOCATION_ID>",
          "status": "ACTIVE",
          "entrances": [
            { "id": "<MAIN_ENTRANCE_ID>", "name": "Main entrance", "defaultEntrance": true }
          ]
        }
      ]
    }
    ```

   If Query Areas returns no areas, the site had no default location when Arrivals was installed: a site gets one
   once its business info has an address. Have the business add its address or a location (in its business info,
   or with the Locations API's Create Location, with an address: a default location without one isn't kept).
   Then call [Create Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/create-area.md) at the new location's `id`, with one entrance, and continue
   with its `id`, `revision`, and entrance `id`:

    ```json
    {
      "area": {
        "name": "Main area",
        "locationId": "<DEFAULT_LOCATION_ID>",
        "entrances": [{ "name": "Main entrance", "defaultEntrance": true }]
      }
    }
    ```

2. Connect the business's active pricing plans to the area. An area is a benefit item of a plan: the business
   owner connects it in the plan editor of the Pricing Plans dashboard, or your app calls Benefit Programs'
   [Add Items to Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pool-definition-items/add-items-to-benefit.md).
   `poolDefinitionId` and `benefitKey` identify the plan's benefit (from Get Pool Definition or Query Pool
   Definitions), and `itemReferences[].externalId` is the area's `id`. The benefit's provider app must be
   Arrivals, and the item appears shortly after the call, not in the same request:

    ```json
    {
      "poolDefinitionId": "<POOL_DEFINITION_ID>",
      "benefitKey": "<BENEFIT_KEY>",
      "itemReferences": [{ "externalId": "<MAIN_AREA_ID>" }]
    }
    ```

   A plan created later is connected the same way; nothing connects automatically after setup.

3. Optionally, call [Update Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/update-area.md) to rename the area and its entrance, and to move the
   area to another location of the business. Send the `revision` from step 1 and the whole `entrances` list,
   with the existing entrance's `id`:

    ```json
    {
      "area": {
        "id": "<MAIN_AREA_ID>",
        "revision": "1",
        "name": "Gym floor",
        "locationId": "<LOCATION_ID>",
        "entrances": [
          { "id": "<MAIN_ENTRANCE_ID>", "name": "Front desk", "defaultEntrance": true }
        ]
      }
    }
    ```

4. Call [Create Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/create-area.md) for each further part of the business, such as a pool or a cycle
   studio, with its own entrances. A location keeps its default entrance unless you mark another of its entrances
   `defaultEntrance`, which moves the default there; an area at a location with no area yet gets it.

## Add an entrance to an area

A business opens a second way into an area, such as a side door, and pairs a new device to it.

To add the entrance, your app can:

1. Call [Get Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/get-area.md) to read the current `entrances` and `revision`.

2. Call [Update Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/update-area.md) with the whole list: every existing entrance with its `id`,
   and the new one without it:

    ```json
    {
      "area": {
        "id": "<AREA_ID>",
        "revision": "3",
        "entrances": [
          { "id": "<MAIN_ENTRANCE_ID>", "name": "Main entrance", "defaultEntrance": true },
          { "name": "Side door" }
        ]
      }
    }
    ```

3. The response carries the new entrance with the ID the server assigned. When a guest arrives at it, pass that
   ID as `arrival.area.entranceId` to [Create Arrival](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival.md) and as `entranceId` to
   [Check Eligibility](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/check-eligibility.md).

## Build the scanner's picker

Site collaborators who scan clients in pick the entrance they are standing at once per scanning position.

To show them where they can scan, your app can:

1. Call [Query Areas](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/query-areas.md) filtered to active areas at the current location:

    ```json
    {
      "query": {
        "filter": {
          "status": "ACTIVE",
          "locationId": "<LOCATION_ID>"
        },
        "sort": [{ "fieldName": "name", "order": "ASC" }]
      }
    }
    ```

2. Offer each area with its `entrances`; preselect the location's default entrance, the one whose
   `defaultEntrance` is `true`.

3. A location can have no active area: `LAST_ACTIVE_AREA` protects only the site's last active area, so on a site
   with several locations one can be left with none. When the query returns nothing, show site collaborators that there is
   nowhere to scan at this location, and point the owner to the dashboard to add or unarchive an area.

4. Hide the picker entirely when the location has a single active area with a single entrance.

## List the forms an area will require

A pool will require a signed swim waiver before a client swims, and a photo consent that doesn't block entry.
Intake forms aren't checked at entry yet: they're validated and stored on the area's policy, and until the check
ships a client is evaluated on their plans and scheduled events only.

> **Prerequisite:** The forms must already exist in the Intake Forms app, installed on the site: create them there
> first and use their IDs. Otherwise Update Area fails with `INTAKE_FORM_NOT_FOUND` or `INTAKE_FORM_APP_NOT_INSTALLED`.

To list the forms on the pool's policy, your app can:

1. Call [Update Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/update-area.md) for the pool with its `policy.intakeForms`:

    ```json
    {
      "area": {
        "id": "<POOL_AREA_ID>",
        "revision": "2",
        "policy": {
          "intakeForms": [
            { "formId": "<SWIM_WAIVER_FORM_ID>", "blocksEntry": true },
            { "formId": "<PHOTO_CONSENT_FORM_ID>" }
          ]
        }
      }
    }
    ```

   The response returns the area with both forms on its policy.

## Let booked clients in on their class

A studio wants clients who booked a class to get in on that booking, without spending a plan credit.

To let a client who is booked into a class enter on that booking, your app can:

1. Call [Get Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/get-area.md) to read the current `revision`.

2. Call [Update Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/update-area.md) with `policy.scheduledEventsPolicy` naming Wix Bookings' app ID and an entry window,
   here from 15 minutes before the start until 10 minutes after:

    ```json
    {
      "area": {
        "id": "<AREA_ID>",
        "revision": "4",
        "policy": {
          "scheduledEventsPolicy": {
            "entryGrantingAppIds": ["13d21c63-b5ec-5912-8397-c3a5ddb27a97"],
            "entryWindow": { "opensBeforeStartInMinutes": 15, "closesAfterStartInMinutes": 10 }
          }
        }
      }
    }
    ```

   From the next scan, a client booked into a scheduled event at the area's location is admitted on it
   inside the window, and nothing is redeemed. Sending `entryGrantingAppIds` without an `entryWindow` fails with
   `ENTRY_WINDOW_REQUIRED`, and an `entryWindow` with both values `0` fails with `EMPTY_ENTRY_WINDOW`.

## Retire an area without losing its history

A business closes a part of it, such as a studio room, and wants its past arrivals to stay in reports.

To retire the area, your app can:

1. Call [Archive Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/archive-area.md) with the area's ID. The area's `status` becomes `ARCHIVED`.
   While Pricing Plans is enabled on the site, the area is also removed from every plan benefit that grants entry
   into it; unarchiving doesn't put it back.
   Archiving the site's last active area fails with `LAST_ACTIVE_AREA`: create or unarchive another area first.

2. Refresh the scanner's picker with [Query Areas](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/query-areas.md). The archived area no longer
   appears among active areas. Past arrivals recorded in the area keep referencing it, so history and reports stay
   intact.

## Remove an area created by mistake

An owner created an area by mistake and wants it gone, not archived.

To remove the area, your app can:

1. Call [Delete Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/delete-area.md) with the area's ID. The area is removed, and the Area Deleted event fires.
   While Pricing Plans is enabled on the site, it is also removed from every plan benefit that grants entry into
   it. Deleting the site's last active area fails with `LAST_ACTIVE_AREA`: create or unarchive another area first.
   Arrivals already recorded in the area keep its ID and name.

To close an area and keep the option to bring it back, call
[Archive Area](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area/archive-area.md) instead, as in the previous flow.