# Audiences

> A section of the Kumkuat API 1.0.0 reference. The rest of it: https://product.tech/docs-kumkuat-ai/api-reference.md (API Reference). Base URL: `https://api.kumkuat.ai`.

Persona categories: list and order them, summarise an audience, and generate reactions for many personas at once.

## List audiences

`GET /api/v1/audiences`

The workspace's audiences (persona categories) in display order.

### Returns (200, object)

OK

- `groups` (array of object, required)
  - `display_name` (string, nullable, for example "Investors")
  - `id` (string, required)
  - `name` (string, required, for example "investors")
  - `sort_order` (integer, default 0)

### Responses

- `200`: OK
- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "groups": [
    {
      "display_name": "Investors",
      "id": "string",
      "name": "investors",
      "sort_order": 0
    }
  ]
}
```

## Add an audience

`POST /api/v1/audiences`

Add one audience category.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## List audience category names

`GET /api/v1/audiences/categories`

The category names in use, as plain strings.

### Returns (200, object)

OK

- `categories` (array of string, required)

### Responses

- `200`: OK
- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences/categories \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "categories": [
    "investors",
    "customers",
    "employees",
    "media"
  ]
}
```

## List cached audience reactions

`GET /api/v1/audiences/reactions`

Reactions already generated in this workspace.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences/reactions \
  -H 'X-API-Key: <api key>'
```

## Get or generate audience reactions

`POST /api/v1/audiences/reactions`

Each persona reacts to the document with a letter grade, judgments, evidence and actions. Reactions are cached per persona and document; pass `force_refresh` to regenerate. `include: ["why_it_matters"]` adds a grounded note on why the document matters to each persona.

### Request body (application/json, required)

- `document` (object, required): What they react to.
  - `content` (string, nullable): The text to react to when no id is given.
  - `document_type` (string, nullable, for example "press\_release")
  - `executive` (string, nullable)
  - `id` (string, nullable): A workspace document id. Give either id, or title plus content.
  - `source_url` (string, nullable)
  - `title` (string, nullable, for example "Q3 pricing announcement")
- `force_refresh` (boolean, default false): Regenerate even when a cached reaction exists.
- `generation_source` (string, nullable, for example "api")
- `include` (array of string): Extra sections to return on each reaction. `why_it_matters`: a grounded note on why this document matters to that persona, one web-grounded model call per persona, cached for 7 days. Needs the Why-this-matters feature on the workspace; when it is off the field comes back null.
- `model` (string, nullable)
- `personas` (array of object, required): Who reacts. One entry per persona; batches are capped.
  - `communication_style` (string, nullable)
  - `concerns` (string, nullable)
  - `description` (string, nullable)
  - `id` (string, nullable): A stored persona id. Omit it and pass name/description/tone to react as an inline persona.
  - `interests` (string, nullable)
  - `name` (string, nullable)
  - `tone` (string, nullable)
- `project_id` (string, nullable): Attach the run to a project.
- `run_id` (string, nullable): Group these reactions under a run.
- `skip_save` (boolean, default false): Do not persist the generated reactions.

### Returns (200, object)

OK

- `cache_hits` (integer, required)
- `document` (object, required)
  - `document_hash` (string, nullable)
  - `document_type` (string, nullable)
  - `executive` (string, nullable)
  - `id` (string, nullable)
  - `source_url` (string, nullable)
  - `title` (string, nullable)
- `failed` (integer, required)
- `generated` (integer, required)
- `insights` (array of object, required)
  - `cache_hit` (boolean, default false)
  - `document` (object, required)
    - `document_hash` (string, nullable)
    - `document_type` (string, nullable)
    - `executive` (string, nullable)
    - `id` (string, nullable)
    - `source_url` (string, nullable)
    - `title` (string, nullable)
  - `error_message` (string, nullable)
  - `generated_at` (string, nullable)
  - `generation_source` (string, nullable)
  - `grade` (string, nullable, for example "B"): Letter grade the persona gave, A to F.
  - `insight_id` (string, nullable)
  - `model` (string, nullable)
  - `output_content` (string, required): The reaction as prose.
  - `output_json` (object): The structured reaction: key_judgments, evidence_and_signals, implications_and_actions, counterpoints_and_risks.
  - `persona` (object, required)
    - `description` (string, default "")
    - `id` (string, required)
    - `name` (string, required)
  - `prompt_version` (string, nullable)
  - `response_language` (string, nullable)
  - `status` (string, default "completed"): completed, failed or timed_out.
  - `status_counts` (object)
    - `bad` (integer, default 0)
    - `good` (integer, default 0)
    - `warn` (integer, default 0)
  - `updated_at` (string, nullable)
  - `why_it_matters` (object, nullable): Only when the request listed `why_it_matters` in `include`; null when it could not be generated.
    - `answer` (string, required): Why the document matters to this persona, grounded on current web sources and their statements.
    - `cache_hit` (boolean, default false)
    - `expires_at` (string, nullable)
    - `generated_at` (string, nullable)
    - `grounded` (boolean, required)
    - `model` (string, nullable)
    - `sources` (array of object): The statements and documents the answer cites.
- `message` (string, default "Persona reaction insights ready")
- `project_attached` (boolean, default false)
- `prompt_version` (string, required)
- `timed_out` (integer, required)
- `translation_target_language` (string, nullable)
- `translation_target_language_name` (string, nullable)
- `why_it_matters` (object, nullable): Only when the request listed `why_it_matters` in `include`.
  - `cache_hits` (integer, default 0)
  - `enabled` (boolean, required): False when the Why-this-matters feature is off for the workspace; every insight then carries null.
  - `failed` (integer, default 0)
  - `generated` (integer, default 0)
  - `requested` (integer, default 0)
- `workspace_id` (string, required)

### Responses

- `200`: OK
- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences/reactions \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"document":{"content":"string","document_type":"press_release"},"personas":[{"id":"d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"}]}'
```

### Example response

```json
{
  "cache_hits": 0,
  "document": {
    "document_hash": "string",
    "document_type": "string",
    "executive": "string",
    "id": "string",
    "source_url": "string",
    "title": "string"
  },
  "failed": 0,
  "generated": 0,
  "insights": [
    {
      "cache_hit": false,
      "document": {},
      "error_message": "string",
      "generated_at": "string",
      "generation_source": "string",
      "grade": "B"
    }
  ],
  "message": "Persona reaction insights ready",
  "project_attached": false,
  "prompt_version": "string",
  "timed_out": 0,
  "translation_target_language": "string",
  "translation_target_language_name": "string",
  "why_it_matters": {
    "cache_hits": 0,
    "enabled": true,
    "failed": 0,
    "generated": 0,
    "requested": 0
  },
  "workspace_id": "string"
}
```

## Queue audience reactions as a job

`POST /api/v1/audiences/reactions/async`

The same reactions, generated in the background; poll the returned job.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/audiences/reactions/async \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Get reaction history for a persona and document

`GET /api/v1/audiences/reactions/history`

Every reaction one persona has given to one document.

### Query parameters

- `persona_id` (string, required): The persona.
- `document_id` (string, required): The document.
- `limit` (integer): Most recent N entries.

### Returns (200, object)

OK

- `count` (integer, required)
- `document_id` (string, required)
- `entries` (array of object, required)
  - `cache_key` (string, nullable)
  - `document_hash` (string, nullable)
  - `document_id` (string, required)
  - `generated_at` (string, nullable)
  - `generation_source` (string, nullable)
  - `grade` (string, nullable)
  - `id` (string, required)
  - `model` (string, nullable)
  - `output_content` (string, default "")
  - `persona_id` (string, required)
  - `persona_name` (string, required)
  - `status_counts` (object)
    - `bad` (integer, default 0)
    - `good` (integer, default 0)
    - `warn` (integer, default 0)
- `persona_id` (string, required)

### Responses

- `200`: OK
- `422`: Unprocessable Entity

### Example request

```bash
curl 'https://api.kumkuat.ai/api/v1/audiences/reactions/history?persona_id=string&document_id=string' \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "count": 0,
  "document_id": "string",
  "entries": [
    {
      "cache_key": "string",
      "document_hash": "string",
      "document_id": "string",
      "generated_at": "string",
      "generation_source": "string",
      "grade": "string"
    }
  ],
  "persona_id": "string"
}
```

## Get or generate an audience summary

`GET /api/v1/audiences/{category}/summary`

What this audience thinks, summarised from its recent reactions.

### Path parameters

- `category` (string, required): Audience category, as listed by GET /api/v1/audiences.

### Query parameters

- `days` (integer, default 30): Reactions from the last N days.
- `company_tag` (string): Only reactions to documents from this company.
- `pillar` (string): Only reactions on this narrative pillar.
- `force_refresh` (boolean): Regenerate the summary.
- `model` (string): Model override.

### Returns (200, object)

OK

- `cache_hit` (boolean, required)
- `refreshing_due_to_pillars` (boolean, nullable)
- `stale` (boolean, nullable): True when a stale cached record was served while a refresh runs.
- `summary` (object, nullable): Null when there are no reactions in the window.
  - `category` (string, required): The audience category, or persona:\<id> for a single persona.
  - `filters` (object)
  - `generated_at` (string, nullable)
  - `grade` (string, nullable, for example "B")
  - `grade_trend` (string, nullable): up, down or flat.
  - `id` (string, nullable): Present on cached records.
  - `is_stale` (boolean, default false)
  - `reaction_count` (integer, default 0)
  - `status_counts` (object)
    - `bad` (integer, default 0)
    - `good` (integer, default 0)
    - `warn` (integer, default 0)
  - `summary_json` (object, required): headline, overall_sentiment, top_themes, pillar_reception, top_actions, top_risks, context, data_window.
  - `workspace_id` (string, required)

### Responses

- `200`: OK
- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/audiences/{category}/summary' \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "cache_hit": true,
  "refreshing_due_to_pillars": true,
  "stale": true,
  "summary": {
    "category": "string",
    "filters": {},
    "generated_at": "string",
    "grade": "B",
    "grade_trend": "string",
    "id": "string"
  }
}
```
