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

# Genie Documents

> Generate polished, ready-to-share documents from your Genie's knowledge base — FAQs, how-to guides, and one-pagers, all grounded in your own content.

Genie Documents lets you produce professionally written documents directly from the knowledge base attached to a Genie. You choose a template, select the source documents to draw from, and receive a structured, print-ready result in seconds.

All generated content is grounded strictly in the source material you provide — no facts are invented. The output is structured as an ordered list of sections, each with a heading and body, ready to render or export.

***

## Generate document

Produces a structured document from one or more knowledge-base documents using a Smart template. Only documents you own (or public documents) can be used as sources.

<ParamField body="resource" type="string" required>
  Must be `"genie-documents"`
</ParamField>

<ParamField body="action" type="string" required>
  Must be `"generate"`
</ParamField>

<ParamField body="data" type="object" required>
  <Expandable title="properties">
    <ParamField body="agentId" type="string" required>
      The Genie UUID. Used to scope the request to a specific assistant.
    </ParamField>

    <ParamField body="template" type="string" required>
      The document template to use. One of:

      * `"faq"` — Frequently Asked Questions sheet (6–12 Q\&A pairs)
      * `"how-to"` — Step-by-step guide with an intro and next-steps section
      * `"one-pager"` — Concise 4–6 section overview of your business
    </ParamField>

    <ParamField body="documentIds" type="string[]" required>
      Array of knowledge-base document UUIDs to use as source material. At least one document is required. Documents are combined up to an internal character limit; the largest documents are trimmed first if the total exceeds the limit.
    </ParamField>

    <ParamField body="purpose" type="string">
      Optional plain-text description of the document's focus (e.g. `"returning customer onboarding"`). When omitted, the template covers the most broadly useful information from the source material.
    </ParamField>

    <ParamField body="genieName" type="string">
      Display name of the business or assistant. Used to address the reader in the generated content. Defaults to `"your business"` if omitted.
    </ParamField>
  </Expandable>
</ParamField>

<ResponseField name="success" type="boolean">
  Whether the request succeeded.
</ResponseField>

<ResponseField name="data" type="object">
  <Expandable title="properties">
    <ResponseField name="document" type="object">
      The generated document.

      <Expandable title="properties">
        <ResponseField name="title" type="string">Document title.</ResponseField>
        <ResponseField name="subtitle" type="string">Optional one-line subtitle or tagline. May be an empty string.</ResponseField>
        <ResponseField name="template" type="string">The template key that was used (`"faq"`, `"how-to"`, or `"one-pager"`).</ResponseField>

        <ResponseField name="sections" type="array">
          Ordered content sections.

          <Expandable title="item properties">
            <ResponseField name="heading" type="string">Section heading (or the question text for FAQs).</ResponseField>
            <ResponseField name="body" type="string">Section content as plain text. Paragraphs are separated by blank lines. Bullet points start with `"- "` and numbered steps start with `"1. "`.</ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="meta" type="object">
      Generation metadata.

      <Expandable title="properties">
        <ResponseField name="sourceDocuments" type="string[]">Names of documents that contributed content to the output.</ResponseField>
        <ResponseField name="skippedDocuments" type="string[]">Names of documents that were skipped (no readable content yet, or access denied).</ResponseField>
        <ResponseField name="truncated" type="boolean">Whether any document content was trimmed to fit within the generation limit.</ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<CodeGroup>
  ```typescript ApiService.invoke() theme={null}
  const response = await ApiService.invoke({
    resource: "genie-documents",
    action: "generate",
    data: {
      agentId: "550e8400-e29b-41d4-a716-446655440000",
      template: "faq",
      documentIds: [
        "770e8400-e29b-41d4-a716-446655440002",
        "880e8400-e29b-41d4-a716-446655440003",
      ],
      purpose: "common questions from new customers",
      genieName: "Acme Support",
    },
  });
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.helpgenie.ai/v1 \
    -H "Authorization: Bearer hg_live_YOUR_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "resource": "genie-documents",
      "action": "generate",
      "data": {
        "agentId": "550e8400-e29b-41d4-a716-446655440000",
        "template": "faq",
        "documentIds": [
          "770e8400-e29b-41d4-a716-446655440002",
          "880e8400-e29b-41d4-a716-446655440003"
        ],
        "purpose": "common questions from new customers",
        "genieName": "Acme Support"
      }
    }'
  ```

  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "document": {
        "title": "Frequently Asked Questions",
        "subtitle": "Everything a new customer needs to know",
        "template": "faq",
        "sections": [
          {
            "heading": "What are your business hours?",
            "body": "We're open Monday through Friday, 9am to 5pm. Our team typically responds to messages within one business day."
          },
          {
            "heading": "How do I get started?",
            "body": "Simply create an account on our website and follow the setup wizard. The whole process takes under five minutes.\n\n1. Visit our website and click \"Sign up\"\n2. Enter your business details\n3. Connect your first channel"
          }
        ]
      },
      "meta": {
        "sourceDocuments": ["Product Overview", "Support Handbook"],
        "skippedDocuments": [],
        "truncated": false
      }
    }
  }
  ```
</CodeGroup>

***

## Templates

| Template     | Key           | Description                                                                                                                        |
| ------------ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| FAQ Sheet    | `"faq"`       | 6–12 question-and-answer pairs written in the customer's voice. Each section heading is the question; the body is a direct answer. |
| How-To Guide | `"how-to"`    | Step-by-step walkthrough with a short intro, ordered sections, and an optional next-steps section.                                 |
| One-Pager    | `"one-pager"` | Concise 4–6 section overview covering what the business offers, who it is for, and the key things a customer should know.          |

***

## Error codes

| Code               | Status | Description                                                                                                              |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------ |
| `VALIDATION_ERROR` | 400    | Missing `agentId`, invalid `template`, no `documentIds` supplied, or no readable content found in the selected documents |
| `NOT_FOUND`        | 404    | None of the specified document IDs exist                                                                                 |
| `FORBIDDEN`        | 403    | Access to the requested documents is denied                                                                              |
| `INTERNAL_ERROR`   | 500    | Document generation failed or returned no content                                                                        |
