> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wistx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Reports

> Generate documentation and reports in various formats

Generate comprehensive documentation and reports in various formats (Markdown, HTML, PDF, DOCX). This endpoint uses the `generate_documentation` tool internally to create architecture docs, runbooks, compliance reports, security reports, cost reports, API documentation, and deployment guides.

## Generate Report

> Generate documentation or report

### Endpoint

`POST /v1/reports/generate`

<CodeGroup>
  ```bash cURL theme={null}
  curl --request POST \
    --url https://api.wistx.ai/v1/reports/generate \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "document_type": "compliance_report",
      "subject": "PCI-DSS Compliance Report",
      "resource_types": ["RDS", "S3"],
      "compliance_standards": ["PCI-DSS"],
      "format": "pdf",
      "include_compliance": true,
      "include_security": true,
      "include_cost": false,
      "include_best_practices": true
    }'
  ```

  ```python Python theme={null}
  import requests

  api_key = "YOUR_API_KEY"
  response = requests.post(
      "https://api.wistx.ai/v1/reports/generate",
      headers={
          "Authorization": f"Bearer {api_key}",
          "Content-Type": "application/json"
      },
      json={
          "document_type": "compliance_report",
          "subject": "PCI-DSS Compliance Report",
          "resource_types": ["RDS", "S3"],
          "compliance_standards": ["PCI-DSS"],
          "format": "pdf",
          "include_compliance": True,
          "include_security": True,
          "include_cost": False,
          "include_best_practices": True
      }
  )
  report = response.json()
  print(f"Report ID: {report['data']['report_id']}")
  ```

  ```javascript JavaScript theme={null}
  const apiKey = "YOUR_API_KEY";
  const response = await fetch("https://api.wistx.ai/v1/reports/generate", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      document_type: "compliance_report",
      subject: "PCI-DSS Compliance Report",
      resource_types: ["RDS", "S3"],
      compliance_standards: ["PCI-DSS"],
      format: "pdf",
      include_compliance: true,
      include_security: true,
      include_cost: false,
      include_best_practices: true
    })
  });
  const report = await response.json();
  console.log(`Report ID: ${report.data.report_id}`);
  ```

  ```go Go theme={null}
  package main

  import (
      "bytes"
      "encoding/json"
      "fmt"
      "net/http"
  )

  func main() {
      apiKey := "YOUR_API_KEY"
      url := "https://api.wistx.ai/v1/reports/generate"

      payload := map[string]interface{}{
          "document_type": "compliance_report",
          "subject": "PCI-DSS Compliance Report",
          "resource_types": []string{"RDS", "S3"},
          "compliance_standards": []string{"PCI-DSS"},
          "format": "pdf",
          "include_compliance": true,
          "include_security": true,
          "include_cost": false,
          "include_best_practices": true,
      }

      jsonData, _ := json.Marshal(payload)
      req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
      req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiKey))
      req.Header.Set("Content-Type", "application/json")

      client := &http.Client{}
      resp, _ := client.Do(req)
      defer resp.Body.Close()

      var result map[string]interface{}
      json.NewDecoder(resp.Body).Decode(&result)
      data := result["data"].(map[string]interface{})
      fmt.Printf("Report ID: %v\n", data["report_id"])
  }
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'json'
  require 'uri'

  api_key = "YOUR_API_KEY"
  url = URI("https://api.wistx.ai/v1/reports/generate")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true

  request = Net::HTTP::Post.new(url)
  request["Authorization"] = "Bearer #{api_key}"
  request["Content-Type"] = "application/json"
  request.body = {
    document_type: "compliance_report",
    subject: "PCI-DSS Compliance Report",
    resource_types: ["RDS", "S3"],
    compliance_standards: ["PCI-DSS"],
    format: "pdf",
    include_compliance: true,
    include_security: true,
    include_cost: false,
    include_best_practices: true
  }.to_json

  response = http.request(request)
  report = JSON.parse(response.body)
  puts "Report ID: #{report['data']['report_id']}"
  ```

  ```php PHP theme={null}
  <?php

  $apiKey = "YOUR_API_KEY";
  $url = "https://api.wistx.ai/v1/reports/generate";

  $data = [
      "document_type" => "compliance_report",
      "subject" => "PCI-DSS Compliance Report",
      "resource_types" => ["RDS", "S3"],
      "compliance_standards" => ["PCI-DSS"],
      "format" => "pdf",
      "include_compliance" => true,
      "include_security" => true,
      "include_cost" => false,
      "include_best_practices" => true
  ];

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  curl_setopt($ch, CURLOPT_HTTPHEADER, [
      "Authorization: Bearer " . $apiKey,
      "Content-Type: application/json"
  ]);

  $response = curl_exec($ch);
  curl_close($ch);

  $report = json_decode($response, true);
  echo "Report ID: " . $report['data']['report_id'];
  ```

  ```java Java theme={null}
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.io.OutputStream;
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import com.google.gson.Gson;
  import com.google.gson.JsonObject;

  public class GenerateReport {
      public static void main(String[] args) throws Exception {
          String apiKey = "YOUR_API_KEY";
          URL url = new URL("https://api.wistx.ai/v1/reports/generate");
          
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setRequestMethod("POST");
          conn.setRequestProperty("Authorization", "Bearer " + apiKey);
          conn.setRequestProperty("Content-Type", "application/json");
          conn.setDoOutput(true);
          
          JsonObject payload = new JsonObject();
          payload.addProperty("document_type", "compliance_report");
          payload.addProperty("subject", "PCI-DSS Compliance Report");
          payload.addProperty("format", "pdf");
          payload.addProperty("include_compliance", true);
          payload.addProperty("include_security", true);
          payload.addProperty("include_cost", false);
          payload.addProperty("include_best_practices", true);
          
          Gson gson = new Gson();
          String[] resourceTypes = {"RDS", "S3"};
          String[] complianceStandards = {"PCI-DSS"};
          payload.add("resource_types", gson.toJsonTree(resourceTypes));
          payload.add("compliance_standards", gson.toJsonTree(complianceStandards));
          
          try (OutputStream os = conn.getOutputStream()) {
              byte[] input = gson.toJson(payload).getBytes("utf-8");
              os.write(input, 0, input.length);
          }
          
          BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "utf-8"));
          StringBuilder response = new StringBuilder();
          String responseLine;
          while ((responseLine = br.readLine()) != null) {
              response.append(responseLine.trim());
          }
          System.out.println(response.toString());
      }
  }
  ```
</CodeGroup>

### Request Parameters

<ParamField body="document_type" type="string" required>
  Type of document to generate.

  **Options:** `compliance_report`, `security_report`, `cost_report`, `infrastructure_report`, `custom`
</ParamField>

<ParamField body="subject" type="string" required>
  Subject or title of the document.
</ParamField>

<ParamField body="resource_ids" type="array[string]">
  List of specific indexed resource IDs to include in report. Filters to user's resources.
</ParamField>

<ParamField body="resource_types" type="array[string]">
  List of resource types to include (e.g., `["RDS", "S3", "EC2"]`).
</ParamField>

<ParamField body="compliance_standards" type="array[string]">
  List of compliance standards to include (e.g., `["PCI-DSS", "HIPAA"]`).
</ParamField>

<ParamField body="format" type="string">
  Output format.

  **Options:** `markdown`, `html`, `pdf`, `docx`, `json`\
  **Default:** `markdown`
</ParamField>

<ParamField body="template_id" type="string">
  Custom template ID to use for generation.
</ParamField>

<ParamField body="custom_template" type="object">
  Custom template dictionary for report structure.
</ParamField>

<ParamField body="branding" type="object">
  Branding configuration (logo, colors, etc.).
</ParamField>

<ParamField body="include_compliance" type="boolean">
  Include compliance information in the report.

  **Default:** `true`
</ParamField>

<ParamField body="include_security" type="boolean">
  Include security information in the report.

  **Default:** `true`
</ParamField>

<ParamField body="include_cost" type="boolean">
  Include cost information in the report.

  **Default:** `true`
</ParamField>

<ParamField body="include_best_practices" type="boolean">
  Include best practices in the report.

  **Default:** `true`
</ParamField>

### Response

<ResponseExample>
  ```json 200 Success theme={null}
  {
    "data": {
      "report_id": "report-20240115103000-abc12345",
      "document_type": "compliance_report",
      "subject": "PCI-DSS Compliance Report",
      "format": "pdf",
      "content": "base64_encoded_pdf_content",
      "content_type": "application/pdf",
      "sections": [
        "Executive Summary",
        "Compliance Overview",
        "Resource Analysis",
        "Recommendations"
      ],
      "metadata": {
        "resource_types": ["RDS", "S3"],
        "compliance_standards": ["PCI-DSS"],
        "generated_at": "2024-01-15T10:30:00Z"
      },
      "download_url": "https://api.wistx.ai/v1/reports/download/report-20240115103000-abc12345",
      "view_url": "https://api.wistx.ai/v1/reports/view/report-20240115103000-abc12345"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 400 Bad Request theme={null}
  {
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Invalid request parameters",
      "details": "document_type is required"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 401 Unauthorized theme={null}
  {
    "detail": "User ID not found"
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "detail": "Access denied to resources: res_xyz789"
  }
  ```

  ```json 500 Internal Server Error theme={null}
  {
    "error": {
      "code": "REPORT_GENERATION_ERROR",
      "message": "Failed to generate report",
      "details": null
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```

  ```json 503 Service Unavailable theme={null}
  {
    "error": {
      "code": "DATABASE_ERROR",
      "message": "Database connection failed",
      "details": "Connection timeout"
    },
    "metadata": {
      "request_id": "req_abc123",
      "timestamp": 1704067200.0
    }
  }
  ```
</ResponseExample>

## Related Endpoints

* [Compliance Requirements](/api-reference/compliance) - Get compliance requirements
* [Knowledge Research](/api-reference/knowledge) - Research knowledge base


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.