POST$0.01/page
https://pdfmage.app/api/v1/field-mapping

Field Mapping

Analyze PDF form fields and map them to relevant document content using AI. Get detailed field analysis, position data, and intelligent mapping suggestions for each form field.

Request

multipart/form-data

Request Body

filefilerequired

PDF file with form fields to analyze and map

Maximum 10MB, PDF format only, must contain form fields

AI-Powered Mapping

Advanced machine learning analyzes form field names, positions, and document content to provide intelligent mapping suggestions with confidence scores.

cURL Example
curl --request POST \
  --url https://pdfmage.app/api/v1/field-mapping \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer pk_live_abc123...' \
  --form 'file=@/path/to/form.pdf'
JavaScript Example
const formData = new FormData();
formData.append('file', pdfFile);

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

if (response.ok) {
  const mappingResult = await response.json();
  console.log('Fields detected:', mappingResult.statistics.totalFields);
  console.log('Mapping success rate:', mappingResult.statistics.mappingSuccess);
  
  mappingResult.fields.forEach(field => {
    console.log(`Field: ${field.name} - Confidence: ${field.mapping.confidence}`);
  });
} else {
  const error = await response.json();
  console.error('Error:', error);
}

Response

application/json

Response Body

fileNamestring - Original filename of processed document
processedAtstring (ISO 8601) - Processing completion timestamp
pageCountnumber - Total number of pages in document
fieldsarray

Array of detected form fields with mapping information

namestring - Field name/identifier
typestring - Field type (text, checkbox, radio, dropdown, signature)
requiredboolean - Whether field is required
pagenumber - Page number containing this field
positionobject - Field position coordinates
• x: number - X coordinate
• y: number - Y coordinate
mappingobject - AI mapping results
• relevantText: string - Document text relevant to field
• confidence: number - Mapping confidence score (0-1)
• reasoning: string - AI explanation for mapping
statisticsobject

Mapping operation statistics

totalFieldsnumber - Total form fields detected
mappedFieldsnumber - Fields successfully mapped
unmappedFieldsnumber - Fields that could not be mapped
mappingSuccessnumber - Overall mapping success rate (0-1)
extractedTextobject

Document text extraction results

fullTextstring - Complete extracted text from document
pageCountnumber - Number of pages processed
Success Response Example
{
  "fileName": "employment-form.pdf",
  "processedAt": "2024-01-15T10:30:45.123Z",
  "pageCount": 1,
  "fields": [
    {
      "name": "firstName",
      "type": "text",
      "required": true,
      "page": 1,
      "position": {
        "x": 120.5,
        "y": 680.2
      },
      "mapping": {
        "relevantText": "First Name: John",
        "confidence": 0.95,
        "reasoning": "Field label 'firstName' matches document text 'First Name: John'"
      }
    },
    {
      "name": "employmentDate",
      "type": "text", 
      "required": false,
      "page": 1,
      "position": {
        "x": 120.5,
        "y": 640.8
      },
      "mapping": {
        "relevantText": "Start Date: January 15, 2024",
        "confidence": 0.87,
        "reasoning": "Employment date field likely corresponds to 'Start Date' in document"
      }
    }
  ],
  "statistics": {
    "totalFields": 12,
    "mappedFields": 10,
    "unmappedFields": 2,
    "mappingSuccess": 0.83
  },
  "extractedText": {
    "fullText": "Employment Application\n\nFirst Name: John\nLast Name: Doe\nStart Date: January 15, 2024...",
    "pageCount": 1
  }
}
Response Headers
HTTP/1.1 200 OK
Content-Type: application/json
X-Credits-Used: 0.01
X-Credits-Remaining: 4.99
X-Credits-Currency: USD

Error Responses

400

Bad Request

Invalid file format, missing file, or corrupted PDF

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 contains no fillable form fields

No Fields Error
{
  "error": "Unprocessable Entity",
  "message": "No form fields found in PDF",
  "details": {
    "code": "NO_FORM_FIELDS",
    "pageCount": 2,
    "suggestion": "Ensure PDF contains fillable form fields"
  },
  "timestamp": "2024-01-15T10:30:00Z",
  "requestId": "req_abc123"
}
Processing Error
{
  "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"
}

Mapping Intelligence

Semantic Understanding

AI understands field names, labels, and context to provide intelligent mapping suggestions.

Confidence Scoring

Each mapping includes confidence scores to help you validate and prioritize results.

Detailed Analysis

Get field positions, types, requirements, and detailed reasoning for each mapping decision.

Advanced AI Mapping

Our field mapping uses advanced natural language processing to understand relationships between form fields and document content, providing accurate mapping even for complex forms with non-standard field names.

Common Use Cases

Form Analysis

Analyze complex forms to understand field structure and requirements before implementing automated filling workflows.

Data Validation

Validate that your data structure matches form fields and identify missing or incompatible data points.

Integration Planning

Plan API integrations by understanding form structure and mapping requirements for automated processing.

Quality Assurance

Use confidence scores to identify potential mapping issues and ensure high-quality form filling results.

Debugging

Debug form filling issues by analyzing field mappings and understanding AI reasoning for each decision.

Custom Workflows

Build custom form processing workflows using detailed field information and mapping intelligence.

Related Endpoints

Fill PDF Forms

Use field mapping results in the full form filling pipeline

Document OCR

Extract text content that feeds into the mapping analysis

PDF Mage - AI PDF Form Filler