> 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

# QueryAttendance

# Package: bookings

# Namespace: AttendanceService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/bookings/bookings/attendance/query-attendance?apiView=SDK.md

## Permission Scopes:
Read Bookings - Including Participants: SCOPE.DC-BOOKINGS.READ-BOOKINGS-SENSITIVE

## Introduction

Retrieves up to 100 `attendance` objects, given the specified
paging, filtering, and sorting.


When querying attendance information, you can query from the perspective of:
+ **A booking.** Specify a booking ID to retrieve attendance information
for all sessions related to that booking. For example, query by `bookingId`
for a course booking to retrieve a participant's attendance for all course
sessions.
+ **A session.** Specify a session ID to retrieve attendance information
for all bookings related to that session.

Query Attendance runs with the following defaults, which you can override:
- `id` sorted in `ASC` order.
- `cursorPaging.limit` set to `50`.

Only a single filter is supported per query. If you define multiple filters
in the same query, only the first is processed.

To learn about working with query methods, see
[API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).

---

## REST API

### Schema

```
 Method: queryAttendance
 Description: Retrieves up to 100 `attendance` objects, given the specified paging, filtering, and sorting.   When querying attendance information, you can query from the perspective of: + **A booking.** Specify a booking GUID to retrieve attendance information for all sessions related to that booking. For example, query by `bookingId` for a course booking to retrieve a participant's attendance for all course sessions. + **A session.** Specify a session GUID to retrieve attendance information for all bookings related to that session.  Query Attendance runs with the following defaults, which you can override: - `id` sorted in `ASC` order. - `cursorPaging.limit` set to `50`.  Only a single filter is supported per query. If you define multiple filters in the same query, only the first is processed.  To learn about working with query methods, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).
 URL: https://www.wixapis.com/bookings/bookings-attendance/query
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: QueryV2   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. In the first request, specify `cursorPaging.limit`. For following requests, specify the retrieved `cursorPaging.cursor` token and not `query.filter` or `query.sort`.  
        - name: limit | type: integer | description: Number of `Attendance` objects to return.  Default: `50` Maximum: `1000`  | validation: minimum 0, maximum 1000, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response.  Not relevant for the first request.  
        - name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.  Max: 1 filter  
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[ {"fieldName":"sortField1","order":"ASC"}, {"fieldName":"sortField2","order":"DESC"} ]`  
           - name: fieldName | type: string | description: Name of the field to sort by.  
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: id | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: bookingId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: sessionId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: eventId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: numberOfAttendees | operators: $eq, $ne, $in, $nin, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryAttendanceResponse
  - name: attendances | type: array<Attendance> | description: List of `attendance` objects that contain attendance information for a booked session.  
     - name: id | type: string | description: GUID of the `attendance` object.  | read-only: true | validation: format GUID
     - name: bookingId | type: string | description: Corresponding booking GUID.  | validation: format GUID
     - name: status | type: AttendanceStatus | description: Status indicating if any participants attended the session.  
         - enum:
         -     NOT_SET: There is no available attendance information.
         -     ATTENDED: At least a single participant attended the session.
         -     NOT_ATTENDED: No participants attended the session.
     - name: numberOfAttendees | type: integer | description: Total number of participants that attended the session. By default, the number of attendees is set to `1`, but you can set a number to greater than `1` if multiple participants attended.  Do not set to `0` to indicate that no one attended the session. Instead, set the `status` field to `NOT_ATTENDED`.  Default: 1  
     - name: eventId | type: string | description: Corresponding [event GUID](https://dev.wix.com/docs/api-reference/business-management/calendar/events-v3/event-object.md). Use this field instead of the deprecated `sessionId`. You can retrieve the event GUID from the booking's slot `booking.bookedEntity.slot.eventId`.  | validation: minLength 36, maxLength 250
  - name: pagingMetadata | type: CursorPagingMetadata | description: Metadata for the paged set of results.  
     - name: cursors | type: Cursors | description: Use these cursors to paginate between results. [Read more](https://dev.wix.com/api/rest/getting-started/api-query-language#getting-started_api-query-language_cursor-paging).  
        - name: next | type: string | description: Cursor pointing to next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  
     - name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.  


```

### Examples

### Query attendance information by status
Retrieves information about sessions that were not attended.

```curl
curl -X POST \
'https://www.wixapis.com/bookings/v2/attendance/query' \
-H 'Authorization:  <AUTH>' \
-d '{
  "query": {
    "filter": {
      "status": "NOT_ATTENDED"
    }
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.bookings.attendance.queryAttendance(query)
 Description: Retrieves up to 100 `attendance` objects, given the specified paging, filtering, and sorting.   When querying attendance information, you can query from the perspective of: + **A booking.** Specify a booking GUID to retrieve attendance information for all sessions related to that booking. For example, query by `bookingId` for a course booking to retrieve a participant's attendance for all course sessions. + **A session.** Specify a session GUID to retrieve attendance information for all bookings related to that session.  Query Attendance runs with the following defaults, which you can override: - `id` sorted in `ASC` order. - `cursorPaging.limit` set to `50`.  Only a single filter is supported per query. If you define multiple filters in the same query, only the first is processed.  To learn about working with query methods, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: AttendanceQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. In the first request, specify `cursorPaging.limit`. For following requests, specify the retrieved `cursorPaging.cursor` token and not `query.filter` or `query.sort`.  
        - name: limit | type: integer | description: Number of `Attendance` objects to return.  Default: `50` Maximum: `1000`  | validation: minimum 0, maximum 1000, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response.  Not relevant for the first request.  
        - name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.  Max: 1 filter  
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[ {"fieldName":"sortField1","order":"ASC"}, {"fieldName":"sortField2","order":"DESC"} ]`  
           - name: fieldName | type: string | description: Name of the field to sort by.  
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: _id | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: bookingId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: sessionId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: eventId | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $nin | sort: ASC | aggregatable: undefined | searchable: undefined
   - field: numberOfAttendees | operators: $eq, $ne, $in, $nin, $lt, $lte, $gt, $gte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryAttendanceResponse>
  - name: attendances | type: array<Attendance> | description: List of `attendance` objects that contain attendance information for a booked session.  
     - name: _id | type: string | description: GUID of the `attendance` object.  | read-only: true | validation: format GUID
     - name: bookingId | type: string | description: Corresponding booking GUID.  | validation: format GUID
     - name: status | type: AttendanceStatus | description: Status indicating if any participants attended the session.  
         - enum:
         -     NOT_SET: There is no available attendance information.
         -     ATTENDED: At least a single participant attended the session.
         -     NOT_ATTENDED: No participants attended the session.
     - name: numberOfAttendees | type: integer | description: Total number of participants that attended the session. By default, the number of attendees is set to `1`, but you can set a number to greater than `1` if multiple participants attended.  Do not set to `0` to indicate that no one attended the session. Instead, set the `status` field to `NOT_ATTENDED`.  Default: 1  
     - name: eventId | type: string | description: Corresponding [event GUID](https://dev.wix.com/docs/api-reference/business-management/calendar/events-v3/event-object.md). Use this field instead of the deprecated `sessionId`. You can retrieve the event GUID from the booking's slot `booking.bookedEntity.slot.eventId`.  | validation: minLength 36, maxLength 250
  - name: pagingMetadata | type: CursorPagingMetadata | description: Metadata for the paged set of results.  
     - name: cursors | type: Cursors | description: Use these cursors to paginate between results. [Read more](https://dev.wix.com/api/rest/getting-started/api-query-language#getting-started_api-query-language_cursor-paging).  
        - name: next | type: string | description: Cursor pointing to next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  
     - name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.  


```

### Examples

### Query attendance for a booking
```javascript
import { attendance } from "@wix/bookings";

async function queryAttendance() {
  const response = await attendance.queryAttendance({
    filter: { bookingId: "12345678-1234-1234-1234-123456789abc" },
    sort: [{ fieldName: "numberOfAttendees", order: "DESC" }],
    cursorPaging: { limit: 50 },
  });
  return response;
}

/* Promise resolves to:
 * {
 *   attendances: [
 *     {
 *       _id: "f3197ab6-4900-4533-a765-f0c719fe00b9",
 *       bookingId: "12345678-1234-1234-1234-123456789abc",
 *       status: "ATTENDED",
 *       numberOfAttendees: 2,
 *       eventId: "11111111-1111-1111-1111-111111111111"
 *     }
 *   ],
 *   pagingMetadata: {
 *     totalCount: 1,
 *     cursors: {},
 *     hasNext: false
 *   }
 * }
 */

```

### queryAttendance (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { attendance } from '@wix/bookings';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { attendance },
  // Include the auth strategy and host as relevant
});


async function queryAttendance(query) {
  const response = await myWixClient.attendance.queryAttendance(query);
};
```

---