Reports API Reference

The Reports API enables programmatic generation of long-form, AI-powered reports. Reports are processed asynchronously through a dedicated worker queue and exported as professionally formatted PDFs.

Base URL: /api/reports

Authentication

All report endpoints require authentication via:

  • Session cookie (ory_kratos_session)
  • API key (X-API-Key header or Authorization: Bearer header)

Most endpoints require AAL2 (second-factor authentication) for session-based access. API key access requires admin or read scope.


Endpoints Overview

MethodEndpointDescriptionAuth Level
GET/templatesList available report templatesAAL2 / API Key
POST/Create new reportAAL2 / API Key
GET/List user’s reportsAAL2 / API Key
GET/{report_id}Get report detailsAAL2 / API Key
GET/{report_id}/downloadDownload report fileAAL2 / API Key
POST/{report_id}/cancelCancel pending reportAAL2 / API Key
POST/{report_id}/retryRetry failed reportAAL2 / API Key
GET/queue/statusGet queue statusPublic

Report Templates

List Templates

Get available report templates for the authenticated user.

GET /api/reports/templates

Query Parameters:

ParameterTypeDescription
categorystringFilter by category (optional)

Response:

{
  "success": true,
  "data": {
    "templates": [
      {
        "id": "cc030440-0005-470f-8341-6ec798d00445",
        "name": "Bee Conversational Report",
        "description": "AI-generated long-form analysis with web search context",
        "category": "analysis",
        "required_role": "user",
        "is_active": true,
        "output_formats": ["pdf", "md", "html"],
        "requires_scrambling": true,
        "max_output_tokens": 16384,
        "estimated_time_minutes": 15
      }
    ],
    "count": 1,
    "user_role": "user"
  }
}

Template Categories:

CategoryDescription
analysisIn-depth analysis and research reports
systemSystem health and performance reports
securitySecurity audits and compliance
knowledgeKnowledge base analytics
compliancePII/data compliance reports

Creating Reports

Create Report

Queue a new report for generation.

POST /api/reports/
Content-Type: application/json

Request Body:

{
  "template_id": "cc030440-0005-470f-8341-6ec798d00445",
  "title": "SCADA Security Best Practices Analysis",
  "description": "Comprehensive analysis of ICS/SCADA security frameworks",
  "priority": "normal",
  "parameters": {
    "user_query": "Provide a detailed 4500+ word analysis of SCADA/ICS security best practices, including NERC CIP compliance, network segmentation, and incident response.",
    "conversation_id": null,
    "generation_mode": "conversational",
    "context": {}
  },
  "output_format": "pdf",
  "honey_jar_id": null,
  "scrambling_enabled": true
}

Request Parameters:

FieldTypeRequiredDescription
template_idstringYesReport template UUID
titlestringYesReport title
descriptionstringNoBrief description
prioritystringNourgent, high, normal, low (default: normal)
parametersobjectYesTemplate-specific parameters
parameters.user_querystringYesThe query/topic for the report
parameters.conversation_idstringNoLink to existing conversation
parameters.generation_modestringNoconversational (default)
output_formatstringNopdf, md, html (default: pdf)
honey_jar_idstringNoHoney jar for RAG context
scrambling_enabledbooleanNoEnable PII detection (default: true)

Response (201 Created):

{
  "success": true,
  "data": {
    "report": {
      "id": "991a8dca-b90c-406d-9a64-dcc9b1bec33c",
      "title": "SCADA Security Best Practices Analysis",
      "status": "queued",
      "priority": "normal",
      "created_at": "2026-01-20T15:30:00Z",
      "output_format": "pdf"
    },
    "queue_position": 2,
    "estimated_completion": "2026-01-20T15:45:00Z"
  }
}

cURL Example

curl -X POST "https://your-sting.com/api/reports/" \
  -H "Content-Type: application/json" \
  -H "X-API-Key: sk_your_api_key_here" \
  -d '{
    "template_id": "cc030440-0005-470f-8341-6ec798d00445",
    "title": "Security Analysis Report",
    "parameters": {
      "user_query": "Provide a comprehensive 5000+ word analysis of zero-trust architecture implementation for enterprise networks."
    },
    "output_format": "pdf"
  }'

Python Example

import requests

api_key = "sk_your_api_key_here"
base_url = "https://your-sting.com"

response = requests.post(
    f"{base_url}/api/reports/",
    headers={
        "Content-Type": "application/json",
        "X-API-Key": api_key
    },
    json={
        "template_id": "cc030440-0005-470f-8341-6ec798d00445",
        "title": "Zero Trust Architecture Analysis",
        "parameters": {
            "user_query": "Provide a detailed analysis of zero-trust security implementation..."
        },
        "output_format": "pdf",
        "priority": "high"
    }
)

data = response.json()
report_id = data["data"]["report"]["id"]
print(f"Report queued: {report_id}")

Managing Reports

List Reports

Get all reports for the authenticated user.

GET /api/reports/

Query Parameters:

ParameterTypeDefaultDescription
limitint50Max results (1-100)
offsetint0Pagination offset
statusstring-Filter by status
searchstring-Search in title/description

Response:

{
  "success": true,
  "data": {
    "reports": [
      {
        "id": "991a8dca-b90c-406d-9a64-dcc9b1bec33c",
        "title": "SCADA Security Analysis",
        "status": "completed",
        "created_at": "2026-01-20T15:30:00Z",
        "completed_at": "2026-01-20T15:42:00Z",
        "output_format": "pdf",
        "file_size_bytes": 2457600,
        "template_name": "Bee Conversational Report"
      }
    ],
    "pagination": {
      "total": 24,
      "limit": 50,
      "offset": 0
    }
  }
}

Get Report Details

Get detailed information about a specific report.

GET /api/reports/{report_id}

Response:

{
  "success": true,
  "report": {
    "id": "991a8dca-b90c-406d-9a64-dcc9b1bec33c",
    "title": "SCADA Security Analysis",
    "description": "Comprehensive ICS/SCADA security analysis",
    "status": "completed",
    "progress_percentage": 100,
    "created_at": "2026-01-20T15:30:00Z",
    "completed_at": "2026-01-20T15:42:00Z",
    "output_format": "pdf",
    "file_size_bytes": 2457600,
    "result_file_id": "file-xyz-789",
    "download_url": "/api/reports/991a8dca-b90c-406d-9a64-dcc9b1bec33c/download",
    "parameters": {
      "user_query": "Provide a detailed analysis..."
    }
  }
}

Download Report

Download a completed report file.

GET /api/reports/{report_id}/download

Response: Binary file download (Content-Type based on output_format)

curl -X GET "https://your-sting.com/api/reports/{report_id}/download" \
  -H "X-API-Key: sk_your_api_key_here" \
  -o report.pdf

Cancel Report

Cancel a pending or processing report.

POST /api/reports/{report_id}/cancel

Response:

{
  "success": true,
  "message": "Report cancelled successfully"
}

Retry Failed Report

Retry generation of a failed report.

POST /api/reports/{report_id}/retry

Response:

{
  "success": true,
  "report_id": "991a8dca-b90c-406d-9a64-dcc9b1bec33c",
  "status": "queued",
  "message": "Report requeued for processing"
}

Queue Status

Get Queue Status (Public)

Get current report queue status. This endpoint does not require authentication.

GET /api/reports/public/queue/status

Response:

{
  "success": true,
  "data": {
    "queue_name": "default",
    "pending_reports": 3,
    "processing_reports": 1,
    "completed_today": 12,
    "failed_today": 0,
    "average_processing_time": "8.5 minutes",
    "estimated_wait_time": "25.5 minutes"
  }
}

Report Status Values

StatusDescription
pendingReport created, waiting to be queued
queuedIn the processing queue
processingCurrently being generated
completedReady for download
failedGeneration failed (check error_message)
cancelledCancelled by user

Report Types & Templates

Bee Conversational Report

The primary report template for AI-generated long-form content.

Template ID: cc030440-0005-470f-8341-6ec798d00445

Supported Report Styles:

StyleTrigger KeywordsDescription
Use Case“how can”, “implement”, “deploy”, “use case”Practical implementation scenarios
Comparison“compare”, “versus”, “vs”, “difference”Side-by-side analysis
Summary“summarize”, “overview”, “brief”Executive summaries
Technical“technical”, “architecture”, “deep dive”Detailed technical analysis

Reports automatically detect the appropriate style based on query keywords.


Polling for Completion

Reports are generated asynchronously. Use polling to check status:

import time
import requests

def wait_for_report(report_id, api_key, timeout=1800):
    """Poll for report completion with smart intervals."""
    base_url = "https://your-sting.com"
    start = time.time()
    
    while time.time() - start < timeout:
        response = requests.get(
            f"{base_url}/api/reports/{report_id}",
            headers={"X-API-Key": api_key}
        )
        data = response.json()
        status = data["report"]["status"]
        
        if status == "completed":
            return data["report"]["download_url"]
        elif status == "failed":
            raise Exception(f"Report failed: {data['report'].get('error_message')}")
        
        # Smart polling: shorter intervals when processing
        interval = 3 if status == "processing" else 10
        time.sleep(interval)
    
    raise TimeoutError("Report generation timed out")

Error Responses

Common Errors

{
  "success": false,
  "error": "Template not found or not available"
}
HTTP CodeErrorDescription
400JSON data requiredMissing request body
400template_id and title are requiredMissing required fields
401Authentication requiredNo valid session or API key
403Insufficient permissionsUser lacks access to template
404Template not foundInvalid template_id
404Report not foundInvalid report_id
500Failed to queue reportInternal queue error

Rate Limits

OperationLimitWindow
Create Report101 hour
List Reports1001 minute
Download501 minute

Best Practices

  1. Use webhooks for completion (if available) instead of polling
  2. Set appropriate priority - urgent for time-sensitive reports
  3. Enable PII scrambling for sensitive topics
  4. Link to Honey Jars for domain-specific context
  5. Monitor queue status before submitting large batches
  6. Handle timeouts gracefully - reports can take 5-25 minutes

Last updated: