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

# How to generate documents with AI in n8n

> Give your AI Agent an MCP Client Tool pointed at Doconda's MCP, or use an HTTP Request to /v1/documents: the workflow gets the Word file or PDF.

In n8n there are two ways: add an **MCP Client Tool** pointed at `https://api.eu.doconda.com/mcp` to an **AI Agent**
node, or call `POST /v1/documents` with an **HTTP Request** node. Either way you get the finished document (Word,
PowerPoint, Excel or PDF) with its download links.

## Steps

### With an AI Agent (the agent decides the document)

1. Add an **AI Agent** node and, on its **Tool** input, an **MCP Client Tool** node.
2. **Endpoint**: `https://api.eu.doconda.com/mcp`.
3. **Server Transport**: `HTTP Streamable`.
4. **Authentication**: `Bearer Auth`, with a new credential where you paste your API key (without "Bearer").
5. **Tools to Include**: `All`, or only the ones you want (for example `create_document`).

Now you can ask the agent things like *"When an order comes in, generate its invoice as a PDF"*.

### With an HTTP Request (always the same document with workflow data)

1. Add an **HTTP Request** node: **Method** `POST`, **URL** `https://api.eu.doconda.com/v1/documents`.
2. **Authentication**: `Bearer Auth` with your API key.
3. **Body** (JSON), with n8n expressions to insert the workflow data:

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "format": "docx",
  "content": { "markdown": "# Hello {{ $json.name }}\n\nThanks for your order {{ $json.order }}." }
}
```

With `content.markdown` the text is used as is and Doconda only lays it out. If you'd rather have the AI write it,
replace `content` with `"prompt": "…"`. You can add `"style": "blue headings"` and change `format` to `pdf`, `pptx` or
`xlsx`.

## What you get back

The HTTP Request waits until the document is ready and returns:

```json theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
{
  "id": "doc_01JAB3H8K2M7V6X5T1R0NPQ4ZW",
  "object": "document",
  "status": "ready",
  "pages": 1,
  "outputs": [
    { "kind": "docx", "url": "https://…", "expires_at": "…" },
    { "kind": "pdf", "url": "https://…", "expires_at": "…" }
  ]
}
```

* `outputs`: the file and its PDF. Links expire after 5 minutes; get fresh ones with `GET /v1/documents/{id}/outputs`.
  To attach it to an email, download it in the next node with another HTTP Request to that `url`.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).

## FAQ

<AccordionGroup>
  <Accordion title="Can I review or edit a file that comes into the workflow?">
    Yes. With the agent, use `review_document` or `edit_document`; through the remote MCP server the file is uploaded by
    URL or as base64. With the API, `"operation": "edit"` and the uploaded `file`. See [Edit](/en/guides/edit).
  </Accordion>

  <Accordion title="How much does it cost?">
    You pay per delivered document; creating from your own Markdown costs less than from a prompt. See
    [pricing](/en/guides/account#pricing).
  </Accordion>

  <Accordion title="Where are the documents stored?">
    In the European Union (Ireland), and the AI that processes them also runs in the EU.
  </Accordion>
</AccordionGroup>

## Keep reading

* [n8n](/en/agents/n8n): the full guide.
* [Quickstart](/en/quickstart).


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