> 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

# CountEventsByStatus

# Package: eventManagement

# Namespace: EventManagement

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/events-v3/count-events-by-status.md

## Permission Scopes:
Read Events: SCOPE.DC-EVENTS.READ-EVENTS

## Introduction

Counts events by status.

See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters.
To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).

---

## REST API

### Schema

```
 Method: countEventsByStatus
 Description: Counts events by status.  See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).
 URL: https://www.wixapis.com/events/v3/events/count-by-status
 Method: POST
 Method parameters:
   param name: facet | type: array<facet> | description: Parameters to count events by.  | validation: maxItems 20, maxLength 100
   param name: filter | type: filter | description: Filter object in the following format: <br/> `"filter" : { "fieldName1": "value1" }`.  
   param name: includeDrafts | type: includeDrafts | description: Whether draft events should be returned in the response. <br> **Note:** This parameter requires the `WIX_EVENTS.READ_DRAFT_EVENTS` permission.  
 Return type: CountEventsByStatusResponse
  - name: pagingMetadata | type: PagingMetadataV2 | description: Metadata for the paginated results.  
     - name: count | type: integer | description: Number of items to return. See [Paging](https://dev.wix.com/api/rest/getting-started/sorting-and-paging#getting-started_sorting-and-paging_paging) for more information.  | validation: format int32
     - name: offset | type: integer | description: Requested offset.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Not returned. Events methods support offset paging only: use `offset` and `total` to page through results.  
        - name: next | type: string | description: Cursor pointing to the next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  
  - name: facets | type: Map<string,FacetCounts> | description: Filter facets.  | validation: format map
     - name: counts | type: object | description: Facet counts aggregated per value  | validation: format map

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILTER_PARSER_ERROR | Description: The `filter` syntax is invalid.


```

### Examples

### Count events by the "Canceled" status
```curl
curl -X POST 'https://www.wixapis.com/events/v3/events/count-by-status' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH TOKEN>' \
-d '{
  "filter": {
    "status": {
      "$eq": "CANCELED"
    }
  },
  "facet": ["status"],
  "includeDrafts": false
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.events.wixEventsV2.countEventsByStatus(options)
 Description: Counts events by status.  See [Query Events](https://dev.wix.com/docs/rest/business-solutions/events/events-v3/query-events.md) for a list of supported filters. To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).
 Method parameters:
   param name: options | type: CountEventsByStatusOptions  none  
        - name: filter | type: object | description: Filter object in the following format: <br/> `"filter" : { "fieldName1": "value1" }`.  
        - name: facet | type: array<string> | description: Parameters to count events by.  | validation: maxItems 20, maxLength 100
        - name: includeDrafts | type: boolean | description: Whether draft events should be returned in the response. <br> **Note:** This parameter requires the `WIX_EVENTS.READ_DRAFT_EVENTS` permission.  
 Return type: PROMISE<CountEventsByStatusResponse>
  - name: pagingMetadata | type: PagingMetadataV2 | description: Metadata for the paginated results.  
     - name: count | type: integer | description: Number of items to return. See [Paging](https://dev.wix.com/api/rest/getting-started/sorting-and-paging#getting-started_sorting-and-paging_paging) for more information.  | validation: format int32
     - name: offset | type: integer | description: Requested offset.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Not returned. Events methods support offset paging only: use `offset` and `total` to page through results.  
        - name: next | type: string | description: Cursor pointing to the next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  
  - name: facets | type: Map<string,FacetCounts> | description: Filter facets.  | validation: format map
     - name: counts | type: object | description: Facet counts aggregated per value  | validation: format map

 Possible Errors:
   HTTP Code: 400 | Status Code: INVALID_ARGUMENT | Application Code: FILTER_PARSER_ERROR | Description: The `filter` syntax is invalid.


```

### Examples

### Count events by status
```javascript
import { wixEventsV2 } from "@wix/events";

async function countEventsByStatus() {
  const response = await wixEventsV2.countEventsByStatus({});
}

```

### countEventsByStatus (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 { wixEventsV2 } from '@wix/events';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function countEventsByStatus(options) {
  const response = await myWixClient.wixEventsV2.countEventsByStatus(options);
};
```

---