---
title: "Edit"
description: "Fill forms and modify documents with natural language instructions"
---

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

# Edit

Edit fills PDF forms and modifies DOCX documents using natural language instructions. You describe what values should go where, and Reducto handles field detection, mapping, and insertion.

Edit completes the document lifecycle. Where [Parse](/parse/overview) reads documents and [Extract](/extract/overview) pulls data out, Edit writes data back in. This enables end-to-end workflows: classify an incoming document, extract data from it, and populate a different form or template, all within a single pipeline.

> **Note:** The Edit endpoint is available in the Python SDK, Node.js SDK, and via cURL. The Go SDK does not yet support Edit.

> **Note:** Looking for an editor your users work in, or an Office.js-style API to edit `.docx`, `.pptx` and `.xlsx` files from your own code? That is the [Reducto Office SDK](/office), a separate product.

---

## When to Use Edit

Edit solves form filling at scale. Instead of manually clicking through fillable PDFs or templating Word documents, you describe what you want in natural language.

**Common use cases:**
- Filling government and tax forms (W-9, I-9, G-1145) with applicant data
- Completing insurance applications and claim forms
- Populating legal contracts with client information
- Generating customized DOCX reports from extracted data

PDF libraries like PyPDF require knowing exact field names and coordinates. Edit uses AI to understand field context, so "Fill in the applicant name" works even if the PDF field is named `topmostSubform[0].Page1[0].f1_1[0]`.

---

## Quick Start

**Python**

```python
from pathlib import Path
from reducto import Reducto

client = Reducto()
upload = client.upload(file=Path("w9_form.pdf"))

result = client.edit.run(
    document_url=upload.file_id,
    edit_instructions="""
        Fill this W-9 form with:
        - Name: Acme Corporation
        - Business name: Acme Corp LLC
        - Tax classification: LLC
        - Address: 123 Main Street, San Francisco, CA 94102
        - TIN: 12-3456789
    """
)

print(result.document_url)  # Download the filled form
```

**Node.js**

```javascript
import Reducto from 'reductoai';
import fs from 'fs';

const client = new Reducto();
const upload = await client.upload({
  file: fs.createReadStream('w9_form.pdf'),
});

const result = await client.edit.run({
  document_url: upload.file_id,
  edit_instructions: `
    Fill this W-9 form with:
    - Name: Acme Corporation
    - Business name: Acme Corp LLC
    - Tax classification: LLC
    - Address: 123 Main Street, San Francisco, CA 94102
    - TIN: 12-3456789
  `
});

console.log(result.document_url);  // Download the filled form
```

**cURL**

```bash
# First upload the file
FILE_ID=$(curl -s -X POST https://platform.reducto.ai/upload \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -F "file=@w9_form.pdf" | jq -r '.file_id')

# Then edit
curl -X POST https://platform.reducto.ai/edit \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "'$FILE_ID'",
    "edit_instructions": "Fill this W-9 form with: Name: Acme Corporation, Business name: Acme Corp LLC, Tax classification: LLC, Address: 123 Main Street, San Francisco, CA 94102, TIN: 12-3456789"
  }'
```

**What happens:**
1. Edit detects all fillable fields in the PDF (text boxes, checkboxes, dropdowns)
2. An LLM reads your instructions and field context (labels, surrounding text)
3. Each field gets mapped to the appropriate value
4. The filled PDF is returned as a downloadable URL

---

## PDF vs DOCX

### PDF

PDFs have structured form widgets (text fields, checkboxes, dropdowns). For PDFs without existing form fields, Edit uses vision to detect where fillable areas should be.

| Feature | Description |
|---------|-------------|
| Text fields | Fill any text input area |
| Checkboxes | Check or uncheck based on instructions |
| Dropdowns | Choose from available options |
| Form detection | Finds fields even in scanned forms |
| Overflow | Long text can flow to appendix pages |

### DOCX

Edit fills Word form controls in place and adds new text to table cells and paragraphs.

| Feature | Description |
|---------|-------------|
| Form fields | Modern (2007+) content controls and legacy text form fields. Edit fills them in place and keeps the formatting of any existing field text |
| Checkboxes | Both modern and legacy controls |
| Table cells | Add content as a new paragraph in the cell |
| Text insertion | Insert content as a new paragraph after an existing paragraph |
| Highlighting | Edits get highlighted in configurable color |

---

## Request Parameters

**Python**

```python
result = client.edit.run(
    document_url="...",           # Required: file to edit
    edit_instructions="...",      # Required: what to fill
    edit_options={
        "color": "#FF0000",                  # Highlight color (DOCX only)
        "enable_overflow_pages": False,      # Appendix for long text (PDF only)
        "llm_provider_preference": "openai"  # LLM provider (optional)
    },
    form_schema=[...]             # Optional: predefined field locations (PDF only)
)
```

**Node.js**

```javascript
const result = await client.edit.run({
  document_url: '...',           // Required: file to edit
  edit_instructions: '...',      // Required: what to fill
  edit_options: {
    color: '#FF0000',                   // Highlight color (DOCX only)
    enable_overflow_pages: false,       // Appendix for long text (PDF only)
    llm_provider_preference: 'openai'   // LLM provider (optional)
  },
  form_schema: [...]             // Optional: predefined field locations (PDF only)
});
```

**cURL**

```bash
curl -X POST https://platform.reducto.ai/edit \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "...",
    "edit_instructions": "...",
    "edit_options": {
      "color": "#FF0000",
      "enable_overflow_pages": false,
      "llm_provider_preference": "openai"
    },
    "form_schema": [...]
  }'
```

### document_url

The document to edit. Accepts the same formats as Parse: `reducto://` file IDs from upload, public URLs, or presigned S3/GCS URLs.

### edit_instructions

Natural language instructions describing what to fill. Be explicit about values and which fields they belong to:

```
Fill this form with:
- Full Name: John David Smith
- Date of Birth: March 15, 1985
- SSN: 123-45-6789
- Check "Yes" for US Citizen
- Select "California" for state
```

Vague instructions like "Fill out John's information" perform poorly. Include formatting hints when the form expects specific formats (dates, phone numbers, SSNs).

### edit_options

| Option | Default | Description |
|--------|---------|-------------|
| `color` | `#FF0000` | Hex color for highlighting edits (DOCX only) |
| `enable_overflow_pages` | `false` | Create appendix pages for text exceeding field capacity (PDF only) |
| `llm_provider_preference` | `null` | LLM provider for form filling: `"openai"`, `"anthropic"`, or `"google"`. If null, defaults to Google. |

### form_schema

For repeatable form filling, define field locations explicitly. This skips detection, improving speed 3x and consistency. See [Form Schema](/configs/edit/form-schema).

---

## Response

```json
{
  "document_url": "https://storage.reducto.ai/filled-form.pdf?...",
  "form_schema": [
    {
      "bbox": {"left": 0.1, "top": 0.2, "width": 0.4, "height": 0.03, "page": 1},
      "description": "Name field in header section",
      "type": "text",
      "value": "John David Smith",
      "filled": true
    },
    {
      "bbox": {"left": 0.1, "top": 0.26, "width": 0.4, "height": 0.03, "page": 1},
      "description": "Middle name field in header section",
      "type": "text",
      "value": null,
      "filled": false
    }
  ],
  "usage": {"num_pages": 2, "credits": null},  // credits is populated only for credit-based accounts
  "warnings": null
}
```

| Field | Description |
|-------|-------------|
| `document_url` | Presigned URL to download edited document. Valid 24 hours. |
| `form_schema` | Detected field schema (PDF only). Save this to reuse for the same form type. |
| `form_schema[].value` | The value Edit wrote to the field, or `null` if it wrote nothing. |
| `form_schema[].filled` | `true` if Edit wrote a value to the field, `false` if it left the field empty. For a checkbox, `true` means Edit set its state, so read `value` to see if the box is checked. See [Form Schema](/configs/edit/form-schema#check-which-fields-were-filled). |
| `warnings` | Warnings about the edit, or `null`. For example, Edit returns a warning when it filled no form fields. |
| `usage.credits` | Credits charged. Populated only for credit-based accounts; `null` for accounts on per-product pricing. See [Usage and Pricing](/reference/credit-usage#edit-endpoint). |
| `usage.usage_breakdown` | Raw usage quantities. Present only for accounts on per-product pricing, where the credit fields are null. See [Pricing Migration Guide](/reference/pricing-migration#what-your-api-responses-look-like). |

---

## Async Processing

For larger documents or webhook delivery, use the async endpoint:

**Python**

```python
result = client.edit.run_job(
    document_url=upload.file_id,
    edit_instructions="...",
)
print(result.job_id)  # Poll /job/{job_id} or wait for webhook

# Poll for results
import time
while True:
    job = client.job.get(result.job_id)
    if job.status == "Completed":
        print(job.result.document_url)
        break
    time.sleep(2)
```

**Node.js**

```javascript
const result = await client.edit.runJob({
  document_url: upload.file_id,
  edit_instructions: '...',
});
console.log(result.job_id);  // Poll /job/{job_id} or wait for webhook

// Poll for results
while (true) {
  const job = await client.job.retrieve(result.job_id);
  if (job.status === 'Completed') {
    console.log(job.result.document_url);
    break;
  }
  await new Promise(r => setTimeout(r, 2000));
}
```

**cURL**

```bash
# Submit async job
JOB_ID=$(curl -s -X POST https://platform.reducto.ai/edit_async \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document_url": "reducto://your-file-id",
    "edit_instructions": "..."
  }' | jq -r '.job_id')

# Poll for results
while true; do
  STATUS=$(curl -s https://platform.reducto.ai/job/$JOB_ID \
    -H "Authorization: Bearer $REDUCTO_API_KEY" | jq -r '.status')
  echo "Status: $STATUS"
  if [ "$STATUS" = "Completed" ]; then
    curl -s https://platform.reducto.ai/job/$JOB_ID \
      -H "Authorization: Bearer $REDUCTO_API_KEY" | jq '.result.document_url'
    break
  fi
  sleep 2
done
```

Sync requests get priority by default. Async requests can set `priority=True`: workers poll the priority queue ahead of the standard queue, so priority jobs start sooner when there is queued work.

---

## How It Works

### PDF

1. **Detect** form widgets (or use vision if none exist)
2. **Analyze** context around each field (labels, headers)
3. **Map** your instructions to fields based on descriptions
4. **Fill** values into the PDF

With a `form_schema`, steps 1-2 are skipped since you've defined field locations and descriptions.

### DOCX

1. **Tag** editable locations (paragraphs, table cells, form controls)
2. **Analyze** document structure against your instructions
3. **Generate** specific edits (fill form fields, check boxes, add text to cells and paragraphs)
4. **Apply** edits with optional highlighting

---

## Troubleshooting

**Fields remain empty**

Several things can cause unfilled fields:

- **Instructions didn't match**: The LLM couldn't map your instructions to that field. Use terms that appear on the form itself.
- **Dropdown mismatch**: Value must exactly match an option ("CA" vs "California")
- **Detection missed it**: Use `form_schema` to explicitly define field locations

**No form fields detected**

The PDF has no widgets and vision couldn't detect fillable areas. Common causes:

- Scanned image without clear form structure
- Fields blend into background or lack clear boundaries
- Document isn't actually a fillable form

**Solution**: Provide a `form_schema` defining field locations. See [Form Schema](/configs/edit/form-schema).

**Text cut off in PDF fields**

PDF fields have fixed sizes. When content exceeds capacity, it gets truncated.

**Solutions:**

1. Enable overflow: `edit_options={"enable_overflow_pages": True}` creates appendix pages
2. Abbreviate in your instructions if the form expects short values

**Checkboxes not checking**

Be explicit: `Check "Yes" for US Citizen` works better than `US Citizen: Yes`. The LLM needs to understand you mean check a box, not fill text.

**Wrong field gets filled**

When fields have similar labels, the LLM may map incorrectly:

1. **Be more specific**: "Applicant First Name: John" rather than "Name: John"
2. **Use form\_schema**: Define exactly which field is which using coordinates
3. **Reference position**: "The name field in the top-left of page 1"

**Can I use Parse to get field locations?**

No. Parse finds existing content (labels like "Name:"). Edit finds empty fillable areas (the input box next to "Name:"). Form fields are blank rectangles with nothing for Parse to detect.

Use Edit once without `form_schema` to detect fields, then save and reuse the returned schema.

---

## Limitations

### Partial Success

Edit returns successfully even when some fields couldn't be filled. These situations don't raise errors:

| Scenario | Behavior |
|----------|----------|
| Dropdown value not in options | Field skipped silently |
| Instructions don't match any field | Document returned unchanged |
| Unsupported widget (signatures, images) | Widget skipped |

### Format-Specific

**PDF:**
- Signature and image fields not supported
- Radio buttons have limited support
- Heavily designed forms may detect incorrectly

**DOCX:**
- Requires structured documents (form controls, tables)
- Edit does not replace existing text, such as a `[Placeholder]` in a table cell or paragraph. It adds the value as a new paragraph without the surrounding formatting. To fill values in place, use form fields.
- Edit does not support legacy dropdown form fields
- Very large documents (100+ pages) take longer

---

## Next Steps

- [Form Schema](/configs/edit/form-schema): Pre-define field locations for faster, more consistent filling.

- [API Reference](/api-reference/api/sections/edit/operations/edit): Complete endpoint specification.

Source: https://docs.reducto.ai/editing/edit-overview/index.mdx
