# Kumkuat API reference

Kumkuat turns the documents, signals and synthetic audiences in a workspace into an API: ingest content, build personas, put a document or a question in front of them, and generate audience-tested copy.

Every request carries a workspace API key in the `X-API-Key` header and is scoped to that key's workspace. Start with `GET /api/v1/workspace`, list personas with `GET /api/v1/personas`, then `POST /api/v1/personas/interact` to ask one of them about a document or a draft. Long-running work (ingestion, reactions for a whole audience, report generation) returns a job id to poll at `GET /api/v1/jobs/{job_id}`.

Ids are opaque strings. Timestamps are ISO-8601 with a UTC offset. Responses marked with an object schema may carry additional fields beyond the ones documented; the documented ones are stable.

Paths follow one shape: `/api/v1/<resource>` for a collection, `/api/v1/<resource>/{id}` for one item, `/api/v1/<resource>/{id}/<sub-resource>` for what belongs to it, and an action as a POST verb on the resource it acts on (`POST /api/v1/reports/{report_id}/generate`). Segments are kebab-case. The key names the workspace, so no path carries a workspace id. Paths marked deprecated keep working; each one names the path that replaced it.

Base URL: `https://gateway.kumkuat.ai/`. Send your key in the `X-API-Key` header; the remaining allowance comes back on every response in `X-Gw-Remaining`.

MCP server: `https://mcp.kumkuat.ai/` (bearer token = the same key).

## Errors every operation can return

- `422` Unprocessable Entity

```json
[
  {
    "input": null,
    "loc": [],
    "msg": "string",
    "type": "string"
  }
]
```

# Workspace

# Jobs

## GET /api/v1/jobs/{job_id}

**Get a background job**

Poll the job id returned by a long-running call (ingestion, audience reactions, report generation) until `status` is `completed`, `failed` or `cancelled`. `result` and `parameters` are JSON-encoded strings. Jobs from other workspaces answer 404.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `job_id` | path | string | yes | The job id returned by the call that queued the work. Example: string |

### Responses

- `200` OK

```json
{
  "created_at": "string",
  "id": "job_7f3a9c2e",
  "job_type": "audience_reactions",
  "max_retries": 0,
  "priority": 0,
  "retry_count": 0,
  "status": "completed",
  "workspace_id": "string"
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/jobs/string" \
  -H "X-API-Key: YOUR_KEY"
```

# Workspace

## GET /api/v1/workspace

**Get the current workspace**

The workspace the API key belongs to, with the caller's role and the workspace settings.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `workspace_id` | query | string | no | Read another workspace by id. Only honored for admin keys; every other key gets its own workspace. Example: string |

### Responses

- `200` OK

```json
{
  "description": "",
  "is_active": true,
  "is_owner": true,
  "name": "Acme Corp",
  "role": "owner",
  "settings": {},
  "workspace_id": "ws_0512272171984c7fb4b7"
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/workspace" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/workspace/company-tags

**List company names extracted by company auto tags**

Return distinct company names extracted by company auto tags for this workspace.<br/><br/>Admin key may pass ?workspace_id= to query another workspace.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/workspace/company-tags" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/workspace/content-type-tags

**List the workspace's content-type tags**

Return distinct content/communication type values extracted by content-type auto tags.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/workspace/content-type-tags" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/workspace/narrative-guidelines

**Get the workspace narrative guideline sets**

The narrative guideline sets the content studio checks drafts against (KS-432).

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/workspace/narrative-guidelines" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/workspace/narrative-guidelines

**Replace the workspace narrative guideline sets**

Replace the whole list of guideline sets.<br/><br/>Every member's drafts are checked against these, so the write needs the same<br/>key as the workspace pull-through priorities.

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/workspace/narrative-guidelines" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/workspace/pull-through-priorities

**Get the workspace pull-through priorities**

The pull-through priorities content writing checks drafts against.

### Responses

- `200` OK

```json
{
  "priorities": [
    {
      "from_kb": false,
      "level": "must",
      "text": "Margin expansion is structural, not one-off"
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/workspace/pull-through-priorities" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/workspace/pull-through-priorities

**Replace the workspace pull-through priorities**

Replace the whole list.

### Request body (application/json)

```json
{
  "priorities": [
    {
      "from_kb": false,
      "level": "must",
      "text": "Margin expansion is structural, not one-off"
    }
  ]
}
```

### Responses

- `200` OK

```json
{
  "priorities": [
    {
      "from_kb": false,
      "level": "must",
      "text": "Margin expansion is structural, not one-off"
    }
  ]
}
```

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/workspace/pull-through-priorities" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "priorities": [
    {
      "from_kb": false,
      "level": "must",
      "text": "Margin expansion is structural, not one-off"
    }
  ]
}'
```

# Documents & content

# Communications

## GET /api/v1/communications

**Get communications with auto tags**

Get documents for communications page with auto tags

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `page` | query | integer | no | Page number, 1-based. Example: 1 |
| `per_page` | query | integer | no | Items per page. Example: 100 |
| `sort_by` | query | string | no | Field to sort on. Example: extracted_date |
| `sort_order` | query | enum | no | asc or desc. One of: asc, desc |
| `search` | query | string | no | Full-text filter. Example: string |
| `tag_filters` | query | string | no | Comma-separated auto-tag values to match. Example: string |
| `tag_filter_mode` | query | enum | no | or or and. One of: or, and |
| `auto_tag_id` | query | string | no | Restrict tag_filters to one auto tag. Example: string |
| `show_filtered` | query | string | no | Set to true to include documents hidden by filters, with `hidden_by`. Example: string |

### Responses

- `200` OK

```json
{
  "documents": [
    {
      "auto_tags": [
        {
          "extracted_value": "Jane Doe",
          "name": "Executives"
        }
      ],
      "content_type": "transcript",
      "id": "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01",
      "source_url": "https://investors.example.com/q3-call",
      "tags": [
        "string"
      ],
      "title": "Acme Q3 earnings call transcript",
      "word_count": 4210,
      "workspace_id": "string"
    }
  ],
  "hidden_count": 1,
  "pagination": {
    "page": 1,
    "per_page": 1,
    "total_count": 1,
    "total_pages": 1
  },
  "show_filtered": true
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/communications" \
  -H "X-API-Key: YOUR_KEY"
```

# Content creation

## POST /api/v1/content-creation/analyze-pull-through-coverage

**Score each pull-through priority against a draft**

Grade each pull-through priority as covered / partial / missing in the given draft.

### Request body (application/json)

```json
{
  "content": "string",
  "model": "gemini/gemini-2.5-flash",
  "pull_through_priorities": []
}
```

### Responses

- `200` OK

```json
{
  "coverage": [
    {}
  ]
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/analyze-pull-through-coverage" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content": "string",
  "model": "gemini/gemini-2.5-flash",
  "pull_through_priorities": []
}'
```

## POST /api/v1/content-creation/deaiify

**Suggest edits to reduce AI-detection signals in content**

LLM-powered analysis of AI-detection signals with span-anchored edit suggestions.

### Request body (application/json)

```json
{
  "model": "gemini/gemini-2.5-flash",
  "selection_only": false,
  "text": "string"
}
```

### Responses

- `200` OK

```json
{
  "suggestions": [
    {}
  ]
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/deaiify" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gemini/gemini-2.5-flash",
  "selection_only": false,
  "text": "string"
}'
```

## POST /api/v1/content-creation/enhance-pull-through

**Rewrite a draft so unmet pull-through priorities are delivered**

Re-prompt the generator with unmet priorities elevated to rewrite the current draft.

### Request body (application/json)

```json
{
  "audiences": [],
  "content_type": "auto",
  "current_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "themes": [],
  "unmet_priorities": []
}
```

### Responses

- `200` OK

```json
{
  "content": "string",
  "truncated": false
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/enhance-pull-through" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "audiences": [],
  "content_type": "auto",
  "current_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "themes": [],
  "unmet_priorities": []
}'
```

## POST /api/v1/content-creation/export

**Export content as PDF, DOCX, or TXT**

Export content creation draft to the requested format (pdf, docx, txt).

### Request body (application/json)

```json
{
  "content_html": "",
  "content_text": "",
  "format": "pdf",
  "meta_position": "below",
  "themes": [],
  "title": "Untitled"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/export" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content_html": "",
  "content_text": "",
  "format": "pdf",
  "meta_position": "below",
  "themes": [],
  "title": "Untitled"
}'
```

## POST /api/v1/content-creation/feedback-themes

**Group audience feedback into themes with exact edits**

Themes across a draft's testers, with the edits that answer each (KS-432).<br/><br/>Optionally also AI-search (GEO) best practice and the workspace's narrative<br/>guidelines. Every edit is checked against the draft before it is returned;<br/>see ``_normalize_feedback_themes``.

### Request body (application/json)

```json
{
  "include_geo": false,
  "model": "gemini/gemini-2.5-flash"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/feedback-themes" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "include_geo": false,
  "model": "gemini/gemini-2.5-flash"
}'
```

## POST /api/v1/content-creation/generate

**Generate content draft text**

Set `Accept: text/event-stream` to stream the draft as it is written.

### Request body (application/json)

```json
{
  "audiences": [],
  "content_type": "auto",
  "model": "gemini/gemini-2.5-flash",
  "pull_through_priorities": [],
  "source_mode": "freeform",
  "themes": []
}
```

### Responses

- `200` OK

```json
{
  "content": "string",
  "truncated": false
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/generate" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "audiences": [],
  "content_type": "auto",
  "model": "gemini/gemini-2.5-flash",
  "pull_through_priorities": [],
  "source_mode": "freeform",
  "themes": []
}'
```

## POST /api/v1/content-creation/revise

**Revise a draft, with or without an instruction**

Rewrite the current draft to an instruction (KS-432).<br/><br/>Same contract as enhance-pull-through: JSON by default, or the draft as it<br/>is written with ``Accept: text/event-stream``.

### Request body (application/json)

```json
{
  "content_type": "auto",
  "model": "gemini/gemini-2.5-flash"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/revise" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content_type": "auto",
  "model": "gemini/gemini-2.5-flash"
}'
```

## POST /api/v1/content-creation/rewrite-phrases

**Phrase-level edit suggestions driven by audience feedback**

LLM-powered phrase-level edit suggestions based on audience test feedback.

### Request body (application/json)

```json
{
  "full_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "segments": []
}
```

### Responses

- `200` OK

```json
{
  "suggestions": [
    {}
  ]
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/rewrite-phrases" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "full_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "segments": []
}'
```

## POST /api/v1/content-creation/rewrite-segments

**Rewrite specific draft segments to address audience feedback**

LLM-powered rewrite of individual segments based on audience test feedback.

### Request body (application/json)

```json
{
  "full_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "segments": []
}
```

### Responses

- `200` OK

```json
{
  "rewrites": [
    {}
  ]
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/rewrite-segments" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "full_draft": "string",
  "model": "gemini/gemini-2.5-flash",
  "segments": []
}'
```

## GET /api/v1/content-creation/drafts

**List content creation drafts**

List recent content drafts stored in the content-drafts knowledgebase.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `limit` | query | integer | no | Most recent N, up to 100. Example: 20 |
| `include_content` | query | string | no | Set to 1 to include each draft's text. Example: string |

### Responses

- `200` OK

```json
{
  "count": 1,
  "drafts": [
    {
      "character_count": 0,
      "content_type": "text",
      "created_at": "string",
      "excerpt": "",
      "id": "string",
      "knowledgebase": "content-drafts",
      "metadata": {
        "audience_persona_ids": [
          "string"
        ],
        "prompt": "",
        "pull_through_priorities": [
          {
            "from_kb": false,
            "level": "must",
            "text": "Margin expansion is structural, not one-off"
          }
        ],
        "test_history": [
          {}
        ],
        "themes": [
          "string"
        ]
      },
      "title": "Q3 margin story — LinkedIn post",
      "updated_at": "string",
      "word_count": 0
    }
  ],
  "knowledgebase": "content-drafts"
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/content-creation/drafts" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/content-creation/drafts

**Create or update content creation draft**

Creates a draft (201), or updates it when `draft_id` is given (200).

### Request body (application/json)

```json
{
  "audience_persona_ids": [],
  "content_type": "text",
  "pull_through_priorities": [],
  "source_mode": "freeform",
  "themes": []
}
```

### Responses

- `200` OK

```json
{
  "draft": {
    "character_count": 0,
    "content_type": "text",
    "created_at": "string",
    "excerpt": "",
    "id": "string",
    "knowledgebase": "content-drafts",
    "metadata": {
      "audience_persona_ids": [
        "string"
      ],
      "prompt": "",
      "pull_through_priorities": [
        {
          "from_kb": false,
          "level": "must",
          "text": "Margin expansion is structural, not one-off"
        }
      ],
      "test_history": [
        {}
      ],
      "themes": [
        "string"
      ]
    },
    "title": "Q3 margin story — LinkedIn post",
    "updated_at": "string",
    "word_count": 0
  },
  "message": "string"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/drafts" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "audience_persona_ids": [],
  "content_type": "text",
  "pull_through_priorities": [],
  "source_mode": "freeform",
  "themes": []
}'
```

## GET /api/v1/content-creation/drafts/{draft_id}

**Get content creation draft**

Fetch a single content draft by document ID.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `draft_id` | path | string | yes | Content draft id. Example: string |

### Responses

- `200` OK

```json
{
  "draft": {
    "character_count": 0,
    "content_type": "text",
    "created_at": "string",
    "excerpt": "",
    "id": "string",
    "knowledgebase": "content-drafts",
    "metadata": {
      "audience_persona_ids": [
        "string"
      ],
      "prompt": "",
      "pull_through_priorities": [
        {
          "from_kb": false,
          "level": "must",
          "text": "Margin expansion is structural, not one-off"
        }
      ],
      "test_history": [
        {}
      ],
      "themes": [
        "string"
      ]
    },
    "title": "Q3 margin story — LinkedIn post",
    "updated_at": "string",
    "word_count": 0
  }
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/content-creation/drafts/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/content-creation/drafts/{draft_id}

**Delete a content creation draft**

Soft-delete a content creation draft by ID.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `draft_id` | path | string | yes | Content draft id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/content-creation/drafts/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/content-creation/drafts/{draft_id}/versions

**List a content draft's saved versions**

A draft's saved versions, newest first; the original (version 0) last.<br/>No text: read one version for its content.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `draft_id` | path | string | yes | Content draft id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/content-creation/drafts/string/versions" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/content-creation/drafts/{draft_id}/versions

**Save a version of a content draft**

Keep a copy of the draft as it is now. Versions are never changed or<br/>deleted afterwards.<br/><br/>``kind: "saved"`` (the default) takes the next number; ``kind: "original"``<br/>is version 0 and a draft has at most one.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `draft_id` | path | string | yes | Content draft id. Example: string |

### Request body (application/json)

```json
{
  "kind": "saved"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/drafts/string/versions" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "saved"
}'
```

## GET /api/v1/content-creation/drafts/{draft_id}/versions/{version_no}

**Get one saved version of a content draft**

One version with its text and studio state.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `draft_id` | path | string | yes | Content draft id. Example: string |
| `version_no` | path | integer | yes | Version number: 0 is the original, saved versions count from 1. Example: 1 |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/content-creation/drafts/string/versions/1" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/content-creation/source-documents

**List content source documents**

List workspace documents tagged for /content source generation.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/content-creation/source-documents" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/content-creation/source-documents/upload

**Upload content source document**

Upload a source document for /content generation using the standard ingestion pipeline.

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/source-documents/upload" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/content-creation/source-documents/{document_id}/attach

**Attach existing document as content source**

Tag an existing workspace document for /content source generation.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `document_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/content-creation/source-documents/string/attach" \
  -H "X-API-Key: YOUR_KEY"
```

# Documents

## GET /api/v1/documents

**Get all documents**

Get all documents with pagination, filtering, and sorting

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `page` | query | integer | no | Page number, 1-based. Example: 1 |
| `per_page` | query | integer | no | Items per page. Example: 20 |
| `sort_by` | query | string | no | Field to sort on. Example: extracted_at |
| `sort_order` | query | enum | no | asc or desc. One of: asc, desc |
| `search` | query | string | no | Full-text filter on title and content. Example: string |
| `light` | query | string | no | Set to 1 to omit content and tags. Example: string |
| `facets` | query | string | no | Set to 1 to add executive, company and communication_type. Example: string |
| `exclude_persona_kbs` | query | string | no | Set to 1 to leave out persona knowledge-base documents. Example: string |

### Responses

- `200` OK

```json
{
  "documents": [
    {
      "auto_tags": [
        {
          "extracted_value": "Jane Doe",
          "name": "Executives"
        }
      ],
      "content_type": "transcript",
      "id": "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01",
      "source_url": "https://investors.example.com/q3-call",
      "tags": [
        "string"
      ],
      "title": "Acme Q3 earnings call transcript",
      "word_count": 4210,
      "workspace_id": "string"
    }
  ],
  "pagination": {
    "page": 1,
    "per_page": 1,
    "total_count": 1,
    "total_pages": 1
  }
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/documents" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/documents

**Create a new document**

Create a new document (admin/owner only)

### Request body (application/json)

```json
{
  "content": "string",
  "content_type": "text",
  "tags": [],
  "title": "string"
}
```

### Responses

- `201` Created

```json
{
  "document": {
    "character_count": 1,
    "content_type": "string",
    "created_at": "string",
    "id": "string",
    "title": "string",
    "word_count": 1
  },
  "message": "Document created successfully"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content": "string",
  "content_type": "text",
  "tags": [],
  "title": "string"
}'
```

## GET /api/v1/documents/{doc_id}

**Get a specific document**

Get a document by ID

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Responses

- `200` OK

```json
{
  "document": {
    "auto_tags": [
      {
        "extracted_value": "Jane Doe",
        "name": "Executives"
      }
    ],
    "content_type": "transcript",
    "id": "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01",
    "source_url": "https://investors.example.com/q3-call",
    "tags": [
      "string"
    ],
    "title": "Acme Q3 earnings call transcript",
    "word_count": 4210,
    "workspace_id": "string"
  }
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/documents/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PATCH /api/v1/documents/{doc_id}

**Update a document**

Only `title` and `extracted_date` can be changed.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Request body (application/json)

```json
{
  "extracted_date": "2026-09-30"
}
```

### Responses

- `200` OK

```json
{
  "document": {
    "auto_tags": [
      {
        "extracted_value": "Jane Doe",
        "name": "Executives"
      }
    ],
    "content_type": "transcript",
    "id": "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01",
    "source_url": "https://investors.example.com/q3-call",
    "tags": [
      "string"
    ],
    "title": "Acme Q3 earnings call transcript",
    "word_count": 4210,
    "workspace_id": "string"
  }
}
```

### Example

```bash
curl -X PATCH "https://gateway.kumkuat.ai/api/v1/documents/string" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "extracted_date": "2026-09-30"
}'
```

## DELETE /api/v1/documents/{doc_id}

**Delete a document**

Delete a document by ID

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/documents/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/documents/facets

**List document filter values**

Every executive, company and communication type a document picker can filter by.<br/><br/>Values come from the whole workspace, not one page of documents (KS-421):<br/>a picker that built its options from the 50 documents it opened on could<br/>not offer a company with no document among those 50 — on the S&P TOP 15<br/>workspace that was NVIDIA, its own anchor company. Pass the same<br/>`exclude_persona_kbs` as the listing the picker filters, then send a chosen<br/>value back as `executive`, `company` or `communication_type` on<br/>GET /api/v1/documents.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/documents/facets" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/documents/extract-text

**Extract text from an uploaded file without saving**

Send the file as multipart/form-data in a `file` field: PDF, DOCX, PPTX, TXT, MD, CSV, HTML, RTF, JSON or XML. Nothing is stored.

### Responses

- `200` OK

```json
{
  "character_count": 1,
  "content": "string",
  "filename": "string",
  "word_count": 1
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents/extract-text" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/documents/ingest

**Ingest a document**

Fetch a URL into the workspace. Returns at once with `processing_status: fetching`; poll `GET /api/v1/documents/{doc_id}` until it clears.

### Request body (application/json)

```json
{
  "content_type": "auto",
  "source_url": "string"
}
```

### Responses

- `200` OK

```json
{
  "character_count": 0,
  "document_id": "string",
  "message": "Document ingested successfully",
  "processing_status": "fetching",
  "success": true,
  "title": "string",
  "word_count": 0
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents/ingest" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content_type": "auto",
  "source_url": "string"
}'
```

## POST /api/v1/documents/query

**Query a document**

Query a document using a template

### Request body (application/json)

```json
{
  "doc_id": "string",
  "model": "gpt-3.5-turbo",
  "query_template": "string"
}
```

### Responses

- `200` OK

```json
{
  "response": "string"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents/query" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "doc_id": "string",
  "model": "gpt-3.5-turbo",
  "query_template": "string"
}'
```

## POST /api/v1/documents/upload

**Upload and ingest a file**

Upload and ingest a file with document enrichment and auto tags

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents/upload" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/documents/{doc_id}/content

**Download a document's stored file**

Stream the stored file for a document, authorized per request.<br/><br/>This is the authenticated replacement for handing out public bucket URLs<br/>(KUM-1315): the objects become private, and callers read them through here<br/>so that access is re-checked every time rather than living forever in a URL.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/documents/string/content" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/documents/{doc_id}/retag

**Retag a document**

Retag a document by rerunning all auto tags.<br/><br/>A retag replaces the document's applied tags with fresh model extractions,<br/>so it is editing that document: member or above, as PATCH<br/>/api/v1/documents/<doc_id> takes. The document must be in the caller's<br/>workspace and not hidden from them by a restricted knowledge base (KS-436);<br/>otherwise it answers 404, the same as an id that does not exist.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/documents/string/retag" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/documents/{doc_id}/auto-tags

**Get auto tags for a document**

Get all auto tags applied to a specific document

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |

### Responses

- `200` OK

```json
{
  "auto_tags": [
    {
      "auto_tag_id": "string",
      "extracted_value": "string",
      "extraction": "string",
      "id": "string",
      "name": "string"
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/documents/string/auto-tags" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/documents/{doc_id}/auto-tags/{applied_tag_id}

**Update an applied auto tag value**

Update the extracted value of an applied auto tag for a specific document.<br/><br/>Editing a document's tag value is editing that document, so it takes the<br/>same role as PATCH /api/v1/documents/<doc_id>: member or above. The applied<br/>row must belong to the caller's workspace and to ``doc_id``; any other id<br/>answers 404, the same as an id that does not exist.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `doc_id` | path | string | yes | Document id. Example: string |
| `applied_tag_id` | path | string | yes | Id of the auto tag as applied to this document. Example: string |

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/documents/string/auto-tags/string" \
  -H "X-API-Key: YOUR_KEY"
```

# Insights

## POST /api/v1/insights

**Get AI comparative analysis for executives or companies on a theme**

Compare what executives or companies say on a theme, with an optional audience read from your personas.

### Request body (application/json)

```json
{
  "comparison_type": "executive",
  "executives": [
    "Jane Doe",
    "John Roe"
  ],
  "focus_question": "Who is most credible on margin durability?",
  "theme": "Pricing power"
}
```

### Responses

- `200` OK

```json
{
  "ai_analysis": {},
  "theme": "string",
  "total_signals": 0
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/insights" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "comparison_type": "executive",
  "executives": [
    "Jane Doe",
    "John Roe"
  ],
  "focus_question": "Who is most credible on margin durability?",
  "theme": "Pricing power"
}'
```

# Personas

# Personas

## GET /api/v1/personas

**Get all personas**

Get persona templates for the current workspace, optionally filtered by category.<br/><br/>Supports pagination via ``limit`` (default 200, max 500) and ``offset`` (default 0).<br/>Response includes ``total`` count before pagination so callers can detect truncation.<br/>Use ``?summary=1`` for the lightweight listing (no pagination cap applies there since<br/>summary objects are ~200B each).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `category` | query | string | no | Only personas in this audience category. Example: string |
| `limit` | query | integer | no | Page size, up to 500. Example: 200 |
| `offset` | query | integer | no | Skip this many personas. Example: 0 |
| `summary` | query | string | no | Set to 1 for a lighter listing: identity, category, avatar, flags and health, with no prompts. Summary mode is not paginated. Example: string |

### Responses

- `200` OK

```json
{
  "personas": [
    {
      "avatar_source": "",
      "avatar_url": "",
      "category": "investors",
      "communication_style": "",
      "concerns": "",
      "created_at": "2026-09-29T16:40:12+00:00",
      "created_by": "system",
      "description": "Runs finance at a mid-cap industrial; distrusts growth narratives without unit economics.",
      "entity_kind": "",
      "entity_kind_resolved": "",
      "external_sources": [
        {}
      ],
      "grounded_statements": [
        {}
      ],
      "health_state": {},
      "id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
      "include_in_audience": true,
      "include_in_voice_list": false,
      "instructions": "",
      "interests": "",
      "is_active": true,
      "is_linked_to_source": false,
      "labels": [
        "string"
      ],
      "linked_knowledgebase_ids": [
        "string"
      ],
      "name": "Skeptical CFO",
      "refresh_policy": {},
      "response_language": "",
      "social_links": [
        {
          "platform": "linkedin",
          "url": "https://www.linkedin.com/in/example"
        }
      ],
      "template": "",
      "tone": "",
      "updated_at": "2026-10-05T09:12:44+00:00",
      "version": 1,
      "voice_profiles": [
        {}
      ],
      "voice_visibility": "workspace",
      "workspace_id": "string",
      "writing_sample_document_ids": [
        "string"
      ]
    }
  ],
  "total": 1
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas

**Create persona**

Create a new persona template

### Request body (application/json)

```json
{
  "category": "investors",
  "communication_style": "",
  "concerns": "",
  "description": "Runs finance at a mid-cap industrial; distrusts growth narratives without unit economics.",
  "include_in_audience": true,
  "include_in_voice_list": false,
  "instructions": "",
  "interests": "",
  "is_active": true,
  "name": "Skeptical CFO",
  "response_language": "en",
  "template": "",
  "tone": ""
}
```

### Responses

- `201` Created

```json
{
  "message": "Persona created successfully",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "category": "investors",
  "communication_style": "",
  "concerns": "",
  "description": "Runs finance at a mid-cap industrial; distrusts growth narratives without unit economics.",
  "include_in_audience": true,
  "include_in_voice_list": false,
  "instructions": "",
  "interests": "",
  "is_active": true,
  "name": "Skeptical CFO",
  "response_language": "en",
  "template": "",
  "tone": ""
}'
```

## GET /api/v1/personas/{persona_id}

**Get persona by ID**

Get a specific persona template

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Responses

- `200` OK

```json
{
  "persona": {
    "avatar_source": "",
    "avatar_url": "",
    "category": "investors",
    "communication_style": "",
    "concerns": "",
    "created_at": "2026-09-29T16:40:12+00:00",
    "created_by": "system",
    "description": "Runs finance at a mid-cap industrial; distrusts growth narratives without unit economics.",
    "entity_kind": "",
    "entity_kind_resolved": "",
    "external_sources": [
      {}
    ],
    "grounded_statements": [
      {}
    ],
    "health_state": {},
    "id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
    "include_in_audience": true,
    "include_in_voice_list": false,
    "instructions": "",
    "interests": "",
    "is_active": true,
    "is_linked_to_source": false,
    "labels": [
      "string"
    ],
    "linked_knowledgebase_ids": [
      "string"
    ],
    "name": "Skeptical CFO",
    "refresh_policy": {},
    "response_language": "",
    "social_links": [
      {
        "platform": "linkedin",
        "url": "https://www.linkedin.com/in/example"
      }
    ],
    "template": "",
    "tone": "",
    "updated_at": "2026-10-05T09:12:44+00:00",
    "version": 1,
    "voice_profiles": [
      {}
    ],
    "voice_visibility": "workspace",
    "workspace_id": "string",
    "writing_sample_document_ids": [
      "string"
    ]
  }
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/personas/{persona_id}

**Update persona**

Send only the fields to change.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Request body (application/json)

```json
{}
```

### Responses

- `200` OK

```json
{
  "message": "string"
}
```

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/personas/string" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## DELETE /api/v1/personas/{persona_id}

**Delete persona**

Delete a persona template

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/personas/string" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/bulk-delete

**Delete many personas**

Soft-delete a selection of personas, with a per-persona report (KS-401).<br/><br/>Body: ``{"persona_ids": [...]}`` (1–200). The Audience Library's<br/>multi-select calls this instead of N single DELETEs. Each id passes the<br/>same checks the single DELETE makes, plus the private-voice filter the<br/>bulk-update applies — the library only lists what the caller can see, so a<br/>hidden voice is ``not_found`` here exactly as it is on every read. The<br/>store is the same soft delete, and each removal is audited the same way.

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/bulk-delete" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/fill-missing

**Draft the blank profile fields of existing personas in the background**

Queue one fill job per selected persona that has blank profile fields (KS-401).<br/><br/>Body: ``{"persona_ids": [...]}`` (1–100) → 202<br/>``{"results": [{"persona_id", "name", "status", "job_id"?, "missing"?}], "summary": {...}}``.<br/><br/>The repair half of the Audience Library's multi-select: a build whose<br/>drafter failed lands with only what the requester typed, and this runs the<br/>same drafter over the blanks (persona_build.fill_persona). Each persona is<br/>triaged here first, so nothing complete, managed or unreadable costs a<br/>model call: ``complete`` and ``managed`` are answered on the spot, and only<br/>``queued`` rows carry a ``job_id`` to poll at ``GET /api/v1/jobs/<id>``.<br/>The jobs ride PERSONA_BUILD, scoped per persona id.

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/fill-missing" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/interact

**Interact with persona**

Put a question, a draft or a workspace document in front of one persona and get its reply. Replies take 10 to 30 seconds. For a whole audience at once use `POST /api/v1/personas/reaction-insights`.

### Request body (application/json)

```json
{
  "enable_follow_up_questions": false,
  "input_content": "We are moving to usage-based pricing next quarter. How does that land with you?",
  "interaction_type": "conversation",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"
}
```

### Responses

- `200` OK

```json
{
  "message": "Persona interaction completed",
  "output_content": "Usage-based pricing tells me you expect customers to grow into the product. Show me the cohort data before I believe the revenue line.",
  "persona_id": "string",
  "response_language": "en"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/interact" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "enable_follow_up_questions": false,
  "input_content": "We are moving to usage-based pricing next quarter. How does that land with you?",
  "interaction_type": "conversation",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"
}'
```

## POST /api/v1/personas/why-it-matters

**Generate/fetch grounded 'why this matters' for a persona+document**

Why this document matters to one persona: a web-grounded note with sources, cached for 7 days. `POST /api/v1/audiences/reactions` returns the same note on every reaction when its `include` lists `why_it_matters`; call this route to fetch one on its own or to regenerate it with `force_refresh`.

### Request body (application/json)

```json
{
  "document": {
    "document_type": "press_release",
    "title": "Q3 pricing announcement"
  },
  "force_refresh": false
}
```

### Responses

- `200` OK

```json
{
  "answer": "string",
  "cache_hit": false,
  "grounded": true,
  "sources": [
    {}
  ]
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/why-it-matters" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "document": {
    "document_type": "press_release",
    "title": "Q3 pricing announcement"
  },
  "force_refresh": false
}'
```

## GET /api/v1/personas/{persona_id}/summary

**Get or generate a persona summary**

What one persona thinks, summarised from its recent reactions.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `days` | query | integer | no | Reactions from the last N days. Example: 30 |
| `force_refresh` | query | boolean | no | Regenerate the summary. Example: True |
| `model` | query | string | no | Model override. Example: string |

### Responses

- `200` OK

```json
{
  "cache_hit": true
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas/string/summary" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/analyze-voice

**Analyze voice from writing samples**

Analyze writing samples to extract a structured voice profile for a persona.<br/><br/>Accepts either raw text samples or knowledgebase document IDs.<br/>Uses the workspace system default model (audience_model) for analysis.<br/>Stores the resulting voice profile in the persona's persona_config.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/analyze-voice" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/feedback

**Submit persona response feedback**

Submit feedback for a persona response (thumbs up/down + description).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Request body (application/json)

```json
{
  "description": "Too eager to accept the pricing change; a CFO would ask about churn first.",
  "feedback_type": "negative"
}
```

### Responses

- `200` OK

```json
{
  "feedback_id": "string",
  "message": "Persona feedback recorded successfully"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/feedback" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "Too eager to accept the pricing change; a CFO would ask about churn first.",
  "feedback_type": "negative"
}'
```

## POST /api/v1/personas/{persona_id}/generate

**Generate content in persona voice**

Write a piece in the persona's voice. The draft is saved as a workspace document.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Request body (application/json)

```json
{
  "content_type": "linkedin_post",
  "topic": "Why our Q3 margin expansion is durable"
}
```

### Responses

- `200` OK

```json
{
  "content": "string",
  "truncated": false
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/generate" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "content_type": "linkedin_post",
  "topic": "Why our Q3 margin expansion is durable"
}'
```

## POST /api/v1/personas/{persona_id}/link-external-source

**Link external source to persona**

Link an external source (e.g. a journalist's column, a blog, or a publication URL)<br/>to a persona by creating a knowledgebase with a web/RSS watcher source.<br/>If the persona already has an external-source KB, the existing one is returned.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/link-external-source" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/link-file

**Link an uploaded file to persona**

Upload a file (deck, doc, notes) and link it to a persona as a grounding<br/>source. The file is ingested into a per-persona "Linked Files"<br/>knowledgebase that is attached via linked_knowledgebase_ids, so its<br/>content grounds the persona and feeds persona refresh like watched<br/>web/social sources do.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/link-file" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/link-linkedin

**Link LinkedIn profile to persona**

Link a LinkedIn profile to a persona by creating a knowledgebase with a<br/>LinkedIn watcher source.  If the persona already has a LinkedIn KB, the<br/>existing one is returned instead of creating a duplicate.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/link-linkedin" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/unlink-file

**Unlink an uploaded file from persona**

Remove a linked file from a persona: detach the document from the<br/>persona's linked-files KB and soft-delete it (linked-file uploads exist<br/>only to ground this persona).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/unlink-file" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/personas/{persona_id}/refinements

**List persona refinements**

List all active refinements (tuning notes) for a persona.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas/string/refinements" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/refinements

**Add manual persona refinement**

Manually add a refinement note to a persona profile.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/refinements" \
  -H "X-API-Key: YOUR_KEY"
```

## PATCH /api/v1/personas/{persona_id}/refinements/{refinement_id}

**Update persona refinement**

Update content or active state of a refinement note.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `refinement_id` | path | string | yes | Refinement id. Example: string |

### Example

```bash
curl -X PATCH "https://gateway.kumkuat.ai/api/v1/personas/string/refinements/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/personas/{persona_id}/refinements/{refinement_id}

**Delete persona refinement**

Delete a refinement note from a persona profile.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `refinement_id` | path | string | yes | Refinement id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/personas/string/refinements/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/personas/{persona_id}/voice-profiles

**List voice profiles for a persona**

Return all voice profiles for a persona.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas/string/voice-profiles" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/personas/{persona_id}/voice-profiles/{profile_id}

**Get a single voice profile**

Return a single voice profile by ID.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `profile_id` | path | string | yes | Voice profile id, as listed by GET /api/v1/personas/{persona_id}/voice-profiles. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/personas/string/voice-profiles/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/personas/{persona_id}/voice-profiles/{profile_id}

**Update a voice profile**

Update an existing voice profile (name, adjective_tags, tone_pillars, etc.).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `profile_id` | path | string | yes | Voice profile id, as listed by GET /api/v1/personas/{persona_id}/voice-profiles. Example: string |

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/personas/string/voice-profiles/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/personas/{persona_id}/voice-profiles/{profile_id}

**Delete a voice profile**

Delete a voice profile. Cannot delete the last remaining profile.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `profile_id` | path | string | yes | Voice profile id, as listed by GET /api/v1/personas/{persona_id}/voice-profiles. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/personas/string/voice-profiles/string" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/personas/{persona_id}/voice-profiles/{profile_id}/set-default

**Set default voice profile**

Set a voice profile as the default for content generation.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id, as returned by GET /api/v1/personas. Example: string |
| `profile_id` | path | string | yes | Voice profile id, as listed by GET /api/v1/personas/{persona_id}/voice-profiles. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/personas/string/voice-profiles/string/set-default" \
  -H "X-API-Key: YOUR_KEY"
```

# Voices

# Voices

## GET /api/v1/voices

**List voices**

Every persona offered as a content-creation voice, plus executives that have<br/>been materialised as voices whether or not they are currently enabled.

### Responses

- `200` OK

```json
{
  "total": 1,
  "voices": [
    {
      "enabled": true,
      "kind": "executive",
      "name": "Jane Doe",
      "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
      "tuned": true
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/voices" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/voices

**Add a voice**

``{"executive": "<name>"}`` materialises an executive named on the workspace's<br/>documents as a tuned voice persona (one model call on first creation; an existing<br/>voice is re-enabled). ``{"persona_id": "<id>"}`` offers an existing persona as a<br/>voice. Answers 201 with the voice.

### Request body (application/json)

```json
{
  "executive": "Jane Doe"
}
```

### Responses

- `201` Created

```json
{
  "created": true,
  "enabled": true,
  "kind": "executive",
  "name": "Jane Doe",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
  "tuned": true
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/voices" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "executive": "Jane Doe"
}'
```

## GET /api/v1/voices/{persona_id}

**Get a voice**

One voice by its persona id. 404 when the persona is not a voice in this workspace.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id of the voice, as listed by GET /api/v1/voices. Example: string |

### Responses

- `200` OK

```json
{
  "enabled": true,
  "kind": "executive",
  "name": "Jane Doe",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
  "tuned": true
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/voices/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/voices/{persona_id}

**Enable or disable a voice**

Body ``{"enabled": true|false}``. For an executive's voice this is the same<br/>toggle as the executives page: enabling tunes the persona from the executive's<br/>statements when it has not been tuned yet, disabling keeps the tuned persona.<br/>For any other persona it sets ``include_in_voice_list``.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | path | string | yes | Persona id of the voice, as listed by GET /api/v1/voices. Example: string |

### Request body (application/json)

```json
{
  "enabled": true
}
```

### Responses

- `200` OK

```json
{
  "enabled": true,
  "kind": "executive",
  "name": "Jane Doe",
  "persona_id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60",
  "tuned": true
}
```

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/voices/string" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true
}'
```

# Audiences

# Audiences

## GET /api/v1/audiences

**List audiences**

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

### Responses

- `200` OK

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

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audiences" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/audiences

**Add an audience**

Add one audience category.

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/audiences" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/audiences/categories

**List audience category names**

The category names in use, as plain strings.

### Responses

- `200` OK

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

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audiences/categories" \
  -H "X-API-Key: YOUR_KEY"
```

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

**Get or generate an audience summary**

What this audience thinks, summarised from its recent reactions.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `category` | path | string | yes | Audience category, as listed by GET /api/v1/audiences. Example: string |
| `days` | query | integer | no | Reactions from the last N days. Example: 30 |
| `company_tag` | query | string | no | Only reactions to documents from this company. Example: string |
| `pillar` | query | string | no | Only reactions on this narrative pillar. Example: string |
| `force_refresh` | query | boolean | no | Regenerate the summary. Example: True |
| `model` | query | string | no | Model override. Example: string |

### Responses

- `200` OK

```json
{
  "cache_hit": true
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audiences/string/summary" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/audiences/reactions

**List cached audience reactions**

Reactions already generated in this workspace.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audiences/reactions" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/audiences/reactions

**Get or generate audience 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)

```json
{
  "document": {
    "document_type": "press_release",
    "title": "Q3 pricing announcement"
  },
  "force_refresh": false,
  "generation_source": "api",
  "include": [
    "why_it_matters"
  ],
  "personas": [
    {
      "id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"
    }
  ],
  "skip_save": false
}
```

### Responses

- `200` OK

```json
{
  "cache_hits": 1,
  "document": {},
  "failed": 1,
  "generated": 1,
  "insights": [
    {
      "cache_hit": false,
      "document": {},
      "grade": "B",
      "output_content": "string",
      "output_json": {},
      "persona": {
        "description": "",
        "id": "string",
        "name": "string"
      },
      "status": "completed",
      "status_counts": {
        "bad": 0,
        "good": 0,
        "warn": 0
      }
    }
  ],
  "message": "Persona reaction insights ready",
  "project_attached": false,
  "prompt_version": "string",
  "timed_out": 1,
  "workspace_id": "string"
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/audiences/reactions" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "document": {
    "document_type": "press_release",
    "title": "Q3 pricing announcement"
  },
  "force_refresh": false,
  "generation_source": "api",
  "include": [
    "why_it_matters"
  ],
  "personas": [
    {
      "id": "d4e9b2a1-6c3f-4b8e-9f21-0a7c5e3d1b60"
    }
  ],
  "skip_save": false
}'
```

## GET /api/v1/audiences/reactions/history

**Get reaction history for a persona and document**

Every reaction one persona has given to one document.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `persona_id` | query | string | yes | The persona. Example: string |
| `document_id` | query | string | yes | The document. Example: string |
| `limit` | query | integer | no | Most recent N entries. Example: 1 |

### Responses

- `200` OK

```json
{
  "count": 1,
  "document_id": "string",
  "entries": [
    {
      "document_id": "string",
      "id": "string",
      "output_content": "",
      "persona_id": "string",
      "persona_name": "string",
      "status_counts": {
        "bad": 0,
        "good": 0,
        "warn": 0
      }
    }
  ],
  "persona_id": "string"
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audiences/reactions/history?persona_id=string&document_id=string" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/audiences/reactions/async

**Queue audience reactions as a job**

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

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/audiences/reactions/async" \
  -H "X-API-Key: YOUR_KEY"
```

# Signals & themes

# Executives

## GET /api/v1/executives/{executive_name}

**Get detailed information about a specific executive**

Get detailed information about a specific executive

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `executive_name` | path | string | yes | The executive's name as it appears on documents. Example: string |

### Responses

- `200` OK

```json
{
  "communication_types": {
    "key": 1
  },
  "companies": [
    "string"
  ],
  "companies_mentioned": [
    "string"
  ],
  "date_range": {},
  "documents": [
    {}
  ],
  "name": "Jane Doe",
  "signals": [
    {}
  ],
  "themes_mentioned": [
    "string"
  ],
  "total_documents": 0,
  "total_signals": 0,
  "unique_companies": 0,
  "unique_themes": 0
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/executives/string" \
  -H "X-API-Key: YOUR_KEY"
```

# Signals

## GET /api/v1/signals

**Get all signals**

Get all signals with pagination

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/filters

**Get the theme and executive filters**

The themes, executives, pillars, content types and companies available for filtering.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `refresh` | query | boolean | no | Recompute instead of serving the cached copy. Example: True |
| `force_refresh` | query | boolean | no | Same as refresh. Example: True |

### Responses

- `200` OK

```json
{
  "companies": [
    "string"
  ],
  "content_types": [
    "string"
  ],
  "executives": [
    {
      "companies": [
        "string"
      ],
      "display": "string",
      "executive": "string"
    }
  ],
  "pillars": [
    "string"
  ],
  "theme_metadata": [
    {}
  ],
  "theme_to_pillar": {
    "key": "string"
  },
  "themes": [
    "string"
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/filters" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/themes

**Get themes and extracted signals**

Theme extractions across the workspace's documents, paginated.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `page` | query | integer | no | Page number, 1-based. Example: 1 |
| `per_page` | query | integer | no | Items per page. Example: 20 |
| `theme` | query | string | no | Only this theme (signal template name). Example: string |
| `executive` | query | string | no | Only this executive. Example: string |
| `company` | query | string | no | Only this company. Example: string |
| `communication_type` | query | string | no | Only this communication type. Example: string |
| `signal_id` | query | string | no | One signal. Example: string |
| `refresh` | query | boolean | no | Recompute instead of serving the cached copy. Example: True |
| `force_refresh` | query | boolean | no | Same as refresh. Example: True |

### Responses

- `200` OK

```json
{
  "pagination": {
    "page": 1,
    "per_page": 1,
    "total_count": 1,
    "total_pages": 1
  },
  "themes": [
    {
      "auto_tags": [
        {
          "extracted_value": "Jane Doe",
          "name": "Executives"
        }
      ],
      "json_data": {},
      "signal_id": "string",
      "template_id": "string",
      "template_name": "Pricing power"
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/themes" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/signals/{signal_id}/feedback

**Submit signal feedback**

Submit feedback for a signal (thumbs up/down)

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `signal_id` | path | string | yes | Signal id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/signals/string/feedback" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/document/{document_id}

**Get signals for a specific document**

Get all signals for a specific document with filtering

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `document_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/document/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/signals/document/{document_id}

**Delete signals for a specific document**

Soft-delete all non-deleted signals for a specific document in the current workspace.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `document_id` | path | string | yes | Document id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/signals/document/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/runs

**Get all signal runs**

Get all signal runs

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/runs" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/runs/{run_id}

**Get signal run**

Get signal run status and results

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `run_id` | path | string | yes | Signal run id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/runs/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/templates

**Get all signal templates**

Get all signal templates

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/templates" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/signals/templates

**Create a signal template**

Create a signal template (a theme to extract).

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/signals/templates" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/templates/{template_id}

**Get signal template by ID**

Get a specific signal template

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `template_id` | path | string | yes | Signal template id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/templates/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/signals/templates/{template_id}

**Update a signal template**

Update a signal template.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `template_id` | path | string | yes | Signal template id. Example: string |

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/signals/templates/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/signals/templates/{template_id}

**Delete a signal template**

Delete a signal template.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `template_id` | path | string | yes | Signal template id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/signals/templates/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/signals/templates/{template_id}/signals

**Get signals by template**

Get all signals from a specific template

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `template_id` | path | string | yes | Signal template id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/signals/templates/string/signals" \
  -H "X-API-Key: YOUR_KEY"
```

# Auto tags

# Auto tags

## GET /api/v1/auto-tags

**Get all auto tags**

Get all auto tags visible in the current workspace

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/auto-tags" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/auto-tags

**Create auto tag**

Create a new auto tag

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/auto-tags" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/auto-tags/{id}

**Get auto tag by ID**

Get a specific auto tag visible in the current workspace

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Record id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/auto-tags/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/auto-tags/{id}

**Update auto tag**

Update an existing auto tag

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Record id. Example: string |

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/auto-tags/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/auto-tags/{id}

**Delete auto tag**

Delete an auto tag

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Record id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/auto-tags/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/auto-tags/aliases

**List auto-tag alias rules**

Alias rules that normalise extracted tag values.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/auto-tags/aliases" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/auto-tags/aliases

**Create an auto-tag alias rule**

Create an alias rule.

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/auto-tags/aliases" \
  -H "X-API-Key: YOUR_KEY"
```

## PUT /api/v1/auto-tags/aliases/{id}

**Update an auto-tag alias rule**

Update an alias rule.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Record id. Example: string |

### Example

```bash
curl -X PUT "https://gateway.kumkuat.ai/api/v1/auto-tags/aliases/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/auto-tags/aliases/{id}

**Delete an auto-tag alias rule**

Delete an alias rule.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes | Record id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/auto-tags/aliases/string" \
  -H "X-API-Key: YOUR_KEY"
```

# Reports

# Reports

## GET /api/v1/reports

**List custom reports for workspace**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `include_templates` | query | string | no | Set to false to leave out report templates. Example: true |

### Responses

- `200` OK

```json
{
  "reports": [
    {
      "created_at": "string",
      "id": "string",
      "is_template": false,
      "layout_config": {},
      "title": "Weekly narrative scorecard",
      "updated_at": "string",
      "workspace_id": "string"
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/reports" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports

**Create a custom report**

### Request body (application/json)

```json
{
  "title": "Weekly narrative scorecard"
}
```

### Responses

- `201` Created

```json
{
  "auto_generated": true,
  "report": {
    "created_at": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {},
    "title": "Weekly narrative scorecard",
    "updated_at": "string",
    "workspace_id": "string"
  }
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports" \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Weekly narrative scorecard"
}'
```

## GET /api/v1/reports/{report_id}

**Get custom report with sections**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Responses

- `200` OK

```json
{
  "report": {
    "created_at": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {},
    "title": "Weekly narrative scorecard",
    "updated_at": "string",
    "workspace_id": "string"
  }
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/reports/string" \
  -H "X-API-Key: YOUR_KEY"
```

## PATCH /api/v1/reports/{report_id}

**Update a custom report**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X PATCH "https://gateway.kumkuat.ai/api/v1/reports/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/reports/{report_id}

**Delete a custom report**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/reports/string" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/reports/{report_id}/pdf

**Download report as PDF**

Generate and return a PDF of the report.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/reports/string/pdf" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/customize-style

**Generate layout_config from natural language style description**

Use LLM to translate a natural language style description into a layout_config JSON.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/customize-style" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/generate

**Generate all stale sections**

Regenerate all stale sections of a report. Returns cached output for fresh sections.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |
| `model` | query | string | no | Model override. Example: string |
| `force` | query | string | no | Set to 1 to regenerate sections that are not stale. Example: string |

### Responses

- `200` OK

```json
{
  "errors": [
    {}
  ],
  "generated_count": 1,
  "report": {
    "created_at": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {},
    "title": "Weekly narrative scorecard",
    "updated_at": "string",
    "workspace_id": "string"
  },
  "stale_count": 1
}
```

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/generate" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/send-email

**Send report via email**

Send the report as an HTML email with optional PDF attachment.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/send-email" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/reports/{report_id}/schedule

**Get report schedule**

Get the current refresh schedule for a report (if any).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/reports/string/schedule" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/schedule

**Create report refresh schedule**

Create a recurring refresh schedule for a report.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/schedule" \
  -H "X-API-Key: YOUR_KEY"
```

## PATCH /api/v1/reports/{report_id}/schedule

**Update report schedule**

Update the refresh schedule for a report.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X PATCH "https://gateway.kumkuat.ai/api/v1/reports/string/schedule" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/reports/{report_id}/schedule

**Delete report schedule**

Remove the refresh schedule for a report.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/reports/string/schedule" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/sections

**Add section to a report**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/sections" \
  -H "X-API-Key: YOUR_KEY"
```

## PATCH /api/v1/reports/{report_id}/sections/{section_id}

**Update a report section**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |
| `section_id` | path | string | yes | Report section id. Example: string |

### Example

```bash
curl -X PATCH "https://gateway.kumkuat.ai/api/v1/reports/string/sections/string" \
  -H "X-API-Key: YOUR_KEY"
```

## DELETE /api/v1/reports/{report_id}/sections/{section_id}

**Delete a report section**

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |
| `section_id` | path | string | yes | Report section id. Example: string |

### Example

```bash
curl -X DELETE "https://gateway.kumkuat.ai/api/v1/reports/string/sections/string" \
  -H "X-API-Key: YOUR_KEY"
```

## POST /api/v1/reports/{report_id}/sections/{section_id}/generate

**Generate output for a single section**

Force-generate (or regenerate) the LLM output for a single report section.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `report_id` | path | string | yes | Custom report id. Example: string |
| `section_id` | path | string | yes | Report section id. Example: string |

### Example

```bash
curl -X POST "https://gateway.kumkuat.ai/api/v1/reports/string/sections/string/generate" \
  -H "X-API-Key: YOUR_KEY"
```

# Audit log

# Audit events

## GET /api/v1/audit-events

**List audit events (SIEM feed)**

Poll this from a SIEM. Events come oldest first; store `next_cursor` and pass it as `cursor` next time. Events appear about 5 seconds after they happen (the feed holds back the newest few seconds so a cursor never skips one). `order=desc` with `before` pages newest first instead. Needs the `workspace.audit_log` permission: owners and admins hold it, and a workspace API key created with `permissions: ["workspace.audit_log"]` can read the log and nothing else.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `cursor` | query | string | no | Return events after this cursor (from `next_cursor`). Example: string |
| `since` | query | string | no | Only events at or after this time (ISO 8601). Use on the first poll instead of a cursor. Example: 2026-10-01T00:00:00Z |
| `until` | query | string | no | Only events before this time (ISO 8601). Example: string |
| `type` | query | string | no | Comma-separated event types, or a whole category such as `member.*`. Example: auth.sign_in,api_key.* |
| `limit` | query | integer | no | Events per page, at most 1000. Example: 100 |
| `order` | query | enum | no | `asc` (feed order) or `desc` (newest first). One of: asc, desc |
| `before` | query | string | no | With `order=desc`: events before this cursor. Example: string |

### Responses

- `200` OK

```json
{
  "events": [
    {
      "actor": {
        "type": "string"
      },
      "cursor": "string",
      "detail": {},
      "id": "string",
      "occurred_at": "string",
      "outcome": "string",
      "source": {},
      "target": {},
      "type": "member.role_changed"
    }
  ],
  "has_more": true,
  "order": "string"
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audit-events" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/audit-events/export.csv

**Download audit events as CSV**

Every event from `since` (default: 30 days ago) to `until` (default: now) as CSV, oldest first.<br/>Takes the same `type` filter as the feed. Columns: occurred_at, type, outcome, actor_type,<br/>actor_email, actor_user_id, api_key_id, source_ip, user_agent, target_type, target_id,<br/>target_name, detail (JSON), id, request_id. Each download is recorded as an<br/>`audit_log.exported` event.

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audit-events/export.csv" \
  -H "X-API-Key: YOUR_KEY"
```

## GET /api/v1/audit-events/types

**List audit event types**

Every event type the audit log records, with what it means.

### Responses

- `200` OK

```json
{
  "retention_days": 1,
  "types": [
    {
      "category": "string",
      "description": "string",
      "type": "string"
    }
  ]
}
```

### Example

```bash
curl "https://gateway.kumkuat.ai/api/v1/audit-events/types" \
  -H "X-API-Key: YOUR_KEY"
```
