> 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: Introduction

## Article: Introduction

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/introduction.md

## Article Content:

# About the Arrivals API

The Arrivals API decides and records entry into an area. Create Arrival checks a client's scheduled events and
pricing plans against an area and writes one arrival whatever it finds about the client: `GRANTED` when the client
may enter, `DENIED` when something stands in the way, with everything the engine found recorded on the arrival
itself. Every answered Create Arrival call therefore ends in exactly one arrival: who arrived, where (the area and
the entrance), what the engine found (`eligibilityDetails`), and whether access was given (`status`).

A granted arrival's Pricing Plans benefit is redeemed just afterwards, asynchronously. A scheduled event's attendance
isn't marked by Arrivals: a business that wants it marked sets up an automation on the "Client arrives" trigger.
When an arrival is denied, site collaborators see why from the arrival's own issues and may let the client in anyway
with Override Arrival as Granted. That's the one change an arrival receives through this API.

The API has two services on the same arrival entity:

- Arrivals Service identifies people by contact ID. Create Arrival evaluates and writes, Override Arrival as
  Granted records a site user's override, and Check Eligibility shows a contact's standing in an area without
  recording anything. Get, Query, and Count Arrivals serve history screens and dashboard tiles. Use it from the
  dashboard's contact card, or from an app or a reader whose own system knows the client's contact ID.
- Credential Arrivals Service identifies people by the pass they present: the token of a QR code. Create Arrival
  By Credential resolves the token to the client and calls Create Arrival for them. Check Eligibility By Credential
  does the same for Check Eligibility.

With the Arrivals API, you can:

- Scan a client's QR code and admit an eligible client in one round trip. `status` `GRANTED` means the client is
  in, and the response carries their name and picture to show it.
- Admit a client by contact ID from your app or a reader, with the same eligibility check and the same redemption
  as a scan.
- Show a client their standing in an area (their benefits and booked sessions, each with its own issue) without
  recording an entry or spending a credit.
- Let a denied client in, with a reason.
- Browse and count arrivals for history screens and dashboard tiles.
- React to grants and denials through the Arrival Created event, by its `status`, and to overrides through
  Arrival Updated.

## Outcomes and issues

A `200` from Create Arrival, or from Create Arrival By Credential which calls it, always returns an arrival. Read
`arrival.status`: `GRANTED` means the client is in. `DENIED` means the engine found an issue that declines, and the
arrival carries it in `eligibilityDetails`. Anything about the client is a `200` with `DENIED`, never an error.

Each issue is in one place:

- An issue of the entry as a whole is in `eligibilityDetails.issues`: `NO_ELIGIBLE_GRANT` (nothing the client holds
  admits them now) and `RECENT_ENTRY`. Both deny, and the status is derived from them.
- Intake forms aren't checked at entry yet. An area's policy can list them, but `INTAKE_FORM_MISSING` isn't
  reported and `eligibilityDetails.missingIntakeForms` is always empty.
- Why a single plan or booking doesn't admit is on that item: `PLAN_NOT_ACTIVE`, `NOT_ENOUGH_BALANCE`,
  `OUTSIDE_ACCESS_HOURS`, or `USAGE_LIMIT_REACHED` on a plan benefit, and `PENDING_CONFIRMATION` on a scheduled
  event. The plan values follow Pricing Plans' own words.

A call fails, and nothing is recorded, in these cases only:

- The pass token doesn't resolve: `BAD_SIGNATURE` or `TOKEN_REVOKED`. Show these as "invalid pass" or "refresh your
  pass".
- The contact or entrance is unknown or out of date: `CONTACT_NOT_FOUND`, `ENTRANCE_NOT_FOUND`, or `AREA_ARCHIVED`.
  Reload the area picker, or the contact.
- Pricing Plans or Contacts can't be reached and nothing else admits the client: `UNAVAILABLE`
  (`PRICING_PLANS_UNAVAILABLE` or `CONTACTS_UNAVAILABLE`). The engine couldn't decide, so offer site collaborators
  "try again" or "let in anyway". A reader at an entrance applies its own fallback. Only Create Arrival by contact
  ID with `denialOverride`, when a site user has decided, writes the arrival in this case: granted with the outage
  in its issues, no plan benefit, nothing redeemed, and without Contacts no name or picture.

Check Eligibility and Check Eligibility By Credential don't fail on an outage. Pricing Plans or Contacts not
answering is reported as `PRICING_PLANS_UNAVAILABLE` or `CONTACTS_UNAVAILABLE` in `eligibilityDetails.issues`, with
`DENIED` unless something else admits the client.

## Overrides

Only a site user (the site owner or a site collaborator) may let a client in against a denial. A reader at an
entrance, or an app with no Wix user on the call, fails with `OVERRIDE_NOT_ALLOWED`. There are two ways:

- After the denial: call Override Arrival as Granted with the arrival's ID and an optional `overrideReason`. It
  moves the status to `GRANTED` and redeems the benefit the denial's evaluation found, so it can spend a credit. The
  client isn't evaluated again: `eligibilityDetails` stays as it was, and its `issues` hold what was overridden. It
  doesn't check `RECENT_ENTRY` either, so look for the client's recent grants in this area first and ask the site
  user to confirm before offering it. Query `GRANTED` arrivals by `contactDetails.contactId` and `area.id`, with a
  `createdDate` lower bound 24 hours ago (a filter on `status` needs one); one is recent when its `overriddenDate`,
  or its `createdDate` if it has none, is within the last 15 minutes. Any denied arrival may be overridden, one a reader wrote included.
- Before the call: when a site user has already decided to let the client in, send `denialOverride` on Create
  Arrival, with an optional `reason`. The engine evaluates as always, and a denial is written `GRANTED` at once, with
  its issues and the reason, exactly as an override would leave it.

When site collaborators decline, or don't act, no call is made: the denied arrival is already the final record.
When the client's standing changes after a denial (a plan was sold at the desk, or a booking was approved), call Create
Arrival again. The engine evaluates afresh and writes a new arrival, and the denied arrival stays on record.

## Repeats and retries

There is no client idempotency key: the arrival ID is the key.

- A repeat for the same contact and entrance by the same caller within 5 seconds returns the existing arrival as it
  is. The caller is the Wix user when the call carries one, through an app included, and the app otherwise. Nothing
  new is written, no event fires, and nothing is redeemed. The one exception is a Create Arrival repeat that carries
  `denialOverride` onto a `DENIED` arrival: it grants that arrival as Override Arrival as Granted would.
- A later call for a client who was granted entry into the same area within the last 15 minutes, where a credit
  would be spent again, writes a `DENIED` arrival with `RECENT_ENTRY`. That covers a retried scan after a lost
  response, a client stepping out and back in, and a guest on the same pass. Site collaborators choose "already in"
  (no call) or "let in anyway" (the override, which spends a credit).
- Don't retry a timed-out call automatically: it may already have written the arrival and spent a credit. A call
  that failed with an error, `UNAVAILABLE` included, wrote nothing and is safe to retry.

A guest admitted on a client's pass is recorded as an arrival of the client, and a second credit is spent. Arrivals
per contact therefore count the entries the contact paid for, not their visits. Such an arrival is `GRANTED` with
`RECENT_ENTRY` in `eligibilityDetails.issues` and `overriddenBy` set.

## Before you begin

It's important to note the following points before starting to code:

- Every arrival is recorded at an entrance, in the area it belongs to. Create Arrival takes only
  `area.entranceId`; the server finds the area and keeps both, with the names they had at the time. Get entrance IDs
  from the Areas API.
- Scheduled events are evaluated only in an area whose `policy.scheduledEventsPolicy.entryGrantingAppIds` names the
  event's app (Areas API), which is empty by default. Elsewhere a booking doesn't admit, and the client is evaluated
  on their plans only.
- An arrival keeps the client's name and picture as Contacts held them when it was written (`contactDetails`), so
  showing who came in needs no Contacts read. It's a snapshot: a later change in Contacts doesn't update it, except a
  privacy deletion of the contact, which replaces the names with `****` and removes the picture.
- An arrival's `eligibilityDetails` and `overrideReason` say why a client wasn't eligible, so they're returned only
  to callers with the `SCOPE.ARRIVALS.READ-ELIGIBILITY-DETAILS` permission scope. Without it, an arrival comes back
  with `status` and no reason.
- The decision an arrival records is final apart from the override. There is no undo: Arrival Created has already
  reached automations and webhooks. A refund of a spent credit is done in Pricing Plans.

## Use cases

- [Scan a client in at the front desk](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Let a denied client in anyway](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Connect a reader at an entrance](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Show a client their standing without admitting them](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Admit a client by contact ID from your app](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Check a client from the contact card](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Refund a credit spent on the wrong client](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)
- [Show today's tiles on the dashboard](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/arrival/sample-flows.md)

## Related APIs

- [Areas](https://dev.wix.com/docs/api-reference/business-solutions/bookings/arrivals/area.md): every arrival is recorded in an area and at one of its entrances (`area.id` and `area.entranceId`, with
  their names and the area's `locationId` as they were at the time). The area's entry window decides which
  scheduled events admit.
- Contact Credentials: the client's pass, whose token is presented at the entrance as a QR code. The arrival records how the client was identified (`source.identifiedBy`).
- [Wix Calendar Events](https://dev.wix.com/docs/api-reference/business-management/calendar/events-v3.md): in an area whose `scheduledEventsPolicy.entryGrantingAppIds` names the event's app, a scheduled event the client is booked into admits them (`scheduledEvent`, the calendar
  event). Nothing is redeemed for one, and Arrivals marks no attendance; a business that wants the booking marked
  attended sets up an automation on the "Client arrives" trigger.
- Pricing Plans: a benefit admits the client (`planBenefit`), a credit pack or an unlimited plan, told apart
  by `type`. Every benefit is redeemed, asynchronously, after the person is let in; a credit pack spends a credit.
  When several admit, an unlimited plan is taken before a credit pack, and among credit packs the one that ends
  soonest (a plan that never ends comes last), then the one with the lowest balance, then the one bought first (the
  rule on `planBenefit`).
  Balances are read from Pricing Plans, never from an arrival. Benefits are held in
  [Benefit Programs pools](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools.md)
  (`planBenefit.poolId`).
- Intake Forms: an area's policy can list intake forms, but they aren't checked at entry yet.
  `eligibilityDetails.missingIntakeForms` is always empty, and `INTAKE_FORM_MISSING` isn't reported.
- [Contacts](https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/contacts/contact-v4.md): the person who arrived (`contactDetails.contactId`), whose name and picture the arrival
  snapshots. A site member is looked up through their contact.

## Terminology

- **Arrival**: The record of one entry into an area, at one of its entrances: granted or denied, with what the engine found.
- **Entry**: The act of passing an entrance. Create Arrival grants an entry; an arrival is its record.
- **Scanner**: An app for site collaborators that scans a client's QR code at an entrance and calls Create Arrival By Credential.
- **Entry issue**: An issue of the entry as a whole (`NO_ELIGIBLE_GRANT`, `RECENT_ENTRY`, or, on an arrival a site
  user let in during an outage or in a Check Eligibility answer, `PRICING_PLANS_UNAVAILABLE` or
  `CONTACTS_UNAVAILABLE`) in `eligibilityDetails.issues`. The status is derived from these.
- **Plan benefit issue** and **scheduled event issue**: Why one benefit or event does not admit, on that item:
  `PLAN_NOT_ACTIVE`, `NOT_ENOUGH_BALANCE`, `OUTSIDE_ACCESS_HOURS`, or `USAGE_LIMIT_REACHED`; `PENDING_CONFIRMATION`, and
  `OUTSIDE_ENTRY_WINDOW` on an event listed only by a Check Eligibility what-if with `scheduledEventSearchWindow`.
- **Eligibility details**: What the engine found (the entry's `issues`, `planBenefits`, and `scheduledEvents`), kept on the arrival for callers with the `SCOPE.ARRIVALS.READ-ELIGIBILITY-DETAILS` permission
  scope, and returned by Check Eligibility in its response.
- **Status**: Whether access was given: `GRANTED` or `DENIED`. A grant the engine would not have made on its own carries `overriddenBy`
  and, if the site user gave a reason, `overrideReason`.
- **Grant**: What can grant entry: a plan benefit or a scheduled event the client is booked on. `NO_ELIGIBLE_GRANT`
  means none of the client's grants admits them now; a granted arrival records the one that did in `planBenefit` or `scheduledEvent`.
- **Granted by**: What granted the entry, never who (who wrote the arrival is `source.createdBy`, who let the person in against a denial is `overriddenBy`), recorded on the
  arrival as one of two: a plan benefit
  (a Pricing Plans credit pack or unlimited plan, with its `type`) or a scheduled event (the session they
  were booked into, with nothing to redeem). Set on a granted arrival; on an override, the benefit or event the
  engine had found.
- **Redemption**: Taking the credit in Pricing Plans, which runs after the person is let in so an entry
  is never delayed or refused by it. It is not recorded on the arrival; credits left are read from Pricing
  Plans. A scheduled event has nothing to redeem.
- **Override**: A site user's decision, with a reason, to let in a person the engine denied. Override Arrival as Granted with the
  arrival's ID; the status moves to `GRANTED` on the evaluation the arrival was denied with, and its benefit is redeemed. When a site user decides before the
  call, `denialOverride` on Create Arrival leaves the same record in one step.

