Skip to main content
POST
/
v1
/
edit
/
agent
/
fill
from retab import Retab

client = Retab()

response = client.edit.agent.fill(
    document="form.pdf",
    instructions="Fill this form with: Name: John Doe, Date: 2025-01-02, Email: john@example.com",
    model="retab-small"
)


# Save the filled document
with open("filled_form.pdf", "wb") as f:
    import base64
    pdf_bytes = base64.b64decode(response.filled_document.url.split(",")[1])
    f.write(pdf_bytes)
{
  "form_data": [
    {
      "key": "full_name",
      "description": "Full name of the applicant",
      "type": "text",
      "value": "John Doe",
      "bbox": {
        "left": 0.15,
        "top": 0.22,
        "width": 0.32,
        "height": 0.03,
        "page": 1
      }
    },
    {
      "key": "date",
      "description": "Date of submission",
      "type": "date",
      "value": "2025-01-02",
      "bbox": {
        "left": 0.15,
        "top": 0.28,
        "width": 0.18,
        "height": 0.03,
        "page": 1
      }
    },
    {
      "key": "email",
      "description": "Email address",
      "type": "text",
      "value": "john@example.com",
      "bbox": {
        "left": 0.15,
        "top": 0.34,
        "width": 0.32,
        "height": 0.03,
        "page": 1
      }
    }
  ],
  "filled_document": {
    "filename": "form_filled.pdf",
    "mime_type": "application/pdf",
    "url": "data:application/pdf;base64,JVBERi0xLjQK..."
  }
}
Automatically detect fillable regions in a document and apply the values described in instructions. This endpoint supports PDF, DOCX, XLSX, and PPTX inputs.
from retab import Retab

client = Retab()

response = client.edit.agent.fill(
    document="form.pdf",
    instructions="Fill this form with: Name: John Doe, Date: 2025-01-02, Email: john@example.com",
    model="retab-small"
)


# Save the filled document
with open("filled_form.pdf", "wb") as f:
    import base64
    pdf_bytes = base64.b64decode(response.filled_document.url.split(",")[1])
    f.write(pdf_bytes)
{
  "form_data": [
    {
      "key": "full_name",
      "description": "Full name of the applicant",
      "type": "text",
      "value": "John Doe",
      "bbox": {
        "left": 0.15,
        "top": 0.22,
        "width": 0.32,
        "height": 0.03,
        "page": 1
      }
    },
    {
      "key": "date",
      "description": "Date of submission",
      "type": "date",
      "value": "2025-01-02",
      "bbox": {
        "left": 0.15,
        "top": 0.28,
        "width": 0.18,
        "height": 0.03,
        "page": 1
      }
    },
    {
      "key": "email",
      "description": "Email address",
      "type": "text",
      "value": "john@example.com",
      "bbox": {
        "left": 0.15,
        "top": 0.34,
        "width": 0.32,
        "height": 0.03,
        "page": 1
      }
    }
  ],
  "filled_document": {
    "filename": "form_filled.pdf",
    "mime_type": "application/pdf",
    "url": "data:application/pdf;base64,JVBERi0xLjQK..."
  }
}

Authorizations

Api-Key
string
header
required

Query Parameters

access_token
string | null

Body

application/json
document
MIMEData · object
template_id
string | null
instructions
string
default:""
form_fields
FormField · object[] | null
config
EditConfig · object
model
string
default:retab-small

Response

Successful Response

filled_document
MIMEData · object
required
usage
RetabUsage · object
required

Usage information for document processing.

form_data
FormField · object[]