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

# Initialize knowledge folders

> Generate a downloadable tree-import template file from an initialization prompt.

Use this route when you are setting up knowledge folders for the first time and want Fini to scaffold a starting folder-and-article structure.

<Info>
  This route returns a downloadable file, not JSON. Save the response body using the returned `Content-Type` and `Content-Disposition` headers, then import that file with [Persist knowledge folders](/en/api-reference/persist-knowledge-folders).
</Info>

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token containing your Fini workspace API key. Format: `Bearer fini_...` The key needs `write` scope.
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Body parameters

<ParamField body="initPrompt" type="string" required>
  Prompt describing the folder-and-article structure you want Fini to scaffold.
</ParamField>

## Response

The response body is a generated tree template file.

<ResponseField name="file" type="binary">
  Downloadable tree-import template file.
</ResponseField>

<ResponseField name="Content-Type" type="string">
  MIME type for the returned file.
</ResponseField>

<ResponseField name="Content-Disposition" type="string">
  Attachment header containing the suggested filename.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api-prod.usefini.com/v2/knowledge/public/tree/initialize' \
    --header 'Authorization: Bearer fini_your_api_key' \
    --header 'Content-Type: application/json' \
    --data '{
      "initPrompt": "Create a support knowledge tree for billing, shipping, and returns."
    }' \
    --output fini-tree-template.csv
  ```
</RequestExample>

## Next step

Review the generated file, make any edits you want, then upload it with [Persist knowledge folders](/en/api-reference/persist-knowledge-folders).

## Errors

<AccordionGroup>
  <Accordion title="400 Bad Request" icon="circle-exclamation">
    The request body is malformed or `initPrompt` is missing or empty.
  </Accordion>

  <Accordion title="401 Unauthorized" icon="lock">
    The API key is missing, malformed, revoked, or invalid.
  </Accordion>

  <Accordion title="403 Forbidden" icon="shield-halved">
    The API key does not include the `write` scope.
  </Accordion>

  <Accordion title="500 Internal Server Error" icon="triangle-exclamation">
    Fini failed while generating the tree template. Retry once, then narrow the prompt if the failure persists.
  </Accordion>
</AccordionGroup>
