Automatically extract structured invoice data using Zapier and the ParserData API, then send clean JSON to your favorite apps.
This Zapier integration template enables you to create automated workflows that:
- Trigger on new invoices (from email, cloud storage, forms, etc.)
- Send the invoice to ParserData API for intelligent data extraction
- Receive structured JSON with extracted invoice fields
- Connect the clean data to accounting software, CRMs, databases, or spreadsheets
- Trigger: New email with invoice attachment in Gmail
- Action: Extract invoice data using ParserData
- Action: Create expense/transaction in QuickBooks or Zero
- Trigger: New invoice file uploaded to cloud storage
- Action: Extract structured data using ParserData
- Action: Add record to Airtable database
- Trigger: Invoice uploaded via form (JotForm, Typeform)
- Action: Extract and validate invoice data
- Action: Send notification with extracted fields to team
- A Zapier account (Free or Paid)
- A ParserData API key (Sign up here)
- Source of invoices (Gmail, Dropbox, Google Drive, etc.)
- Destination app (QuickBooks, Airtable, Google Sheets, etc.)
- Log into Zapier.com
- Click "Create Zap"
- Give your Zap a name: "Invoice processing with ParserData"
Choose your trigger app:
- Gmail: "New Email" trigger with filters for invoice emails
- Google Drive: "New File in Folder" trigger
- Dropbox: "New File" trigger
- Typeform/JotForm: "New Submission" trigger
Configure the trigger according to your needs.
Add a "Code by Zapier" step:
- Click "+" to add a step
- Search for "Code by Zapier"
- Choose "Run JavaScript"
const axios = require('axios'); // Get API key from Zapier secrets (see Security section) const apiKey = process.env.PARSERDATA_API_KEY; // Get file from previous step const fileUrl = inputData.fileUrl; // From trigger const fileContent = inputData.fileContent; // Base64 encoded file async function extractInvoiceData() { try { // Prepare form data const formData = new FormData(); formData.append('prompt', 'Extract invoice number, invoice date, supplier name, total amount, tax amount, line items (description, quantity, unit price, net amount), and payment terms.'); formData.append('options', JSON.stringify({ return_schema: false, return_selected_fields: false })); // Add file - either from URL or base64 if (fileContent) { const buffer = Buffer.from(fileContent, 'base64'); formData.append('file', buffer, 'invoice.pdf'); } else if (fileUrl) { // Fetch file from URL const response = await axios.get(fileUrl, { responseType: 'arraybuffer' }); formData.append('file', Buffer.from(response.data), 'invoice.pdf'); } else { throw new Error('No file content or URL provided'); } // Call ParserData API const apiResponse = await axios.post('https://api.parserdata.com/v1/extract', formData, { headers: { 'X-API-Key': apiKey, ...formData.getHeaders() }, timeout: 300000 // 5 minutes }); // Return cleaned data return { extractedData: apiResponse.data.result || apiResponse.data, fileName: apiResponse.data.file_name || 'invoice.pdf', success: true, processedAt: new Date().toISOString() }; } catch (error) { // Implement retry logic if (error.response && [429, 500, 502, 503, 504].includes(error.response.status)) { // Log retry attempt console.log(`Retry needed for status ${error.response.status}`); throw error; // Zapier will retry based on settings } return { success: false, error: error.message, errorDetails: error.response?.data || null, processedAt: new Date().toISOString() }; } } // Execute and return result return extractInvoiceData();
Map the following fields in Code by Zapier:
| Field | Value |
|---|---|
fileUrl |
URL of invoice file from trigger (if available) |
fileContent |
Base64 encoded file content (if available) |
(Optional) customPrompt |
Custom extraction prompt if different from default |
Add your destination app:
- QuickBooks: "Create Expense" or "Create Bill"
- Airtable: "Create Record"
- Google Sheets: "Create Spreadsheet Row"
- Slack: "Send Channel Message"
- Email: "Send Outbound Email"
Map the extracted fields from ParserData to your destination app fields.
- Click "Test" to run a test with a sample invoice
- Verify the extracted data looks correct
- Turn on your Zap
Never hardcode your API key! Use Zapier's built-in secrets:
- In your Zap, go to the Code step
- Click "Manage Secrets" (bottom of code editor)
- Add a secret named
PARSERDATA_API_KEYwith your actual API key - Reference it as
process.env.PARSERDATA_API_KEYin your code
The example includes:
- HTTP Status Code Checking: Automatic retry for 429 (rate limit) and 5xx (server) errors
- Zapier Built-in Retry: Configure Zapier to retry failed steps (Settings → Retry)
- Timeout Handling: 5-minute timeout for large documents
- Structured Error Responses: Clear error messages for debugging
To configure additional retries in Zapier:
- Go to Zap Settings
- Enable "Retry on failure"
- Set maximum retries (recommended: 3)
- Set delay between retries (recommended: 5 minutes)
To extract different fields or handle specific document types:
-
Modify the prompt in the JavaScript code:
formData.append('prompt', 'Extract purchase order number, supplier, order date, delivery address, line items (product code, description, quantity, unit price, total).');
-
Handle different file types:
const fileName = inputData.fileName || 'document'; const extension = fileName.split('.').pop().toLowerCase(); // Handle PDF, JPG, PNG, etc.
-
Add field validation:
// Validate extracted data if (!extractedData.invoiceNumber || !extractedData.totalAmount) { return { success: false, error: 'Required fields missing' }; }
- File Size Limits: ParserData API has file size limits (check latest documentation)
- Rate Limits: Be aware of ParserData API rate limits
- Concurrent Zaps: Monitor performance if running multiple invoice processing Zaps simultaneously
- Processing Time: Allow 5-30 seconds for API response depending on document complexity
- Test with Sample Files: Use provided sample invoices in
/samplesfolder - Monitor Zap History: Check Zapier dashboard for successful/failed runs
- Validate Data Quality: Spot-check extracted data against original documents
- Load Test: Process multiple invoices to ensure stability
| Issue | Solution |
|---|---|
| API Key Invalid | Verify API key in Zapier secrets, regenerate if needed |
| File Not Processed | Check file format (PDF, JPG, PNG supported), verify file size limits |
| Timeout Errors | Increase timeout in code, check network connectivity |
| Incorrect Data Extraction | Refine extraction prompt, provide clearer examples in prompt |
| Rate Limit Errors | Reduce Zap frequency, implement exponential backoff |
- Use
console.log()in Code by Zapier to debug intermediate values - Check Zapier task history for detailed error logs
- Test API directly with curl:
curl -X POST -H "X-API-Key: YOUR_KEY" -F "file=@invoice.pdf" -F "prompt=Extract invoice fields" https://api.parserdata.com/v1/extract - Verify file URLs are accessible (not behind authentication)
See /examples directory for:
- Multi-step extraction workflows
- Data validation and transformation
- Error notification setups
- Batch processing implementations
This repository is a reference example. For production support or custom integration needs, contact support@parserdata.com.
MIT