v1

latestOpenAPI 3.1.02026-07-2466150275.0 KB
Form Instances

Aggregate Form Instances

Aggregate form instances with GROUP BY operations.

Allows grouping by status, form_id, type_id, site_id, and other fields with aggregation functions like COUNT, SUM, AVG, MIN, MAX. Uses the same base filters and company scoping as the search endpoint for consistent behavior.

post/v1/form-instance/aggregate

Request body

querystring nullable

Keywords should be space separated and are ANDed together, so all keywords must be present but they can be present in any of the fields specified above.

skipinteger nullable

Number of records to skip before returning records

limitinteger nullable

Number of records to return

sort_direction'asc' | 'desc'

Direction to sort the sort_column - ascending or descending.

date_startstring date-time nullable

If sorting on updated_at or created_at, and date_cut_off is provided, return only records that were created or updated (whichever is being sorted on) between date_start and date_cut_off

date_cut_offstring date-time nullable

If sorting on updated_at or created_at, return only records that were created or updated (whichever is being sorted on) between the initial value (determined by sort order) and the cutoff date.

For example, sorting on created_at ascending with a date_cut_off will return all records from the oldest creation date to the cutoff date. By comparison, sorting on created_at descending with a date_cut_off will return all records from the most recent creation date to the cutoff date.

sort_columnstring nullable

Column to sort aggregation results by (must be in group_by or an aggregation alias)

group_bystring[] required

Column names to group by

date_filter_column'created_at' | 'updated_at' | 'submitted_on'

Column to apply date_start/date_cut_off filters on. One of 'created_at', 'updated_at', or 'submitted_on' (excludes drafts since they have no submitted_on).

is_archivedboolean nullable

Filter by entity archived status. Defaults to False (only active entities). Use True for archived only, None to include all.

project_is_archivedboolean nullable

Filter by parent project's archived status. Defaults to False (only active projects). Use True for archived projects only, None to include all.

query_mode'own' | 'shared'

Specify the search mode for the form instances.

form_instance_status'draft' | 'draft_pending_review' | 'pending_review' | 'completed' | 'disapproved'

The status of the form instances.

form_idinteger nullable

Filter to submissions of a specific form template.

site_idinteger nullable

Filter to submissions at a specific site.

type_idinteger nullable

Filter to submissions of a specific form type.

submitted_by_user_idinteger nullable

Filter to submissions by a specific user.

asset_idinteger nullable

Filter to submissions for a specific asset.

Example request

{
  "aggregations": [
    {
      "alias": "total_submissions",
      "column": "id",
      "operator": "count"
    },
    {
      "alias": "unique_sites",
      "column": "site_id",
      "operator": "count_distinct"
    }
  ],
  "date_filter_column": "updated_at",
  "group_by": [
    "status",
    "form_id"
  ],
  "is_archived": false,
  "limit": 50,
  "project_is_archived": false,
  "query_mode": "own",
  "skip": 0,
  "sort_column": "total_submissions",
  "sort_direction": "desc"
}

Response

Successful Response

errorboolean

A boolean error indicator.

messagestring nullable

Optional message.

Example response

{
  "data": {
    "data": [
      {
        "form_id": 101,
        "status": "completed",
        "total_submissions": 250,
        "unique_sites": 15
      },
      {
        "form_id": 102,
        "status": "completed",
        "total_submissions": 180,
        "unique_sites": 12
      },
      {
        "form_id": 101,
        "status": "pending_review",
        "total_submissions": 45,
        "unique_sites": 8
      }
    ],
    "metadata": {
      "aggregations": [
        {
          "alias": "total_submissions",
          "column": "id",
          "operator": "count"
        },
        {
          "alias": "unique_sites",
          "column": "site_id",
          "operator": "count_distinct"
        }
      ],
      "group_by_columns": [
        "status",
        "form_id"
      ]
    },
    "total_groups": 3
  }
}