> 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/arrival/sample-flows.md

## Article Content:

# Arrivals: 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.

## Scan a client in at the front desk

A client shows the QR code of their pass at the front desk, and a site collaborator scans it with your app.

To admit the client, your app can:

1. Call [Create Arrival By Credential](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival-by-credential.md) with the scanned QR payload, the
   `entranceId` a site collaborator picked where they stand. The area is the one the entrance belongs to:

    ```json
    {
      "token": "<SCANNED_QR_PAYLOAD>",
      "entranceId": "<ENTRANCE_ID>"
    }
    ```

2. The response carries the written `arrival`. When `arrival.status` is `GRANTED`, the person is in: show the
   green screen with `arrival.planBenefit` or `arrival.scheduledEvent` (which your app renders in its own
   language) and the client's name and photo from `arrival.contactDetails`, a snapshot the server took
   from Contacts when it wrote the arrival. The benefit is redeemed after the response; the arrival does not say
   when. When several of the client's benefits could have paid, the server picked one; the scanner never asks.

3. When `arrival.status` is `DENIED`, show the sheet from the arrival itself: `arrival.eligibilityDetails`
   says why: its `issues` for the entry as a whole, each of its `planBenefits` and `scheduledEvents` with its own
   `issues` (a lapsed plan, an empty pack, or a booking still pending approval). The denial is
   already on record and Arrival Created has fired. The sheet offers one action: when a site collaborator taps "Let in anyway",
   record the override with [Override Arrival as Granted](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/override-arrival-as-granted.md) (next flow). When a site collaborator taps "Decline", or the
   sheet times out, make no call: the denied arrival is the final record. Selling a plan is
   done in its own product, not from the sheet; once the client's standing has changed, scan again. The engine
   evaluates afresh and writes a new arrival.

4. When `arrival.status` is `DENIED` with `RECENT_ENTRY` in `eligibilityDetails.issues`, the client was granted
   entry into this area within the last 15 minutes and a credit would be spent again: a retried scan after a lost
   response, a client who stepped out, or a guest on the same credential. Show "let in 4 minutes ago" with two
   choices: **already in** makes no call; **let in anyway** is Override Arrival as Granted, and spends a
   credit. Never retry a timed-out scan automatically; this sheet is how a lost response is resolved. A repeat
   of the same scan (same client and entrance, by the same site collaborator) within 5 seconds returns the
   existing arrival instead, and nothing new is written. A Create Arrival repeat by contact ID that carries
   `denialOverride` grants that denied arrival instead, as Override Arrival as Granted would.

5. A token that does not resolve to a live credential fails with `BAD_SIGNATURE` or `TOKEN_REVOKED`, and nothing
   is recorded. Show these as scanner results ("invalid pass", "refresh your pass"), not as failures.
   `ENTRANCE_NOT_FOUND` means the scanner's entrance no longer exists: reload the area picker.

## Let a denied client in anyway

A scan or a call by contact ID wrote a `DENIED` arrival, and a site collaborator decides to let the client in anyway.

To record the override, your app can:

1. Before the call, check whether the client was already let in since this denial. The override is a site user's
   decision and doesn't check `RECENT_ENTRY`: it spends the picked credit even then. Check Eligibility returns
   `recentArrival` only when its own evaluation would grant on a credit pack, so right after a denial it's usually
   absent, and its absence doesn't mean the client wasn't let in. To check, call
   [Query Arrivals](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/query-arrivals.md)
   filtered by `contactDetails.contactId`, `area.id`, `status` `GRANTED`, and a `createdDate` lower bound 24 hours
   ago, since an overridden arrival keeps the denial's `createdDate`. An arrival is a recent grant when its
   `overriddenDate`, or its `createdDate` if it has none, is within the last 15 minutes. If you find one, show
   "already let in at …" and ask the site user to confirm.

2. Call [Override Arrival as Granted](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/override-arrival-as-granted.md) with the arrival's ID and an `overrideReason` in the
   site collaborator's own words. Nothing else is sent; the contact, the area, and the entrance can't change.

    ```json
    {
      "arrivalId": "<ARRIVAL_ID>",
      "overrideReason": "Guest of a member, approved at the desk"
    }
    ```

3. The response is the same arrival, overridden: `status` `GRANTED`, `overrideReason` set, `revision` moved,
   `eligibilityDetails` as it was at the denial, and `planBenefit` or `scheduledEvent` set to what that
   evaluation found, if anything. The client is not evaluated again, so Pricing Plans is not called. Arrival Updated fires. A benefit in
   `planBenefit` is redeemed after the response, so letting a recent entry in spends a credit.

4. The override is idempotent: calling it again, or calling it for an arrival that is already `GRANTED`, returns
   the arrival unchanged (its `overrideReason` too) and redeems nothing. It fails on bad input (`ARRIVAL_NOT_FOUND` when `arrivalId` names
   no arrival), and with `OVERRIDE_NOT_ALLOWED` when the caller is not a site user. Any denied arrival may be overridden,
   one a reader wrote included. `overrideReason` is optional.

## Connect a reader at an entrance

A door or turnstile reader paired to an entrance decides on its own, with no site collaborator present. Its own
system maps the card or fob a client presents to the client's Wix contact ID. A reader that scans the QR code of a
client's pass instead calls
[Create Arrival By Credential](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival-by-credential.md)
with the token, as in the first flow, and reads the result the same way.

To let the reader decide at the door, your device can:

1. Call [Create Arrival](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival.md) with the person's `contactId` and the reader's own `entranceId`:

    ```json
    {
      "arrival": {
        "contactDetails": { "contactId": "<CONTACT_ID>" },
        "area": { "entranceId": "<ENTRANCE_ID>" }
      }
    }
    ```

   A repeat by the same caller for the same contact at the same entrance within 5 seconds returns the existing arrival; a
   later one within 15 minutes where a credit would be spent again is written as `DENIED` with `RECENT_ENTRY`.

2. On the `200`, read `arrival.status`: `GRANTED` opens; `DENIED` keeps closed. Why it was denied is in
   `arrival.eligibilityDetails.issues`, which is returned only to callers with the
   `SCOPE.ARRIVALS.READ-ELIGIBILITY-DETAILS` permission scope; without it, the arrival comes back with `status` and
   no `eligibilityDetails`, so show a generic "see the front desk". Either way the arrival is on record with
   `source.identifiedBy` `BY_CONTACT` and `source.createdBy` naming your app, and Arrival Created has fired. A reader
   never overrides: the client goes to a site collaborator, who either overrides this denied arrival or scans the client
   or approves their entry, which writes a new arrival. One or the other, not both, since each admits the client and may
   spend a credit.

3. Handle each error by keeping the door closed; nothing was recorded:
   - `CONTACT_NOT_FOUND`: the contact was deleted, or merged into another. Read the contact again to get the surviving
     contact's ID and update the card's mapping.
   - `UNAVAILABLE` (`PRICING_PLANS_UNAVAILABLE` or `CONTACTS_UNAVAILABLE`): the check could not be completed. Show
     "try again" and let the client present the card again; a retry is safe.
   - `ENTRANCE_NOT_FOUND` or `AREA_ARCHIVED`: the reader's entrance no longer takes arrivals. Show "out of
     service" and flag the device for setup.

## Show a client their standing without admitting them

A client asks at the desk what their pass still covers, before they go in.

To let site collaborators check the client's standing from a scan, your app can:

1. Call [Check Eligibility By Credential](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/check-eligibility-by-credential.md) with the token and the scanner's `entranceId`;
   eligibility is checked for the area the entrance belongs to.

2. Render the response read-only: `status` says what a scan would get; in `eligibilityDetails`, each
   of `planBenefits` with its `planBenefit.type` and its `issues` (empty means it admits), each of `scheduledEvents` (inside the
   area's entry window, and only from the apps in the area's `scheduledEventsPolicy.entryGrantingAppIds`) with its
   `issues`, and the entry's `issues`. Nothing was recorded and nothing was redeemed. Balances are not returned: the client sees them in
   their app, the owner in Pricing Plans. When the entry's `issues` hold `PRICING_PLANS_UNAVAILABLE` or
   `CONTACTS_UNAVAILABLE`, the check could not be completed: show "Couldn't check" with "Try again" (call Check
   Eligibility By Credential again); "Mark as arrived" fails with `UNAVAILABLE` until the source answers.

3. Offer one button that records the entry: "Mark as arrived". It calls
   [Create Arrival By Credential](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival-by-credential.md) with the same token and the scanner's `entranceId`. The
   engine evaluates again, since the client's standing may have changed since the check. When the arrival comes
   back `DENIED` and a site collaborator chooses "Let in anyway", call [Override Arrival as Granted](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/override-arrival-as-granted.md)
   with that arrival's ID and an optional `overrideReason`, as in "Let a denied client in anyway". Arrival Created
   fires with the denial, then Arrival Updated with the grant; the arrival keeps `source.identifiedBy` `BY_TOKEN`.

## Admit a client by contact ID from your app

A client arrives without their pass, and a site collaborator finds them in your app by name. Your app already knows
the client's contact ID.

To admit the client, your app can:

1. Call [Create Arrival](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/create-arrival.md) with the client's `contactId` in `contactDetails`
   and an `area.entranceId`:

    ```json
    {
      "arrival": {
        "contactDetails": { "contactId": "<CONTACT_ID>" },
        "area": { "entranceId": "<ENTRANCE_ID>" }
      }
    }
    ```

2. The same evaluation runs as at a scan, and the arrival is written with the status the issues imply. It has
   `source.identifiedBy` `BY_CONTACT`, even when the client holds a credential; the server fills in the name and picture
   from Contacts, and the area's and entrance's names:

    ```json
    {
      "arrival": {
        "id": "<ARRIVAL_ID>",
        "contactDetails": { "contactId": "<CONTACT_ID>", "firstName": "Noa", "lastName": "Levi" },
        "source": { "identifiedBy": "BY_CONTACT", "createdBy": { "wixUserId": "<USER_ID>" } },
        "area": { "id": "<AREA_ID>", "name": "Main floor", "entranceId": "<ENTRANCE_ID>", "entranceName": "Front entrance" },
        "eligibilityDetails": { "issues": [], "planBenefits": [ { "planBenefit": { "poolId": "<POOL_ID>", "benefitKey": "<BENEFIT_KEY>", "displayName": "Monthly Unlimited", "type": "UNLIMITED" } } ] },
        "planBenefit": { "poolId": "<POOL_ID>", "benefitKey": "<BENEFIT_KEY>", "displayName": "Monthly Unlimited", "type": "UNLIMITED" },
        "status": "GRANTED"
      }
    }
    ```

3. When `status` is `DENIED`, show the sheet from `eligibilityDetails` and, if the site collaborator lets the client
   in anyway, call Override Arrival as Granted with the arrival's ID and an `overrideReason`. When the
   site collaborator has already decided to let the client in (after checking their standing), send
   `denialOverride` on Create Arrival instead: a denial is then written `GRANTED` in that one call. Sending it is
   the decision, even empty; add `{ "reason": "…" }` to record why:

    ```json
    {
      "arrival": {
        "contactDetails": { "contactId": "<CONTACT_ID>" },
        "area": { "entranceId": "<ENTRANCE_ID>" }
      },
      "denialOverride": {}
    }
    ```

## Check a client from the contact card

An owner or manager looks at a client's record and wants to know whether the client can enter an area right now,
with no QR code involved.

To show the client's standing, your app can:

1. Call [Check Eligibility](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/check-eligibility.md) with the client's `contactId` and an `entranceId`;
   eligibility is checked for the area the entrance belongs to.

2. Render the response read-only, as in [Show a client their standing without admitting them](#show-a-client-their-standing-without-admitting-them): the benefits and scheduled events found,
   each with its issue. Nothing was recorded and nothing was redeemed.

3. When the entry's `issues` hold `RECENT_ENTRY`, the client was let into this area within the last 15 minutes and
   another entry would spend a credit: show "let in N minutes ago" from `recentArrival.createdDate`. For an
   arrival a site user overrode after it was written, that's the time of the denial: call
   [Get Arrival](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/get-arrival.md)
   with `recentArrival.arrivalId` and read its `overriddenDate` for when the client was let in. To let a
   guest in on the client's pass, call Create Arrival with `denialOverride`; it spends a credit. When they hold
   `PRICING_PLANS_UNAVAILABLE` or `CONTACTS_UNAVAILABLE`, the check could not be completed: show "Couldn't check"
   with "Try again" (call Check Eligibility again) and, for site collaborators who decide anyway, "Let in anyway" (Create
   Arrival with `denialOverride`).

4. To show which upcoming sessions the client could get in on ("classes this evening"), call Check
   Eligibility again with `scheduledEventSearchWindow` (`startDate`, `endDate`). The sessions that start in
   that range are listed in `eligibilityDetails.scheduledEvents`; one that is not open for entry yet carries
   `OUTSIDE_ENTRY_WINDOW` and does not admit, and `status` still says what a scan would get now. Only the first year
   after `startDate` is searched, and at most 20 events are listed. The window works only in an area whose
   `scheduledEventsPolicy.entryGrantingAppIds` lists the app, such as Wix Bookings.

## Refund a credit spent on the wrong client

A site collaborator scanned the wrong client, and a credit was spent. The business fixes the charge in Pricing Plans;
the arrival itself is never changed.

To find the charge to refund, your app can:

1. Call [Query Arrivals](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/query-arrivals.md) filtered by `contactDetails.contactId` and today's
   `createdDate` to find the arrival; `planBenefit.poolId` and `planBenefit.benefitKey` name the benefit that was charged.

2. Have the business refund that credit in the Pricing Plans dashboard. The redemption's transaction carries the arrival's `id`
   as its idempotency key and in its additional data as `arrivalId`, so support can trace an arrival to its transaction
   from the Pricing Plans side. The arrival stays `GRANTED` and unchanged: it is the record that the scan
   happened, and Arrivals fires no revert event.

## Show today's tiles on the dashboard

A business wants to see at a glance how many clients came in today, how many were turned away, and how many were let
in anyway.

To show "entries today" per area, your app can:

1. Call [Count Arrivals](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/count-arrivals.md) with a filter on `area.id`, `status` `GRANTED`, and
   `createdDate` from midnight.

2. Call it again with the same filter and `status` `DENIED`. An arrival a site collaborator overrode is `GRANTED`, so it is counted once, with the grants.

3. For "let in anyway today", call it with `overriddenBy.wixUserId` `{ "$exists": true }` and the same `area.id` and
   `createdDate`. An override with no reason is found too: every override has `overriddenBy`. Such an arrival is
   already among the grants of step 1, so show this as a part of them, not beside them.