> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # CountItems # Package: benefitPrograms # Namespace: ItemService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/items/count-items.md ## Permission Scopes: SCOPE.BENEFIT_PROGRAMS.READ (PII): SCOPE.BENEFIT_PROGRAMS.READ_LIMITED ## Introduction Counts how many benefit items exist that fulfill the specified filtering conditions. For a list of supported filters, see [Filtering and Sorting](https://dev.wix.com/docs/rest/business-solutions/benefit-programs/items/filtering-and-sorting.md). --- ## REST API ### Schema ``` Method: countItems Description: Counts how many benefit items exist that fulfill the specified filtering conditions. For a list of supported filters, see [Filtering and Sorting](https://dev.wix.com/docs/rest/business-solutions/benefit-programs/items/filtering-and-sorting.md). URL: https://www.wixapis.com/benefit-programs/v1/items/count Method: POST Method parameters: param name: filter | type: filter | description: Items to count. Filter options. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md). Return type: CountItemsResponse - name: count | type: integer | description: Number of items fulfilling the specified filter conditions. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: TOO_MANY_TO_COUNT | Description: Number of items exceeds the server's limit. ``` ### Examples ### CountItems ```curl ~~~cURL curl -X POST "https://www.wixapis.com/benefit-programs/v1/items/count" -H 'Content-type: application/json' \ -H 'Authorization: ' -d "{ "filter": { "externalId": { "$eq": "3f9a7c91-4e2b-4d5e-b6f8-0c2e5a9d4f34" } } }" ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.benefitPrograms.ItemService.countItems(options) Description: Counts how many benefit items exist that fulfill the specified filtering conditions. For a list of supported filters, see [Filtering and Sorting](https://dev.wix.com/docs/rest/business-solutions/benefit-programs/items/filtering-and-sorting.md). Method parameters: param name: options | type: CountItemsOptions none - name: filter | type: object | description: Items to count. Filter options. See [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md). Return type: PROMISE - name: count | type: integer | description: Number of items fulfilling the specified filter conditions. Possible Errors: HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: TOO_MANY_TO_COUNT | Description: Number of items exceeds the server's limit. ``` ### Examples ### countItems ```javascript import { items } from '@wix/benefit-programs'; async function countItems(options) { const response = await items.countItems(options); }; ``` ### countItems (with elevated permissions) ```javascript import { items } from '@wix/benefit-programs'; import { auth } from '@wix/essentials'; async function myCountItemsMethod(options) { const elevatedCountItems = auth.elevate(items.countItems); const response = await elevatedCountItems(options); } ``` ### countItems (self-hosted) Self-hosted 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 { items } from '@wix/benefit-programs'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { items }, // Include the auth strategy and host as relevant }); async function countItems(options) { const response = await myWixClient.items.countItems(options); }; ``` ---