For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Book a demoLog in
DocumentationAPI ReferenceModel VersioningChangelog
DocumentationAPI ReferenceModel VersioningChangelog
    • Studio
    • Support
    • Benchmarks
    • Status
  • Getting Started
    • Overview
    • API Quickstart
    • Dashboard Quickstart
    • Agent Quickstart
  • Dev Tools
    • SDKs
    • CLI
  • Capabilities
      • Overview
      • Configuration
      • Response Format
      • Best Practices
      • Error Handling
      • Generate Edit Schema
LogoLogo
Book a demoLog in
On this page
  • Quick start
  • Example response
  • Key fields
  • Use the output
  • Sync vs async
  • Configuration
  • Instructions
  • Schema
  • Flatten the PDF
  • Tutorial video
  • Next steps
CapabilitiesEditing

Overview

Was this page helpful?
Previous

Configuration

Next
Built with

Editing fills PDF form fields programmatically and returns a completed document. You give it a PDF and either natural-language instructions or a schema describing the fields and values, and Extend detects the form’s fields, fills them, and returns a downloadable PDF along with the values it wrote. Use it to auto-fill applications, pre-populate documents with customer data, and generate filled forms at scale.

Quick start

We’ll fill a blank IRS Form 1040 from natural-language instructions. For this quick-start we’ve uploaded the file here.

First page of IRS Form 1040

Grab a key from the Developers page and store it as the EXTEND_API_KEY environment variable. If you’re using an SDK, see the installation instructions.

$export EXTEND_API_KEY="your_api_key_here"

The /edit endpoint takes a file and a config with instructions (or a schema).

Python
TypeScript
Java
Go
cURL
1import os
2from extend_ai import Extend
3
4client = Extend(token=os.environ["EXTEND_API_KEY"])
5
6result = client.edit(
7 file={
8 "url": "https://extend-public-files.s3.us-east-2.amazonaws.com/f1040.pdf",
9 },
10 config={
11 "instructions": (
12 "Fill the taxpayer's first name as Jordan and last name as Avery. "
13 "Set the Single filing status. Leave all other fields blank."
14 ),
15 "advancedOptions": {"flattenPdf": True},
16 },
17)
18
19print(result)

Want to edit your own document? Upload it first, then pass the returned file id instead of a url (reusing the same config).

Python
TypeScript
Java
Go
cURL
1with open("f1040.pdf", "rb") as f:
2 uploaded = client.files.upload(file=f)
3
4result = client.edit(file={"id": uploaded.id}, config=config)

Example response

After you run the code snippet above, you’ll see a response like this. Extend detects the form’s fields, fills the ones your instructions describe, and returns an output with the completed PDF in editedFile and the written values in filledValues.

1{
2 "object": "edit_run",
3 "id": "edr_xK9mLPqRtN3vS8wF5hB2cQ",
4 "status": "PROCESSED",
5 "output": {
6 "editedFile": {
7 "id": "file_Ab3cDE45Fg6hIj7KlM8nO",
8 "presignedUrl": "https://extend-files.s3.amazonaws.com/..."
9 },
10 "filledValues": {
11 "Your first name and middle initial": "Jordan",
12 "Last name": "Avery",
13 "filing_status_single": true
14 }
15 },
16 "metrics": { "processingTimeMs": 1234, "pageCount": 2, "fieldCount": 3 },
17 "usage": { "credits": 1 }
18}

Key fields

FieldWhat it contains
output.editedFile.idThe Extend file id of the completed PDF, reusable as input to other endpoints.
output.editedFile.presignedUrlA download URL for the completed PDF. Expires after 15 minutes.
output.filledValuesThe values written into the form, keyed by schema property name.
statusPROCESSING, PROCESSED, or FAILED.

For full request/response details, see the Create Edit Run API reference.

Use the output

Read the download link off output.editedFile, and inspect output.filledValues to see what was written.

Python
TypeScript
Java
Go
1edited = result.output.edited_file
2print("Download:", edited.presigned_url) # expires after 15 minutes
3
4for field, value in (result.output.filled_values or {}).items():
5 print(f"{field}: {value}")

For the full response shape and status values, see Response Format.

Sync vs async

The example above calls the synchronous /edit endpoint. We also have an asynchronous /edit_runs endpoint that should be used for large files and high volume use cases.

See Async Processing for the full comparison, polling options, and webhook setup.

Configuration

The quick start sends file and config.instructions. To control how the form is filled, pass more options inside config. Here are the most commonly used ones; for the full reference, see Configuration.

Instructions

Natural-language guidance describing the values to fill and any special handling. The fastest way to start — Extend detects the form’s fields and fills the ones you describe.

1{ "config": { "instructions": "Fill the applicant's name and today's date. Leave optional fields blank." } }

Schema

A JSON Schema that pins each field’s PDF type, value, and position using extend_edit:* keywords. Use it for exact, repeatable control over what gets filled and where.

1{
2 "config": {
3 "schema": {
4 "type": "object",
5 "properties": {
6 "applicant_name": {
7 "type": ["string", "null"],
8 "extend_edit:field_type": "text",
9 "extend_edit:value": "Jane Smith"
10 }
11 }
12 }
13 }
14}

Full schema reference →

Flatten the PDF

Flatten the document after editing so the filled fields become non-editable. Use it when generating final documents.

1{ "config": { "advancedOptions": { "flattenPdf": true } } }

Don’t have a schema yet? Generate Edit Schema detects a form’s fields and returns a starter schema with positions annotated. For every config option, see the Configuration reference.


Tutorial video

Next steps

Configuration

Instructions, schema, field types, and advanced options.

Generate Edit Schema

Detect a form’s fields and get a starter schema.

Response Format

The edit run output, filled values, and status values.

Best Practices

Schemas, flattening, polling, and reliable production runs.