Statistics API
The Statistics API allows you to retrieve aggregated analytics data across systems in Doc Gen. It supports both standard REST and Prometheus-compatible metrics access.
This API is useful for:
- Monitoring user and system activity
- Integrating usage data with BI tools like Power BI or Prometheus
Authentication is based on OAuth 2.0 client credentials. To get a token, see Authentication and the Statistics authentication page. For the data model and the use cases, see the Statistics documentation and the endpoints page.
Get analytics data
GET https://api.statistics-v2.metaforce.net/analytics
| Parameter | What it is |
|---|---|
startDate | The start of the date range. Send it on every call. |
toDate | The end of the date range. Optional. |
pageNumber | The page to return. The default is 1. |
pageSize | Records per page, from 1 to 1000. The default is 500. |
A value outside those limits is answered with 400.
The response is one page of data:
| Field | What it is |
|---|---|
pageNumber, pageSize | The page you asked for. |
totalRecords, totalPages | How much data matches your date range. |
data | The records of this page. |
Each record in data has event, system, template, source, distribution, environment, area, count and eventDetail. Records that are counted per day or per hour also have date and hour. count is how many times the event happened.
{
"pageNumber": 1,
"pageSize": 500,
"totalRecords": 235,
"totalPages": 1,
"data": [
{
"event": "Submit",
"system": "Smartforms",
"date": "2026-09-01",
"template": "Employee onboarding",
"environment": "Production",
"count": 42
}
]
}Below is a JavaScript example using axios to fetch a range of paginated statistics data. It assumes you already have a valid access token.
const axios = require('axios').default;
const token = "<Bearer token>";
const pageSize = 1000;
const pageNumber = 1;
const startDate = '2026-09-01T00:00:00Z';
const toDate = '2026-09-30T23:59:59Z';
const apiUrl = `https://api.statistics-v2.metaforce.net/analytics?pageSize=${pageSize}&pageNumber=${pageNumber}&startDate=${startDate}&toDate=${toDate}`;
const requestOptions = {
method: 'GET',
url: apiUrl,
headers: {
'Authorization': `Bearer ${token}`
}
};
axios(requestOptions)
.then(response => {
console.log(response.data);
});
To get everything, keep asking for the next pageNumber until you have passed totalPages.
Get Prometheus metrics
GET https://api.statistics-v2.metaforce.net/analytics/prometheus?startDate=2026-09-01T00:00:00Z&toDate=2026-09-30T23:59:59Z
startDate and toDate are both optional. The response is plain text in the Prometheus format, with one line for each event count, so a Prometheus server can read it directly. Each line starts with the event name in lower case, followed by _event_count, then the values of the record as labels in braces and the count:
submit_event_count{system="Smartforms", date="2026-09-01", template="Employee onboarding", source="", distribution="", environment="Production", area="", eventdetail=""} 42date and hour appear only on records that have them. The other labels are always there, with an empty value when the record has none. A date range with no data gives an empty response.