v1

latestOpenAPI 3.1.02026-07-2466150275.0 KB
Certificates

Aggregate Certificates

Aggregate certificates with GROUP BY operations.

Allows grouping by status, type, 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/certificate/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'

Column to apply date_start/date_cut_off filters on (created_at or updated_at)

is_archivedboolean nullable

Not used for certificates. Use 'archived' parameter instead.

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.

archivedboolean nullable

Filter by archived status. Defaults to False (only active certificates). Use None to include all.

expiredboolean nullable

Filter by expiry status before aggregating. True = only expired, False = only not-expired, None = include all.

expiry_date_fromstring date-time nullable

Filter certificates with expiry_date on or after this date (inclusive) before aggregating.

expiry_date_tostring date-time nullable

Filter certificates with expiry_date strictly before this date (exclusive) before aggregating.

user_idinteger nullable

Filter to certificates for a specific user.

company_certification_type_idinteger nullable

Filter to certificates with a specific company certification type ID.

Example request

{
  "aggregations": [
    {
      "alias": "total_certs",
      "column": "id",
      "operator": "count"
    },
    {
      "alias": "unique_holders",
      "column": "user_id",
      "operator": "count_distinct"
    }
  ],
  "archived": false,
  "date_filter_column": "updated_at",
  "group_by": [
    "company_certification_type_id",
    "offline"
  ],
  "limit": 100,
  "project_is_archived": false,
  "query": "safety",
  "skip": 0,
  "sort_column": "company_certification_type_id",
  "sort_direction": "desc"
}

Response

Successful Response

errorboolean

A boolean error indicator.

messagestring nullable

Optional message.

Example response

{
  "data": {
    "data": [
      {
        "company_certification_type_id": 1,
        "offline": false,
        "total_certs": 45,
        "unique_holders": 38
      },
      {
        "company_certification_type_id": 1,
        "offline": true,
        "total_certs": 12,
        "unique_holders": 10
      },
      {
        "company_certification_type_id": 2,
        "offline": false,
        "total_certs": 28,
        "unique_holders": 28
      }
    ],
    "metadata": {
      "aggregations": [
        {
          "alias": "total_certs",
          "column": "id",
          "operator": "count"
        },
        {
          "alias": "unique_holders",
          "column": "user_id",
          "operator": "count_distinct"
        }
      ],
      "group_by_columns": [
        "company_certification_type_id",
        "offline"
      ]
    },
    "total_groups": 3
  }
}