Skip to main content
Edit is used to modify documents by applying instructions to either fill forms (PDF) or insert/modify content (DOCX). Edit takes in a PDF or DOCX file along with a prompt and then automatically detects the document’s layout, intelligently filling it in.

Key features

The edit endpoint supports two different document types with distinct capabilities:

DOCX editing

  • AI-powered content insertion: Uses intelligent agents to insert content at specific markers
  • Table cell editing: Modify existing table cells or add content to empty cells
  • Custom highlighting: Configurable highlight colors for edited content
  • Instruction-based editing: Natural language instructions for content modifications

PDF editing

  • Form filling: Automatically detects and fills form fields
  • Vision-based field detection: Uses computer vision to identify form elements
  • Multi-field support: Handles text fields, checkboxes, radio buttons, and dropdowns
  • Intelligent field mapping: Maps instructions to appropriate form fields

Configuration

EditConfig parameters

The edit endpoint uses the EditConfig class with the following parameters:
  • document_url: The document to edit (public URL, presigned S3 URL, or reducto:// URL)
  • edit_instructions: Natural language instructions describing the desired edits
  • edit_options: Configuration options including highlight color and LLM provider preference
  • priority: Whether to use priority processing (default: true for sync, false for async)

EditOptions

  • color: Hex color code for highlighting edits (default: “#FF0000”). This is only available for DOCX files.
  • llm_provider_preference: Choose between “openai” or “anthropic” (internal use)

Usage examples

Synchronous DOCX editing

from reducto import Reducto

client = Reducto(api_key="your-api-key")

# Upload document
upload = client.upload(file="contract.docx")

# Edit the document
result = client.edit(
    document_url=upload,
    edit_instructions="Fill in the client name as 'Acme Corporation' and set the contract date to January 15, 2024",
    edit_options={
        "color": "#0066CC"
    }
)

# Download the edited document
edited_document_url = result.document_url

Asynchronous PDF form filling

# Edit a PDF form asynchronously
result = client.edit_async(
    document_url="https://example.com/form.pdf",
    edit_instructions="Fill out the form with: Name: John Doe, Email: john@example.com, Select 'Yes' for newsletter subscription",
    webhook={
        "mode": "direct",
        "url": "https://your-app.com/webhook"
    }
)

job_id = result.job_id

Response format

Synchronous response (EditResponse)

{
    "document_url": "https://presigned-url-to-edited-document"
}

Asynchronous response (AsyncEditResponse)

{
    "job_id": "uuid-of-the-job"
}

Limitations and considerations

DOCX limitations

  • Requires documents with proper structure for marker-based insertion
  • Complex formatting may not be preserved in all cases
  • Large documents may take longer to process

PDF limitations

  • Densely packed form layouts may not be detected accurately

General limitations

  • File size limits apply (check your plan limits)
  • Processing time varies based on document complexity
  • Only DOCX and PDF formats are supported

Error handling

Common error scenarios:
  • 401 Unauthorized: Invalid or missing API key
  • 400 Bad Request: Unsupported file format, invalid configuration, no widgets found in PDF, or no pages with widgets found
  • 500 Internal Server Error: Processing failure or timeout

Best practices

  1. Clear instructions: Provide specific, actionable edit instructions
  2. Test with samples: Start with simple documents to understand capabilities
  3. Handle errors: Implement proper error handling for production use
  4. Async for large files: Use async processing for larger documents
  5. Validate forms: For PDFs, ensure forms are properly fillable before editing

FAQ

Yes, but each edit operation creates a new document. You’ll need to use the output from one edit as input to the next edit operation.
The edit endpoint is generally available. You can start using it with your existing API key.
Synchronous editing returns the result immediately but may timeout for large documents. Asynchronous editing returns a job ID immediately and processes the document in the background.
I