The guide
- 1
Set up your Notion database
Create a Notion database with these property types:
Vendor — Title Amount — Number Currency — Text Date — Date Invoice # — Text Tax — Number Payment Method — Text Receipt — Files & media
- 2
Get your Notion API key
Go to developers.notion.com → New integration → copy the Internal Integration Secret. In Notion, open your database → Share → Invite → select your integration by name.
- 3
Get your Database ID
Copy the Database ID from your Notion database URL:
notion.so/workspace/[DATABASE-ID]?v=... ^^^^^^^^^^^^^^^^ This is your NOTION_DATABASE_IDSign up — get a free API keyNeed your API key first?20 free documents/month — no credit card - 4
Extract the document
Submit your receipt or invoice and fetch the result (see the Python guide). The fetched data gives you merchant, total, tax, date, currency and invoice_id.
- 5
Write to Notion
POST to the Notion API pages endpoint with your database ID and extracted fields. Store a link to the original receipt (for example its Google Drive URL) in a Files & media property so it sits next to the extracted data.
import os, requests NOTION_DB_ID = os.environ["NOTION_DATABASE_ID"] NOTION_HEADERS = { "Authorization": f"Bearer {os.environ['NOTION_API_KEY']}", "Notion-Version": "2022-06-28", "Content-Type": "application/json", } def log_to_notion(inv, file_url=None): props = { "Vendor": {"title": [{"text": {"content": inv.get("merchant") or "Unknown"}}]}, "Amount": {"number": float(inv.get("total") or 0)}, "Tax": {"number": float(inv.get("tax") or 0)}, "Currency": {"rich_text": [{"text": {"content": inv.get("currency") or "USD"}}]}, "Invoice #": {"rich_text": [{"text": {"content": inv.get("invoice_id") or ""}}]}, "Payment Method": {"rich_text": [{"text": {"content": inv.get("payment_method") or ""}}]}, } if inv.get("date"): props["Date"] = {"date": {"start": inv["date"]}} if file_url: props["Receipt"] = {"files": [{"name": "receipt", "type": "external", "external": {"url": file_url}}]} r = requests.post("https://api.notion.com/v1/pages", headers=NOTION_HEADERS, json={"parent": {"database_id": NOTION_DB_ID}, "properties": props}) r.raise_for_status() return r.json()
Full working example
import os, time, requests
NOTION_DB_ID = os.environ["NOTION_DATABASE_ID"]
NOTION_HEADERS = {
"Authorization": f"Bearer {os.environ['NOTION_API_KEY']}",
"Notion-Version": "2022-06-28",
"Content-Type": "application/json",
}
API = "https://docuparseapi.com/api/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['DOCUPARSE_API_KEY']}"}
def parse_document(path: str) -> dict:
# 1. Submit
with open(path, "rb") as f:
submit = requests.post(f"{API}/extract", headers=HEADERS,
files={"file": (os.path.basename(path), f)}, timeout=30).json()
if not submit.get("success"):
raise RuntimeError(f"[{submit['error']['code']}] {submit['error']['message']}")
# 2. Fetch the result
for _ in range(40):
doc = requests.get(f"{API}/documents/{submit['document_id']}",
headers=HEADERS, timeout=30).json()
if doc["status"] == "completed":
return doc["data"]
if doc["status"] == "failed":
raise RuntimeError(f"Extraction failed: {submit['document_id']}")
time.sleep(1.5)
raise TimeoutError(submit["document_id"])
def log_to_notion(inv, file_url=None):
props = {
"Vendor": {"title": [{"text": {"content": inv.get("merchant") or "Unknown"}}]},
"Amount": {"number": float(inv.get("total") or 0)},
"Tax": {"number": float(inv.get("tax") or 0)},
"Currency": {"rich_text": [{"text": {"content": inv.get("currency") or "USD"}}]},
"Invoice #": {"rich_text": [{"text": {"content": inv.get("invoice_id") or ""}}]},
"Payment Method": {"rich_text": [{"text": {"content": inv.get("payment_method") or ""}}]},
}
if inv.get("date"):
props["Date"] = {"date": {"start": inv["date"]}}
if file_url:
props["Receipt"] = {"files": [{"name": "receipt", "type": "external", "external": {"url": file_url}}]}
r = requests.post("https://api.notion.com/v1/pages",
headers=NOTION_HEADERS,
json={"parent": {"database_id": NOTION_DB_ID}, "properties": props})
r.raise_for_status()
return r.json()
def process(file_path, file_url=None):
inv = parse_document(file_path)
page = log_to_notion(inv, file_url)
print(f"Logged: {inv.get('merchant')} — {inv.get('total')} | {page['url']}")
process("receipt.pdf")What gets extracted
| Field | Description |
|---|---|
merchant | The vendor or store name |
total | The final charged amount including tax |
subtotal | The pre-tax amount |
tax | The tax amount charged |
date | Invoice or transaction date (ISO 8601) |
due_date | Payment due date, or null if not present |
invoice_id | Invoice number or receipt ID from the document |
currency | ISO 4217 currency code (USD, EUR, GBP, etc.) |
payment_method | Card type, cash, or other payment method |
line_items | Array of items with description, quantity, price, line_total, vat_rate |
Common errors and fixes
MISSING_API_KEY | Authorization header missing | Add header: Authorization: Bearer YOUR_KEY |
INVALID_API_KEY | Key not recognised | Check key in dashboard — regenerate if needed |
LIMIT_EXCEEDED | Monthly document limit reached | Upgrade at docuparseapi.com/pricing |
UNSUPPORTED_FILE_TYPE | File format not supported | Use PDF, JPG, PNG or CSV |
FILE_TOO_LARGE_AUTHENTICATED | The file is too large | Compress the image or split the PDF |
TOO_MANY_PAGES | More than 20 pages | Split the PDF into parts of up to 20 pages |
EXTRACTION_FAILED | Document could not be parsed | Try a cleaner scan or different file |
Ready to start?
20 documents a month free, with full API access. No credit card. Webhooks on Starter and Pro.