Request
multipart/form-data
Request Body
filefilerequiredPDF file to process with form fields to be filled
Maximum 10MB, PDF format only
datastringrequiredText containing information to fill form fields (any format) - Required to provide data for filling the PDF
Example:
// 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."
Request 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"'Response
application/pdf
Response Body
bodybinaryBinary PDF file content with filled form fields
Response Headers
Content-Typestring - application/pdfContent-Dispositionstring - attachment; filename="filled-[filename].pdf"X-Processing-Statsstring - JSON string with processing statisticsX-Credits-Usednumber - Credits deducted for this operationX-Credits-Remainingnumber - Remaining credit balanceX-Credits-Currencystring - Currency of credits (USD)X-Rate-Limit-Remainingnumber - Remaining requests (session auth only)X-Rate-Limit-Resetnumber - Rate limit reset time (session auth only)Success Response Headers
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="filled-form.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, missing data parameter, or malformed data
401
Unauthorized
Invalid or missing API key
402
Payment Required
Insufficient credit balance
429
Too Many Requests
Rate limit exceeded for API key or session
500
Internal Server Error
Server error during processing
Insufficient Balance Error
{
"error": "Insufficient balance",
"amountRequired": 0.02,
"currentBalance": 0.01,
"pageCount": 1
}Rate Limit Error
{
"error": "Rate limit exceeded",
"resetTime": "1704456000"
}Validation Error
{
"error": "Invalid file format. Only PDF files are supported."
}
// or
{
"error": "The "data" parameter is required and cannot be empty"
}