API Reference

A REST API for extracting structured data from documents. Send a file, get back structured JSON.

REST APIJSON responsesWebhooks60+ languages

Authentication

All requests require an X-API-Key header. Get your key from Settings → API in your Airparser account.

cURL
curl https://api.airparser.com/inboxes \
  -H "X-API-Key: YOUR_API_KEY"

Store your API key securely — treat it like a password.

Parse Documents

Upload any file and get back fully extracted data in a single synchronous request — no webhooks, no polling, no second call. The response contains all extracted fields as structured JSON, ready to use immediately in your workflow.

POST/inboxes/{inbox_id}/upload-syncAPI docs →
curl \
  -X POST \
  https://api.airparser.com/inboxes/<INBOX_ID>/upload-sync \
  -F 'file=@./receipt.pdf' \
  -H "X-API-Key: <YOUR_API_KEY>"import requests

header = {"X-API-Key": "<API_KEY>"}
url = "https://api.airparser.com/inboxes/<INBOX_ID>/upload-sync"

with open('invoice.pdf', 'rb') as f:
    files = {'file': f}
    with requests.request("POST", url, files=files, headers=header) as response:
        print('response: ', response)const fetch = require("node-fetch");
const fs = require("fs");
const FormData = require("form-data");

const APIKEY = "<YOUR_API_KEY>";
const inboxId = "<INBOX_ID>";
const filePath = "/path/to/your/file.pdf";
const metadata = { foo: "bar" };

async function parseDocument(inboxId, filePath, metadata) {
  const url = `https://api.airparser.com/inboxes/${inboxId}/upload-sync`;

  const fileStream = fs.createReadStream(filePath);

  const form = new FormData();
  form.append("file", fileStream);
  form.append("meta", JSON.stringify(metadata));

  try {
    const response = await fetch(url, {
      method: "POST",
      body: form,
      headers: {
        "X-API-Key": APIKEY,
      },
    });

    const docId = await response.json();
    console.log(response.status);
    console.log("Document id:", docId);
  } catch (e) {
    console.error("Error:", e.message);
  }
}

parseDocument(inboxId, filePath, metadata);<?php

$apikey = '<API_KEY>';
$url = 'https://api.airparser.com/inboxes/<INBOX_ID>/upload-sync';
$filepath = './invoice.pdf';

$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'X-API-Key: ' . $apikey
));
curl_setopt($curl, CURLOPT_POST, true);

$meta = array(
  'foo' => 'bar',
  'my_id' => 42,
);
$metaJson = json_encode($meta);

curl_setopt($curl, CURLOPT_POSTFIELDS, array(
    'file' => curl_file_create($filepath, 'application/pdf', 'invoice.pdf'),
    'meta' => $metaJson
));

$response = curl_exec($curl);
curl_close($curl);

echo $response;
Response200 OK
{
  "doc_id": "64abc123def456...",
  "parsing_in_progress": false,
  "status": "parsed",
  "name": "invoice.pdf",
  "content_type": "application/pdf",
  "created_at": "2026-03-10T12:00:00.000Z",
  "processed_at": "2026-03-10T12:00:04.321Z",
  "json": {
    "invoice_number": "INV-001",
    "vendor": "Acme Corp",
    "total": 1250.00,
    "currency": "USD",
    "date": "2024-01-15"
  }
}

Retrieve Extracted Data

Fetch a document by ID to get its extraction status and results. Poll this endpoint or use webhooks to know when processing is complete.

GET/documents/{document_id}
cURL
curl https://api.airparser.com/documents/doc_abc123 \
  -H "X-API-Key: YOUR_API_KEY"
Response200 OK
{
  "doc_id": "64abc123def456...",
  "parsing_in_progress": false,
  "status": "parsed",
  "name": "invoice.pdf",
  "content_type": "application/pdf",
  "created_at": "2026-03-10T12:00:00.000Z",
  "processed_at": "2026-03-10T12:00:04.321Z",
  "json": {
    "invoice_number": "INV-001",
    "vendor": "Acme Corp",
    "total": 1250.00,
    "date": "2024-01-15"
  }
}

Define Extraction Schema

Define what fields to extract. Supports scalar fields, lists (for line items), and enums.

POST/inboxes/{inbox_id}/schema
{
  "fields": [
    {
      "type": "scalar",
      "data": {
        "name": "invoice_number",
        "description": "Invoice reference number",
        "type": "string",
        "default_value": ""
      }
    },
    {
      "type": "list",
      "data": {
        "name": "items",
        "description": "List of items in the invoice",
        "attributes": [
          {
            "name": "description",
            "description": "Item description",
            "type": "string",
            "default_value": ""
          },
          {
            "name": "amount",
            "description": "Item amount",
            "type": "decimal",
            "default_value": "0.00"
          }
        ]
      }
    },
    {
      "type": "enum",
      "data": {
        "name": "payment_status",
        "description": "Current payment status",
        "values": ["paid", "pending", "overdue"]
      }
    }
  ]
}

Post-Processing

Run Python code on extracted data before it's sent to integrations. Add business logic, merge fields, format values.

Merge fields
# Merge first and last name into full name
data['fullname'] = data['first_name'] + " " + data['last_name']

# Using f-strings (recommended)
data["fullname"] = f"{data['first_name']} {data['last_name']}"

# Using format() function
data['fullname'] = '{} {}'.format(data['first_name'], data['last_name'])
Conditional logic
# Only process invoices above certain amount
if float(data.get('total_amount', 0)) > 1000:
    data['priority'] = 'high'
else:
    data['priority'] = 'normal'

# Add timestamp
import datetime
data['processed_at'] = datetime.datetime.now().isoformat()

Explore advanced post-processing techniques and examples:

Webhooks

Airparser sends a POST request to your endpoint when extraction is complete. Respond with 200 to acknowledge.

Setup steps

  1. 1 Copy your webhook endpoint URL from your server or a service like ngrok.
  2. 2 Go to Integrations → Webhooks in your Airparser account.
  3. 3 Click "Create a webhook" and paste your endpoint URL.
  4. 4 Test the webhook with a sample document to verify the integration.
import json
from flask import Flask, request

app = Flask(__name__)

@app.route('/webhook', methods=['POST'])
def webhook():
    payload = request.data
    data = json.loads(payload)

    # Process the parsed data
    # data contains all extracted fields

    return {'success': True}

if __name__ == '__main__':
    app.run(port=4242)const express = require('express');
const app = express();

app.post('/webhook', express.raw({type: 'application/json'}), (request, response) => {
  const payload = request.body;
  const data = JSON.parse(payload);

  // Process the parsed data
  // data contains all extracted fields

  // Return 200 to acknowledge receipt
  response.send();
});

app.listen(4242, () => console.log('Running on port 4242'));<?php
$payload = @file_get_contents('php://input');
$data = json_decode($payload, true);

// Process the parsed data
// $data contains all extracted fields

// Always return 200 to acknowledge receipt
http_response_code(200);
echo "OK";

Resources

Looking for a non-technical overview? Read What is a Document Extraction API — covers the concept, use cases, and how Airparser's API works without code examples.