> 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

# CountSubmissions

# Package: forms

# Namespace: FormSubmissionService

# Method link: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/count-submissions.md

## Permission Scopes:
Manage form submissions.: SCOPE.FORMS.MANAGE-SUBMISSIONS

## Introduction

> **Note:** The Form Submission API only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site.
<br>
Counts the number of submissions belonging to the specified forms.

---

## REST API

### Schema

```
 Method: countSubmissions
 Description: > **Note:** The Form Submission API only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site. <br> Counts the number of submissions belonging to the specified forms.
 URL: https://www.wixapis.com/form-submission-service/v4/submissions/count
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  formIds, namespace
 Method parameters: 
   param name: formIds | type: array<formIds> | description: Form GUIDs. | required: true | validation: minItems 1, maxItems 100, format GUID
   param name: namespace | type: namespace | description: Identifies the app which the form submissions belong to. For example, the namespace for the Wix Forms App is `"wix.form_app.form"`. The namespace of a submission can be retrieved using the Get Submission endpoint. | required: true | validation: minLength 10, maxLength 50
   param name: statuses | type: array<statuses> | description: List of statuses of submissions which should be taken into count Default: CONFIRMED, PAYMENT_WAITING, PAYMENT_CANCELED  | validation: maxItems 4
                 - enum:
                 -     PENDING: A submission is created, but has not yet been recorded in the Wix Forms collection.
                 -     CONFIRMED: A submission is recorded in the Wix Forms collection.
                 -     PAYMENT_WAITING: A form submission requiring payment is created.
                 -     PAYMENT_CANCELED: An order of a form submission is canceled.
 Return type: CountSubmissionsResponse
  - name: formsSubmissionsCount | type: array<FormSubmissionsCount> | description: Forms submission count.  
     - name: formId | type: string | description: Form GUID.  | validation: format GUID
     - name: totalCount | type: integer | description: Total number of submissions.  
     - name: unseenCount | type: integer | description: Number of submissions that haven't yet been seen by site Extensions with manage submission permissions.  


```

### Examples

### CountSubmissions
```curl
~~~cURL
curl -X POST \
  'https://www.wixapis.com/form-submission-service/v4/submissions/count' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
    "formIds": [
      "e62e3011-55cf-4de3-a497-e097b52d86b8"
    ],
    "namespace": "wix.form_app.form"
  }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.forms.submissions.countSubmissions(formIds, namespace, options)
 Description: > **Note:** The Form Submission API only works with the Wix Forms app. Call [GetAppInstance](https://dev.wix.com/docs/rest/api-reference/app-management/apps/app-instance/get-app-instance.md) to confirm that the app named `wix_forms` is installed on the site. <br> Counts the number of submissions belonging to the specified forms.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  formIds, namespace
 Method parameters: 
   param name: formIds | type: array<string> | description: Form GUIDs which submissions should be counted. | required: true | validation: minItems 1, maxItems 100, format GUID
   param name: namespace | type: string | description: The app which the form submissions belong to. For example, the namespace for the Wix Forms app is `wix.form_app.form`. Call `getSubmission()` to retrieve the namespace. | required: true | validation: minLength 10, maxLength 50
   param name: options | type: CountSubmissionsOptions  none  
        - name: statuses | type: array<SubmissionStatus> | description: List of statuses of submissions which should be taken into count Default: CONFIRMED, PAYMENT_WAITING, PAYMENT_CANCELED  | validation: maxItems 4
             - enum:
             -     PENDING: A submission is created, but has not yet been recorded in the Wix Forms collection.
             -     CONFIRMED: A submission is recorded in the Wix Forms collection.
             -     PAYMENT_WAITING: A form submission requiring payment is created.
             -     PAYMENT_CANCELED: An order of a form submission is canceled.
 Return type: PROMISE<CountSubmissionsResponse>
  - name: formsSubmissionsCount | type: array<FormSubmissionsCount> | description: Forms submission count.  
     - name: formId | type: string | description: Form GUID.  | validation: format GUID
     - name: totalCount | type: integer | description: Total number of submissions.  
     - name: unseenCount | type: integer | description: Number of submissions that haven't yet been seen by site Extensions with manage submission permissions.  


```

### Examples

### Count submissions (with elevated permissions)
```javascript
import { submissions } from '@wix/forms';
import { auth } from '@wix/essentials';

/* 
Sample formIds value: ["21bcb6c7-02b3-4ed1-b6db-7856094fac03"]
Sample namespace value: "wix.form_app.form"
*/

const elevatedCountSubmissions = auth.elevate(submissions.countSubmissions);

export async function myCountSubmissionsFunction(formIds, namespace) {
  try {
    const formsSubmissionsCount = await elevatedCountSubmissions(formIds, namespace);
    console.log('Success! Forms submissions count:', formsSubmissionsCount);
    return formsSubmissionsCount;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
{
    "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",
    "totalCount": 4,
    "unseenCount": 2
}
*/
```

### Count submissions
```javascript
import { submissions } from '@wix/forms';

/* 
Sample formIds value: ["21bcb6c7-02b3-4ed1-b6db-7856094fac03"]
Sample namespace value: "wix.form_app.form"
*/

export async function myCountSubmissionsFunction(formIds, namespace) {
  try {
    const formsSubmissionsCount = await submissions.countSubmissions(formIds, namespace);
    console.log('Success! Forms submissions count:', formsSubmissionsCount);
    return formsSubmissionsCount;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
{
    "formId": "21bcb6c7-02b3-4ed1-b6db-7856094fac03",
    "totalCount": 4,
    "unseenCount": 2
}
*/
```

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

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


async function countSubmissions(formIds,namespace,options) {
  const response = await myWixClient.submissions.countSubmissions(formIds,namespace,options);
};
```

---