> 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
# CountSubmissions
# Package: forms
# Namespace: FormSubmissionService
# Method link: https://dev.wix.com/docs/api-reference/crm/forms/form-submissions/count-submissions.md
## Permission Scopes:
Read Submissions: SCOPE.DC-FORMS.READ-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.
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.
Counts the number of submissions belonging to the specified forms.
URL: https://www.wixapis.com/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 | description: Form GUIDs. | required: true
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
param name: statuses | type: array | description: List of statuses of submissions which should be taken into count Default: CONFIRMED, PAYMENT_WAITING, PAYMENT_CANCELED
- 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 | description: Forms submission count.
- name: formId | type: string | description: Form 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 \
'http://www.wixapis.com/form-submission/v4/submissions/count' \
-H 'Content-Type: application/json' \
-H 'Authorization: ' \
-d '{
"formIds": [
"e62e3011-55cf-4de3-a497-e097b52d86b8"
],
"namespace": "wix.form_app.form"
}'
~~~
```
---
## JavaScript SDK
### Schema
```
Method: wixClientAdmin.forms.FormSubmissionService.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.
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 | description: Form GUIDs which submissions should be counted. | required: true
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
param name: options | type: CountSubmissionsOptions none
- name: statuses | type: array | description: List of statuses of submissions which should be taken into count Default: CONFIRMED, PAYMENT_WAITING, PAYMENT_CANCELED
- 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
- name: formsSubmissionsCount | type: array | description: Forms submission count.
- name: formId | type: string | description: Form 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-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 { 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);
};
```
---