# Documents & content

> 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`.

Upload, ingest, query and tag documents; run the content-writing endpoints.

## Get communications with auto tags

`GET /api/v1/communications`

Get documents for communications page with auto tags

### Query parameters

- `page` (integer, default 1): Page number, 1-based.
- `per_page` (integer, default 100): Items per page.
- `sort_by` (string, default "extracted\_date"): Field to sort on.
- `sort_order` (one of "asc", "desc", default "desc"): asc or desc.
- `search` (string): Full-text filter.
- `tag_filters` (string): Comma-separated auto-tag values to match.
- `tag_filter_mode` (one of "or", "and", default "or"): or or and.
- `auto_tag_id` (string): Restrict tag_filters to one auto tag.
- `show_filtered` (string): Set to true to include documents hidden by filters, with `hidden_by`.

### Returns (200, object)

OK

- `documents` (array of object, required): Without content; tags are a JSON-encoded string on this endpoint.
  - `auto_tags` (array of object)
    - `applied_at` (string, nullable)
    - `confidence_score` (number, nullable)
    - `extracted_value` (string, required, for example "Jane Doe")
    - `name` (string, required, for example "Executives")
    - `tag_type` (string, nullable)
  - `character_count` (integer, nullable)
  - `communication_type` (string, nullable)
  - `company` (string, nullable)
  - `content` (string, nullable): Full text; omitted by list endpoints in light mode.
  - `content_type` (string, nullable, for example "transcript")
  - `created_at` (string, nullable)
  - `executive` (string, nullable): Executive the document is attributed to.
  - `extracted_at` (string, nullable)
  - `extracted_date` (string, nullable): When the content was published, as extracted.
  - `id` (string, required, for example "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01")
  - `is_narrative_testing_upload` (boolean, nullable)
  - `media_provenance` (string, nullable): owned, earned or paid.
  - `processing_status` (string, nullable): fetching or enhancing while ingestion runs, failed on error, null when done.
  - `source_url` (string, nullable, for example "https://investors.example.com/q3-call")
  - `tags` (array of string)
  - `title` (string, required, for example "Acme Q3 earnings call transcript")
  - `updated_at` (string, nullable)
  - `url` (string, nullable)
  - `word_count` (integer, nullable, for example 4210)
  - `workspace_id` (string, required)
- `hidden_count` (integer, required): Documents hidden by auto-tag filters.
- `pagination` (object, required)
  - `page` (integer, required): Page number, 1-based.
  - `per_page` (integer, required): Items per page.
  - `total_count` (integer, required): Items across all pages.
  - `total_pages` (integer, required)
- `show_filtered` (boolean, required)

### Responses

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

### Example request

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

### Example response

```json
{
  "documents": [
    {
      "auto_tags": [],
      "character_count": 0,
      "communication_type": "string",
      "company": "string",
      "content": "string",
      "content_type": "transcript"
    }
  ],
  "hidden_count": 0,
  "pagination": {
    "page": 0,
    "per_page": 0,
    "total_count": 0,
    "total_pages": 0
  },
  "show_filtered": true
}
```

## Score each pull-through priority against a draft

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

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

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

- `content` (string, required)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `pull_through_priorities` (array of object)
  - `from_kb` (boolean, nullable, default false)
  - `level` (string, nullable, default "must")
  - `text` (string, required)

### Returns (200, object)

OK

- `coverage` (array of object, required): One entry per priority: text, level, covered, evidence.
- `model` (string, nullable)
- `parse_error` (boolean, nullable)

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/analyze-pull-through-coverage \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"content":"string"}'
```

### Example response

```json
{
  "coverage": [
    {}
  ],
  "model": "string",
  "parse_error": true
}
```

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

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

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

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

- `content_type_label` (string, nullable)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `selection_only` (boolean, default false)
- `text` (string, required)
- `tone_persona_helper` (string, nullable)
- `tone_persona_label` (string, nullable)

### Returns (200, object)

OK

- `message` (string, nullable): Set when the text was too short to analyse.
- `model` (string, nullable)
- `suggestions` (array of object, required): Edits as original/replacement pairs with a reason.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/deaiify \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"text":"string"}'
```

### Example response

```json
{
  "message": "string",
  "model": "string",
  "suggestions": [
    {}
  ]
}
```

## List content creation drafts

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

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

### Query parameters

- `limit` (integer, default 20): Most recent N, up to 100.
- `include_content` (string): Set to 1 to include each draft's text.

### Returns (200, object)

OK

- `count` (integer, required)
- `drafts` (array of object, required)
  - `character_count` (integer, default 0)
  - `content` (string, nullable): Present when include_content is set, and on single-draft reads.
  - `content_type` (string, default "text")
  - `created_at` (string, required)
  - `excerpt` (string, default "")
  - `id` (string, required)
  - `knowledgebase` (string, default "content-drafts")
  - `metadata` (object)
    - `audience_persona_ids` (array of string)
    - `content_type_value` (string, nullable)
    - `prompt` (string, default "")
    - `pull_through_priorities` (array of object)
      - and 3 more fields
    - `source_document_id` (string, nullable)
    - `source_mode` (string, nullable)
    - `test_history` (array of object)
    - `themes` (array of string)
    - `tone_persona_id` (string, nullable)
    - `voice_profile_id` (string, nullable)
  - `source_url` (string, nullable)
  - `title` (string, required, for example "Q3 margin story — LinkedIn post")
  - `updated_at` (string, required)
  - `word_count` (integer, default 0)
- `knowledgebase` (string, default "content-drafts")

### Responses

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

### Example request

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

### Example response

```json
{
  "count": 0,
  "drafts": [
    {
      "character_count": 0,
      "content": "string",
      "content_type": "text",
      "created_at": "string",
      "excerpt": "",
      "id": "string"
    }
  ],
  "knowledgebase": "content-drafts"
}
```

## Create or update content creation draft

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

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

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

- `audience_persona_ids` (array of string)
- `content` (string, nullable)
- `content_type` (string, nullable, default "text")
- `content_type_value` (string, nullable)
- `draft_id` (string, nullable)
- `knowledgebase_id` (string, nullable)
- `project_id` (string, nullable)
- `prompt` (string, nullable)
- `pull_through_priorities` (array of object)
  - `from_kb` (boolean, nullable, default false)
  - `level` (string, nullable, default "must")
  - `text` (string, required)
- `source_document_id` (string, nullable)
- `source_mode` (string, nullable, default "freeform")
- `source_url` (string, nullable)
- `test_history` (array of object, nullable)
- `themes` (array of string)
- `title` (string, nullable)
- `tone_persona_id` (string, nullable)
- `voice_profile_id` (string, nullable)

### Returns (200, object)

OK

- `draft` (object, required)
  - `character_count` (integer, default 0)
  - `content` (string, nullable): Present when include_content is set, and on single-draft reads.
  - `content_type` (string, default "text")
  - `created_at` (string, required)
  - `excerpt` (string, default "")
  - `id` (string, required)
  - `knowledgebase` (string, default "content-drafts")
  - `metadata` (object)
    - `audience_persona_ids` (array of string)
    - `content_type_value` (string, nullable)
    - `prompt` (string, default "")
    - `pull_through_priorities` (array of object)
      - and 3 more fields
    - `source_document_id` (string, nullable)
    - `source_mode` (string, nullable)
    - `test_history` (array of object)
    - `themes` (array of string)
    - `tone_persona_id` (string, nullable)
    - `voice_profile_id` (string, nullable)
  - `source_url` (string, nullable)
  - `title` (string, required, for example "Q3 margin story — LinkedIn post")
  - `updated_at` (string, required)
  - `word_count` (integer, default 0)
- `knowledgebase_name` (string, nullable)
- `message` (string, required)
- `project_attached` (boolean, nullable)

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/drafts \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"audience_persona_ids":["string"],"content":"string"}'
```

### Example response

```json
{
  "draft": {
    "character_count": 0,
    "content": "string",
    "content_type": "text",
    "created_at": "string",
    "excerpt": "",
    "id": "string"
  },
  "knowledgebase_name": "string",
  "message": "string",
  "project_attached": true
}
```

## Get content creation draft

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

Fetch a single content draft by document ID.

### Path parameters

- `draft_id` (string, required): Content draft id.

### Returns (200, object)

OK

- `draft` (object, required)
  - `character_count` (integer, default 0)
  - `content` (string, nullable): Present when include_content is set, and on single-draft reads.
  - `content_type` (string, default "text")
  - `created_at` (string, required)
  - `excerpt` (string, default "")
  - `id` (string, required)
  - `knowledgebase` (string, default "content-drafts")
  - `metadata` (object)
    - `audience_persona_ids` (array of string)
    - `content_type_value` (string, nullable)
    - `prompt` (string, default "")
    - `pull_through_priorities` (array of object)
      - and 3 more fields
    - `source_document_id` (string, nullable)
    - `source_mode` (string, nullable)
    - `test_history` (array of object)
    - `themes` (array of string)
    - `tone_persona_id` (string, nullable)
    - `voice_profile_id` (string, nullable)
  - `source_url` (string, nullable)
  - `title` (string, required, for example "Q3 margin story — LinkedIn post")
  - `updated_at` (string, required)
  - `word_count` (integer, default 0)

### Responses

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

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/content-creation/drafts/{draft_id}' \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "draft": {
    "character_count": 0,
    "content": "string",
    "content_type": "text",
    "created_at": "string",
    "excerpt": "",
    "id": "string"
  }
}
```

## Delete a content creation draft

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

Soft-delete a content creation draft by ID.

### Path parameters

- `draft_id` (string, required): Content draft id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/content-creation/drafts/{draft_id}' \
  -X DELETE \
  -H 'X-API-Key: <api key>'
```

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

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

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

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

- `audiences` (array of string)
- `content_type` (string, nullable, default "auto")
- `content_type_label` (string, nullable)
- `current_draft` (string, required)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `prompt` (string, nullable)
- `themes` (array of string)
- `tone_persona_helper` (string, nullable)
- `tone_persona_label` (string, nullable)
- `unmet_priorities` (array of object)
  - `from_kb` (boolean, nullable, default false)
  - `level` (string, nullable, default "must")
  - `text` (string, required)

### Returns (200, object)

OK

- `content` (string, required): The generated or rewritten draft.
- `model` (string, nullable)
- `truncated` (boolean, default false): True when the model hit its output limit; ask for a shorter piece.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/enhance-pull-through \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"current_draft":"string"}'
```

### Example response

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

## Export content as PDF, DOCX, or TXT

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

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

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

- `content_html` (string, nullable, default "")
- `content_text` (string, nullable, default "")
- `content_type` (string, nullable)
- `format` (string, default "pdf")
- `themes` (array of string)
- `title` (string, nullable, default "Untitled")
- `tone_persona` (string, nullable)

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/export \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"content_html":"","content_text":""}'
```

## Generate content draft text

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

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

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

- `audiences` (array of string)
- `content_type` (string, nullable, default "auto")
- `content_type_label` (string, nullable)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `preferred_title_length` (integer, nullable)
- `prompt` (string, nullable)
- `pull_through_priorities` (array of object)
  - `from_kb` (boolean, nullable, default false)
  - `level` (string, nullable, default "must")
  - `text` (string, required)
- `source_document_excerpt` (string, nullable)
- `source_document_id` (string, nullable)
- `source_document_title` (string, nullable)
- `source_mode` (string, nullable, default "freeform")
- `template_instructions` (string, nullable)
- `template_reference_excerpt` (string, nullable)
- `themes` (array of string)
- `tone_persona_helper` (string, nullable)
- `tone_persona_id` (string, nullable)
- `tone_persona_label` (string, nullable)
- `voice_profile_id` (string, nullable)

### Returns (200, object)

OK

- `content` (string, required): The generated or rewritten draft.
- `model` (string, nullable)
- `truncated` (boolean, default false): True when the model hit its output limit; ask for a shorter piece.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/generate \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"audiences":["string"],"content_type":"auto"}'
```

### Example response

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

## Phrase-level edit suggestions driven by audience feedback

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

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

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

- `content_type_label` (string, nullable)
- `full_draft` (string, required)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `segments` (array of object)
  - `actions` (array of string)
  - `grade` (string, nullable)
  - `persona_name` (string, nullable)
  - `risks` (array of string)
  - `segment_text` (string, required)
  - `summary` (string, nullable)
- `tone_persona_helper` (string, nullable)
- `tone_persona_label` (string, nullable)

### Returns (200, object)

OK

- `message` (string, nullable): Set when the text was too short to analyse.
- `model` (string, nullable)
- `suggestions` (array of object, required): Edits as original/replacement pairs with a reason.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/rewrite-phrases \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"full_draft":"string"}'
```

### Example response

```json
{
  "message": "string",
  "model": "string",
  "suggestions": [
    {}
  ]
}
```

## Rewrite specific draft segments to address audience feedback

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

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

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

- `content_type_label` (string, nullable)
- `full_draft` (string, required)
- `model` (string, nullable, default "gemini/gemini-2.5-flash")
- `segments` (array of object)
  - `actions` (array of string)
  - `grade` (string, nullable)
  - `persona_name` (string, nullable)
  - `risks` (array of string)
  - `segment_text` (string, required)
  - `summary` (string, nullable)
- `tone_persona_helper` (string, nullable)
- `tone_persona_label` (string, nullable)

### Returns (200, object)

OK

- `model` (string, nullable)
- `rewrites` (array of object, required): One rewrite per submitted segment.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/rewrite-segments \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"full_draft":"string"}'
```

### Example response

```json
{
  "model": "string",
  "rewrites": [
    {}
  ]
}
```

## List content source documents

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

List workspace documents tagged for /content source generation.

### Responses

- `422`: Unprocessable Entity

### Example request

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

## Upload content source document

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

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

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/content-creation/source-documents/upload \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Attach existing document as content source

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

Tag an existing workspace document for /content source generation.

### Path parameters

- `document_id` (string, required): Document id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/content-creation/source-documents/{document_id}/attach' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Get all documents

`GET /api/v1/documents`

Get all documents with pagination, filtering, and sorting

### Query parameters

- `page` (integer, default 1): Page number, 1-based.
- `per_page` (integer, default 20): Items per page.
- `sort_by` (string, default "extracted\_at"): Field to sort on.
- `sort_order` (one of "asc", "desc", default "desc"): asc or desc.
- `search` (string): Full-text filter on title and content.
- `light` (string): Set to 1 to omit content and tags.
- `facets` (string): Set to 1 to add executive, company and communication_type.
- `exclude_persona_kbs` (string): Set to 1 to leave out persona knowledge-base documents.

### Returns (200, object)

OK

- `documents` (array of object, required)
  - `auto_tags` (array of object)
    - `applied_at` (string, nullable)
    - `confidence_score` (number, nullable)
    - `extracted_value` (string, required, for example "Jane Doe")
    - `name` (string, required, for example "Executives")
    - `tag_type` (string, nullable)
  - `character_count` (integer, nullable)
  - `communication_type` (string, nullable)
  - `company` (string, nullable)
  - `content` (string, nullable): Full text; omitted by list endpoints in light mode.
  - `content_type` (string, nullable, for example "transcript")
  - `created_at` (string, nullable)
  - `executive` (string, nullable): Executive the document is attributed to.
  - `extracted_at` (string, nullable)
  - `extracted_date` (string, nullable): When the content was published, as extracted.
  - `id` (string, required, for example "c0a8e2f4-1b7d-4e2a-8c9f-5d6e7a8b9c01")
  - `is_narrative_testing_upload` (boolean, nullable)
  - `media_provenance` (string, nullable): owned, earned or paid.
  - `processing_status` (string, nullable): fetching or enhancing while ingestion runs, failed on error, null when done.
  - `source_url` (string, nullable, for example "https://investors.example.com/q3-call")
  - `tags` (array of string)
  - `title` (string, required, for example "Acme Q3 earnings call transcript")
  - `updated_at` (string, nullable)
  - `url` (string, nullable)
  - `word_count` (integer, nullable, for example 4210)
  - `workspace_id` (string, required)
- `pagination` (object, required)
  - `page` (integer, required): Page number, 1-based.
  - `per_page` (integer, required): Items per page.
  - `total_count` (integer, required): Items across all pages.
  - `total_pages` (integer, required)

### Responses

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

### Example request

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

### Example response

```json
{
  "documents": [
    {
      "auto_tags": [],
      "character_count": 0,
      "communication_type": "string",
      "company": "string",
      "content": "string",
      "content_type": "transcript"
    }
  ],
  "pagination": {
    "page": 0,
    "per_page": 0,
    "total_count": 0,
    "total_pages": 0
  }
}
```

## Create a new document

`POST /api/v1/documents`

Create a new document (admin/owner only)

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

- `content` (string, required)
- `content_type` (string, default "text")
- `media_provenance` (string)
- `source_url` (string)
- `tags` (array of string)
- `title` (string, required)

### Returns (201, object)

Created

- `document` (object, required)
  - `character_count` (integer, required)
  - `content_type` (string, required)
  - `created_at` (string, required)
  - `id` (string, required)
  - `title` (string, required)
  - `word_count` (integer, required)
- `message` (string, default "Document created successfully")

### Responses

- `201`: Created
- `422`: Unprocessable Entity

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/documents \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"content":"string","title":"string"}'
```

### Example response

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

## Extract text from an uploaded file without saving

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

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.

### Returns (200, object)

OK

- `character_count` (integer, required)
- `content` (string, required): The extracted text.
- `filename` (string, required)
- `word_count` (integer, required)

### Responses

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

### Example request

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

### Example response

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

## Ingest a document

`POST /api/v1/documents/ingest`

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, required)

- `audio_url` (string)
- `content_type` (string, default "auto"): webpage, pdf, image, audio, youtube, or auto to detect from the URL.
- `media_provenance` (string)
- `source_url` (string, required): The page, PDF, image, audio file or YouTube video to ingest.

### Returns (200, object)

OK

- `character_count` (integer, default 0)
- `document_id` (string, required)
- `error` (string, nullable): Set when the fetch could not be started; the status is still 200.
- `message` (string, default "Document ingested successfully")
- `processing_status` (string, nullable, default "fetching"): Poll GET /api/v1/documents/&#123;doc_id&#125; until this is null.
- `scrape_job_id` (string, nullable)
- `source_url` (string, nullable)
- `success` (boolean, default true)
- `title` (string, required): A placeholder until the fetch completes.
- `url` (string, nullable)
- `word_count` (integer, default 0)

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/documents/ingest \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"source_url":"string"}'
```

### Example response

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

## Query a document

`POST /api/v1/documents/query`

Query a document using a template

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

- `doc_id` (string, required)
- `model` (string, default "gpt-3.5-turbo")
- `query_template` (string, required)

### Returns (200, object)

OK

- `response` (string, required): The answer, as text.

### Responses

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

### Example request

```bash
curl https://api.kumkuat.ai/api/v1/documents/query \
  -H 'X-API-Key: <api key>' \
  -H 'Content-Type: application/json' \
  -d '{"doc_id":"string","query_template":"string"}'
```

### Example response

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