Edit is used to modify documents by applying instructions to either fill forms (PDF) or insert/modify content (DOCX). The edit endpoint is currently in beta and available only to whitelisted organizations.

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
  • Text snippets: Reusable text snippets that can be referenced throughout the document
  • 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
  • snippets: Array of reusable text snippets (DOCX only)
  • 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”)
  • 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",
    snippets=["Acme Corporation", "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

  • Only works with fillable PDF forms
  • Snippets are not supported for PDF editing
  • Scanned PDFs without form fields cannot be edited
  • Complex form layouts may not be detected accurately

General Limitations

  • Beta access required (contact support for access)
  • 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
  • 403 Forbidden: Organization not whitelisted for beta access
  • 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

Beta Access

The edit endpoint is currently in beta and restricted to specific organizations:

  • Reducto AI
  • Vanta
  • Vanta Staging

Contact support to request beta access for your organization.

Best Practices

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

FAQ