> For the complete documentation index, see [llms.txt](https://k-ai.gitbook.io/knowledge-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://k-ai.gitbook.io/knowledge-ai/k-ai-audit/api-reference/stats.md).

# Stats

Daily, per-user, and filtered aggregate statistics for an audit instance — the worklist counters consumed by K-AI Audit web app dashboards.

This page covers 3 operations.

Auth: OAuth 2.1 Bearer token (MCP) or the `kai_auth` HttpOnly cookie (browsers) — see [OAuth 2.1](/knowledge-ai/authentication/oauth.md).

***

## audit\_stats\_get\_filtered

`POST /audit/stats/get-filtered-stats`

Return the home-page card counters used by the K-AI Audit web app — total questions, questions with conflicts, managed vs unmanaged conflicts, missing-subject count, documents-to-update count, estimated total update time, and so on. When `need_detect_owner_document_feature` is enabled, the counters are filtered to the caller's owned documents.

{% openapi src="/files/LsPumOBZAN25uU285Xuz" path="/audit/stats/get-filtered-stats" method="post" %}
[audit-api.yaml](https://3937809777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F85gF5n5kGsNQKMPwm2VR%2Fuploads%2Fgit-blob-00a25a57ce88a8c396c05c4686ed7c88c8fa834a%2Faudit-api.yaml?alt=media)
{% endopenapi %}

{% tabs %}
{% tab title="curl" %}

```bash
curl -X POST https://api-audit.kai-studio.ai/audit/stats/get-filtered-stats \
  -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"instance_id": "ki_abc123"}'
```

{% endtab %}

{% tab title="Python" %}

```python
import httpx

response = httpx.post(
    "https://api-audit.kai-studio.ai/audit/stats/get-filtered-stats",
    headers={"Authorization": f"Bearer {access_token}"},
    json={"instance_id": "ki_abc123"},
)
response.raise_for_status()
print(response.json())
```

{% endtab %}

{% tab title="TypeScript" %}

```ts
const response = await fetch(
  "https://api-audit.kai-studio.ai/audit/stats/get-filtered-stats",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${accessToken}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ instance_id: "ki_abc123" }),
  },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

{% endtab %}
{% endtabs %}

### Response fields

| Field                                | Description                                                   |
| ------------------------------------ | ------------------------------------------------------------- |
| `total_questions`                    | Total number of mandatory questions on the instance.          |
| `questions_with_conflicts_to_manage` | Questions with unresolved conflicts.                          |
| `questions_with_conflicts_analyzed`  | Questions whose conflicts have been analyzed.                 |
| `managed_questions`                  | Questions transitioned to `MANAGED`.                          |
| `questions_without_conflicts`        | Questions with no detected conflicts.                         |
| `missing_subjects_count`             | Number of missing subjects on the instance.                   |
| `total_conflicts`                    | Total number of conflicts (open + closed).                    |
| `managed_important_conflicts`        | Closed conflicts with at least one applied recommendation.    |
| `documents_to_update_count`          | Documents flagged by recommendations as needing an update.    |
| `total_documents`                    | Documents in the linked K-AI instance.                        |
| `documents_with_unmanaged_conflicts` | Documents touched by at least one open conflict.              |
| `estimated_total_update_time`        | Estimated time (seconds) to apply every pending modification. |
| `questions_not_analyzed_yet`         | Questions still awaiting analysis.                            |

***

## audit\_stats\_get\_daily

`POST /audit/stats/get-daily-stats`

Daily audit stats for an instance over a date range. Pass an empty string in `user_id` to aggregate across all users.

{% openapi src="/files/LsPumOBZAN25uU285Xuz" path="/audit/stats/get-daily-stats" method="post" %}
[audit-api.yaml](https://3937809777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F85gF5n5kGsNQKMPwm2VR%2Fuploads%2Fgit-blob-00a25a57ce88a8c396c05c4686ed7c88c8fa834a%2Faudit-api.yaml?alt=media)
{% endopenapi %}

***

## audit\_stats\_get\_user

`POST /audit/stats/get-user-stats`

Per-user audit stats over a date range. Non-admins can only query their own stats. Admin queries that target another admin user return `false`.

{% openapi src="/files/LsPumOBZAN25uU285Xuz" path="/audit/stats/get-user-stats" method="post" %}
[audit-api.yaml](https://3937809777-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F85gF5n5kGsNQKMPwm2VR%2Fuploads%2Fgit-blob-00a25a57ce88a8c396c05c4686ed7c88c8fa834a%2Faudit-api.yaml?alt=media)
{% endopenapi %}

***

## Next

* [Instances](/knowledge-ai/k-ai-audit/api-reference/instances.md) — start from the dashboard.
* [Conflicts](/knowledge-ai/k-ai-audit/api-reference/conflicts.md) — drill into the work surfaced by these counters.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://k-ai.gitbook.io/knowledge-ai/k-ai-audit/api-reference/stats.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
