> 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

# CountBadgeAssignments

# Package: activity

# Namespace: BadgeAssignments

# Method link: https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/count-badge-assignments.md

## Permission Scopes:
Manage Badges: SCOPE.DC-MEMBERS.MANAGE-BADGES

## Introduction

Counts the badge assignments that match the provided filter.

Returns a single count for the whole filter. You can combine `badgeId` and `memberId`
in one filter, and pass several IDs to either field with `$in`. An empty filter counts every badge assignment on the site.

A member can hold each badge only once, so filtering by a single `badgeId` returns the number of members who have that badge.

To retrieve the badge assignments themselves, call [Query Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/query-badge-assignments.md).

---

## REST API

### Schema

```
 Method: countBadgeAssignments
 Description: Counts the badge assignments that match the provided filter.  Returns a single count for the whole filter. You can combine `badgeId` and `memberId` in one filter, and pass several GUIDs to either field with `$in`. An empty filter counts every badge assignment on the site.  A member can hold each badge only once, so filtering by a single `badgeId` returns the number of members who have that badge.  To retrieve the badge assignments themselves, call [Query Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/query-badge-assignments.md).
 URL: https://www.wixapis.com/badges/v4/assignments/count
 Method: POST
 Method parameters:
   param name: filter | type: filter | description: Filter object for the badge assignments to count. Supports the same filters as [Query Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/query-badge-assignments.md). See [Supported Filters and Sorting](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/supported-filters-and-sorting.md) for details.  Supported properties: `badgeId`, `memberId`  Default: Empty filter, which counts every badge assignment on the site.  
 Return type: CountBadgeAssignmentsResponse
  - name: count | type: integer | description: Number of badge assignments that match the filter.  


```

### Examples

### Count Badge Assignments
```curl
curl -X POST \
  https://www.wixapis.com/badges/v4/assignments/count \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
        "filter": {
          "badgeId": "1cdd939f-6de3-4889-ac2d-872da517f9e9"
        }
      }'
```

### Count Badge Assignments for several badges
```curl
curl -X POST \
  https://www.wixapis.com/badges/v4/assignments/count \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
        "filter": {
          "badgeId": {
            "$in": [
              "1cdd939f-6de3-4889-ac2d-872da517f9e9",
              "d3405ceb-5640-46e3-8163-5f110bf1db3a"
            ]
          }
        }
      }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.members.badgeAssignments.countBadgeAssignments(options)
 Description: Counts the badge assignments that match the provided filter.  Returns a single count for the whole filter. You can combine `badgeId` and `memberId` in one filter, and pass several GUIDs to either field with `$in`. An empty filter counts every badge assignment on the site.  A member can hold each badge only once, so filtering by a single `badgeId` returns the number of members who have that badge.  To retrieve the badge assignments themselves, call [Query Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/query-badge-assignments.md).
 Method parameters:
   param name: options | type: CountBadgeAssignmentsOptions  none  
        - name: filter | type: object | description: Filter object for the badge assignments to count. Supports the same filters as [Query Badge Assignments](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/query-badge-assignments.md). See [Supported Filters and Sorting](https://dev.wix.com/docs/api-reference/crm/members-contacts/members/activity/badge-assignments/supported-filters-and-sorting.md) for details.  Supported properties: `badgeId`, `memberId`  Default: Empty filter, which counts every badge assignment on the site.  
 Return type: PROMISE<CountBadgeAssignmentsResponse>
  - name: count | type: integer | description: Number of badge assignments that match the filter.  


```

### Examples

### countBadgeAssignments
```javascript
import { badgeAssignments } from '@wix/members';

async function countBadgeAssignments(options) {
  const response = await badgeAssignments.countBadgeAssignments(options);
};
```

### countBadgeAssignments (with elevated permissions)
```javascript
import { badgeAssignments } from '@wix/members';
import { auth } from '@wix/essentials';

async function myCountBadgeAssignmentsMethod(options) {
  const elevatedCountBadgeAssignments = auth.elevate(badgeAssignments.countBadgeAssignments);
  const response = await elevatedCountBadgeAssignments(options);
}
```

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

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


async function countBadgeAssignments(options) {
  const response = await myWixClient.badgeAssignments.countBadgeAssignments(options);
};
```

---