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

# Edit Documents

> Fill forms and modify documents

The Edit API allows you to programmatically edit documents, such as filling forms using AI.

## API Usage Guide

Calling the [edit](/api-reference/v2/edit) endpoint initiates a document editing job.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from tensorlake.documentai import DocumentAI, FormFillingOptions

    doc_ai = DocumentAI(api_key="YOUR_API_KEY")

    form_filling = FormFillingOptions(
        fill_prompt="Fill the form for John Doe, born 01/01/1980.",
        ignore_source_values=True
    )

    # Returns a job ID
    job_id = doc_ai.edit(
        file_id="file_XXX",
        form_filling=form_filling
    )
    ```
  </Tab>

  <Tab title="REST API">
    ```bash theme={null}
    curl --request POST \
    --url https://api.tensorlake.ai/documents/v2/edit \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
        "file_id": "file_XXX",
        "form_filling": {
            "fill_prompt": "Fill the form for John Doe, born 01/01/1980.",
            "ignore_source_values": true
        }
    }'
    ```
  </Tab>
</Tabs>

## Form Filling

The `form_filling` object configures how the document should be filled.

| Parameter              | Description                                                                                                  | Default Value |
| ---------------------- | ------------------------------------------------------------------------------------------------------------ | ------------- |
| `fill_prompt`          | A custom prompt to use for form filling. This provides context or data to the AI model for filling the form. | `None`        |
| `ignore_source_values` | If `true`, the model will ignore existing values in the form fields and overwrite them.                      | `false`       |
| `no_acroform`          | If `true`, the model will not use AcroForm detection (standard PDF form fields).                             | `false`       |
| `no_widget_detection`  | If `true`, the model will not use do widget detection using visual analysis.                                 | `false`       |

## Output

The output of the edit operation includes the modified document and metadata.

* `filled_pdf_base64`: The base64 encoded string of the filled PDF document.
* `form_filling_metadata`: A dictionary containing metadata about the form filling process, such as fields identified and filled.
