# Reports

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

Custom report definitions, sections, generation, PDF export and scheduling. Requires the Custom reports feature on the workspace.

## List custom reports for workspace

`GET /api/v1/reports`

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Query parameters

- `include_templates` (string, default "true"): Set to false to leave out report templates.

### Returns (200, object)

OK

- `reports` (array of object, required)
  - `created_at` (string, required)
  - `created_by` (string, nullable)
  - `description` (string, nullable)
  - `id` (string, required)
  - `is_template` (boolean, default false)
  - `layout_config` (object)
  - `sections` (array of object, nullable): Present on single-report reads.
    - `cached_output` (object, nullable): The last generated output.
    - `created_at` (string, required)
    - `data_scope` (object)
    - `display_type` (string, default "narrative"): cards, table, narrative or grade_bar.
    - `generated_at` (string, nullable)
    - `id` (string, required)
    - `is_stale` (boolean, default true)
    - `prompt_template` (string, nullable)
    - `report_id` (string, required)
    - `section_type` (string, required): prompt_analysis, aggregate_summary or data_table.
    - `sort_order` (integer, default 0)
    - `title` (string, required)
    - `updated_at` (string, required)
  - `title` (string, required, for example "Weekly narrative scorecard")
  - `updated_at` (string, required)
  - `workspace_id` (string, required)

### Responses

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

### Example request

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

### Example response

```json
{
  "reports": [
    {
      "created_at": "string",
      "created_by": "string",
      "description": "string",
      "id": "string",
      "is_template": false,
      "layout_config": {}
    }
  ]
}
```

## Create a custom report

`POST /api/v1/reports`

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

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

- `description` (string, nullable): Used to propose the report's sections.
- `model` (string, nullable)
- `title` (string, required, for example "Weekly narrative scorecard")

### Returns (201, object)

Created

- `auto_generated` (boolean, required): True when sections were proposed from the description.
- `report` (object, required)
  - `created_at` (string, required)
  - `created_by` (string, nullable)
  - `description` (string, nullable)
  - `id` (string, required)
  - `is_template` (boolean, default false)
  - `layout_config` (object)
  - `sections` (array of object, nullable): Present on single-report reads.
    - `cached_output` (object, nullable): The last generated output.
    - `created_at` (string, required)
    - `data_scope` (object)
    - `display_type` (string, default "narrative"): cards, table, narrative or grade_bar.
    - `generated_at` (string, nullable)
    - `id` (string, required)
    - `is_stale` (boolean, default true)
    - `prompt_template` (string, nullable)
    - `report_id` (string, required)
    - `section_type` (string, required): prompt_analysis, aggregate_summary or data_table.
    - `sort_order` (integer, default 0)
    - `title` (string, required)
    - `updated_at` (string, required)
  - `title` (string, required, for example "Weekly narrative scorecard")
  - `updated_at` (string, required)
  - `workspace_id` (string, required)

### Responses

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

### Example request

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

### Example response

```json
{
  "auto_generated": true,
  "report": {
    "created_at": "string",
    "created_by": "string",
    "description": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {}
  }
}
```

## Get custom report with sections

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Returns (200, object)

OK

- `report` (object, required)
  - `created_at` (string, required)
  - `created_by` (string, nullable)
  - `description` (string, nullable)
  - `id` (string, required)
  - `is_template` (boolean, default false)
  - `layout_config` (object)
  - `sections` (array of object, nullable): Present on single-report reads.
    - `cached_output` (object, nullable): The last generated output.
    - `created_at` (string, required)
    - `data_scope` (object)
    - `display_type` (string, default "narrative"): cards, table, narrative or grade_bar.
    - `generated_at` (string, nullable)
    - `id` (string, required)
    - `is_stale` (boolean, default true)
    - `prompt_template` (string, nullable)
    - `report_id` (string, required)
    - `section_type` (string, required): prompt_analysis, aggregate_summary or data_table.
    - `sort_order` (integer, default 0)
    - `title` (string, required)
    - `updated_at` (string, required)
  - `title` (string, required, for example "Weekly narrative scorecard")
  - `updated_at` (string, required)
  - `workspace_id` (string, required)

### Responses

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

### Example request

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

### Example response

```json
{
  "report": {
    "created_at": "string",
    "created_by": "string",
    "description": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {}
  }
}
```

## Update a custom report

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

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

## Delete a custom report

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

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

## Generate layout\_config from natural language style description

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

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/customize-style' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Generate all stale sections

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

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Query parameters

- `model` (string): Model override.
- `force` (string): Set to 1 to regenerate sections that are not stale.

### Returns (200, object)

OK

- `errors` (array of object)
- `generated_count` (integer, required)
- `report` (object, required)
  - `created_at` (string, required)
  - `created_by` (string, nullable)
  - `description` (string, nullable)
  - `id` (string, required)
  - `is_template` (boolean, default false)
  - `layout_config` (object)
  - `sections` (array of object, nullable): Present on single-report reads.
    - `cached_output` (object, nullable): The last generated output.
    - `created_at` (string, required)
    - `data_scope` (object)
    - `display_type` (string, default "narrative"): cards, table, narrative or grade_bar.
    - `generated_at` (string, nullable)
    - `id` (string, required)
    - `is_stale` (boolean, default true)
    - `prompt_template` (string, nullable)
    - `report_id` (string, required)
    - `section_type` (string, required): prompt_analysis, aggregate_summary or data_table.
    - `sort_order` (integer, default 0)
    - `title` (string, required)
    - `updated_at` (string, required)
  - `title` (string, required, for example "Weekly narrative scorecard")
  - `updated_at` (string, required)
  - `workspace_id` (string, required)
- `stale_count` (integer, required)

### Responses

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

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/generate' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

### Example response

```json
{
  "errors": [
    {}
  ],
  "generated_count": 0,
  "report": {
    "created_at": "string",
    "created_by": "string",
    "description": "string",
    "id": "string",
    "is_template": false,
    "layout_config": {}
  },
  "stale_count": 0
}
```

## Download report as PDF

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

Generate and return a PDF of the report.

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

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

## Get report schedule

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

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

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

## Create report refresh schedule

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

Create a recurring refresh schedule for a report.

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/schedule' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Update report schedule

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

Update the refresh schedule for a report.

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/schedule' \
  -X PATCH \
  -H 'X-API-Key: <api key>'
```

## Delete report schedule

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

Remove the refresh schedule for a report.

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/schedule' \
  -X DELETE \
  -H 'X-API-Key: <api key>'
```

## Add section to a report

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/sections' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Update a report section

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.
- `section_id` (string, required): Report section id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/sections/{section_id}' \
  -X PATCH \
  -H 'X-API-Key: <api key>'
```

## Delete a report section

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.
- `section_id` (string, required): Report section id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/sections/{section_id}' \
  -X DELETE \
  -H 'X-API-Key: <api key>'
```

## Generate output for a single section

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

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.
- `section_id` (string, required): Report section id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/sections/{section_id}/generate' \
  -X POST \
  -H 'X-API-Key: <api key>'
```

## Send report via email

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

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

Requires the **Custom reports** feature, which Kumkuat enables per workspace. Without it the API returns 403.

### Path parameters

- `report_id` (string, required): Custom report id.

### Responses

- `422`: Unprocessable Entity

### Example request

```bash
curl --globoff 'https://api.kumkuat.ai/api/v1/reports/{report_id}/send-email' \
  -X POST \
  -H 'X-API-Key: <api key>'
```
