> Source: https://builder-docs.ema.ai/api-reference/document-generation/overview
> Title: Document Generation Overview

# Document Generation Overview

Document Generation enables AI Employees to produce documents asynchronously. Unlike chat (real-time) or dashboard (batch processing), document generation follows an async lifecycle where a request is submitted, processed in the background, and the result is retrieved when ready.

## Async Lifecycle

Document generation follows a state machine with four statuses:

```
TRIGGERED → PROCESSING → COMPLETED
 → FAILED
```

Status

Description

`TRIGGERED`

Document generation request has been accepted

`PROCESSING`

The AI Employee is actively generating the document

`COMPLETED`

The document has been generated successfully

`FAILED`

Document generation encountered an error

## Workflow

1.  **Create**: Submit a document generation request with input data
2.  **Poll**: Retrieve the document status periodically until `COMPLETED` or `FAILED`
3.  **Use**: Access the generated document content from the response
4.  **Iterate**: Optionally regenerate or update the document

## Use Cases

-   **Report generation** -- Generate summary reports from data
-   **Email drafting** -- Create personalized email content
-   **Contract generation** -- Produce documents from templates and data
-   **Content creation** -- Generate marketing copy, documentation, etc.
-   **Data extraction** -- Extract structured information into document form

## Trigger Type

Document generation AI Employees use `PersonaTriggerType.DOCUMENT_GENERATION` (value `5`). This trigger type determines the AI Employee's interaction pattern and the available API endpoints.

## Preview and Iteration

The API supports a regeneration flow for iterating on documents:

1.  Call `Regenerate` (preview) to generate a new version without replacing the original
2.  Review the preview
3.  Call `Update` to finalize changes

This allows safe iteration without losing the previous version.

## Related

-   [Document Generation API](/legacy-docs/api-reference/document-generation/api) -- API endpoints
-   [AI Employee Overview](/legacy-docs/api-reference/ai-employees/overview) -- AI Employee architecture
-   [Workflow Overview](/legacy-docs/api-reference/workflows/overview) -- How workflows process document requests
