POSTMost Popular$0.02/page
https://pdfmage.app/api/v1/fill-pdf

Fill PDF Forms

Full PDF form filling pipeline: extract fields, OCR text, map fields, generate values, and return filled PDF. This endpoint handles the entire process from input PDF to completed form.

Request

multipart/form-data

Request Body

filefilerequired

PDF file to process with form fields to be filled

Maximum 10MB, PDF format only

datastringoptional

Text containing information to fill form fields (any format)

Example formats (all are valid):

// Structured format:
Name: John Doe
Email: [email protected]
Phone: +1-555-123-4567
Address: 123 Main St, New York, NY 10001

// Unstructured format:
"I'm John Doe, living at 123 Main St in New York.
My email is [email protected] and phone is +1-555-123-4567."

// Mixed format:
John Doe | [email protected]
123 Main St, New York, NY 10001
Phone: (555) 123-4567
cURL Example
curl --request POST \
  --url https://pdfmage.app/api/v1/fill-pdf \
  --header 'Accept: application/pdf' \
  --header 'Authorization: Bearer pk_live_abc123...' \
  --form 'file=@/path/to/form.pdf' \
  --form 'data="John Doe, [email protected], +1-555-123-4567, 123 Main St, New York, NY 10001"'
JavaScript Example
const formData = new FormData();
formData.append('file', pdfFile);
formData.append('data', `
  Name: John Doe
  Email: [email protected]
  Phone: +1-555-123-4567
  Address: 123 Main St, New York, NY 10001
`);

const response = await fetch('https://pdfmage.app/api/v1/fill-pdf', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer pk_live_abc123...'
  },
  body: formData
});

if (response.ok) {
  const filledPdf = await response.blob();
  // Save or display the filled PDF
} else {
  const error = await response.json();
  console.error('Error:', error);
}

Response

application/pdf

Response Body

bodybinary

Binary PDF file content with filled form fields

Response Headers

Content-Typestring - application/pdf
Content-Dispositionstring - attachment; filename="filled-document.pdf"
X-Processing-Statsstring - JSON string with processing statistics
X-Credits-Usednumber - Credits deducted for this operation
X-Credits-Remainingnumber - Remaining credit balance
X-Credits-Currencystring - Currency of credits (USD)
Success Response Headers
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="filled-document.pdf"
Content-Length: 1048576
X-Processing-Stats: {"processingTime":1247,"confidence":0.95}
X-Credits-Used: 0.02
X-Credits-Remaining: 4.98
X-Credits-Currency: USD

[Binary PDF Content]
Processing Stats Details
// X-Processing-Stats header contains:
{
  "timing": {
    "fieldExtraction": 120,      // Field extraction time (ms)
    "textExtraction": 450,       // OCR processing time (ms)
    "fieldMapping": 230,         // Field mapping time (ms)
    "fieldFilling": 180,         // Field filling time (ms)
    "pdfGeneration": 267,        // PDF generation time (ms)
    "total": 1247                // Total processing time (ms)
  }
}

Error Responses

400

Bad Request

Invalid file format, missing file, or malformed data parameter

401

Unauthorized

Invalid or missing API key

402

Payment Required

Insufficient credit balance

413

Payload Too Large

File exceeds maximum size limit (10MB)

422

Unprocessable Entity

PDF has no fillable form fields or is corrupted

Error Response Example
{
  "error": "Insufficient balance",
  "message": "Not enough credits to process this request",
  "details": {
    "code": "INSUFFICIENT_BALANCE", 
    "amountRequired": 0.02,
    "currentBalance": 0.01,
    "pageCount": 1
  },
  "timestamp": "2024-01-15T10:30:00Z",
  "requestId": "req_abc123"
}
Validation Error Example
{
  "error": "Bad Request",
  "message": "Invalid file format",
  "details": {
    "code": "INVALID_FILE_FORMAT",
    "allowedFormats": ["pdf"],
    "receivedFormat": "docx"
  },
  "timestamp": "2024-01-15T10:30:00Z",
  "requestId": "req_def456"
}

Processing Flow

1. Field Extraction

Extract all fillable form fields from the PDF

2. OCR Processing

Extract text content using Google Document AI

3. Field Mapping

AI maps your data to the appropriate form fields

4. PDF Generation

Generate the filled PDF with all form fields populated

Processing typically takes 1-3 seconds

The entire pipeline is optimized for speed while maintaining high accuracy. Processing time depends on document complexity and number of form fields.

Related Endpoints

Document OCR

Extract text and structured data from PDFs without form filling

Field Mapping

Analyze PDF form fields and their relationships to document content

PDF Mage - AI PDF Form Filler