AI Receipt Processing for Expenses: A Practical Build
How to build receipt capture, field extraction, categorisation, rule-based policy checks, duplicate detection and human approval, using official API docs.
Most of the work in an expense claim is reading a receipt and checking it against a policy. Both steps can be automated, but they suit different tools. Reading the receipt is a document extraction problem that cloud services already handle with documented output fields. Checking the policy is a rules problem, and rules belong in code you can test and audit, not in a model prompt. This guide walks through a pipeline that keeps those concerns apart: capture, extraction, categorisation, policy rules, duplicate checks, and a person approving the exceptions.
Everything about the APIs below comes from the vendors’ own documentation. The earlier version of this post quoted a Forrester analyst and cited McKinsey percentages; none of that could be traced to a primary source, so it has been removed.
The pipeline at a glance
| Stage | What happens | Who or what decides |
|---|---|---|
| Capture | Photo, PDF or forwarded email arrives | The employee |
| Extraction | A receipt model returns typed fields with confidence scores | Document AI service |
| Categorisation | Merchant and line items map to your expense categories | Lookup table first, model suggestion second |
| Policy checks | Limits, receipt requirements, blocked categories | Your code |
| Duplicate check | Compare against earlier claims | Your code |
| Approval | Clean claims flow on; exceptions go to a reviewer | A person, for every exception |
Step 1: capture and extraction
Two well-documented options are Amazon Textract’s AnalyzeExpense operation and the Azure AI Document Intelligence receipt model (model ID prebuilt-receipt).
Amazon Textract AnalyzeExpense. AWS says it pulls data from invoices and receipts with no templates or setup. It also normalises different labels for the same thing: “bill number”, “invoice number” and “receipt number” all come back as the standard type INVOICE_RECEIPT_ID. The documented standard fields relevant to receipts include:
- Header:
VENDOR_NAME,VENDOR_ADDRESS,VENDOR_PHONE,INVOICE_RECEIPT_DATE,INVOICE_RECEIPT_ID - Amounts:
SUBTOTAL,TAX,SERVICE_CHARGE,GRATUITY,DISCOUNT,TOTAL,AMOUNT_PAID - Tax registration:
VENDOR_VAT_NUMBER,VENDOR_GST_NUMBER,VENDOR_ABN_NUMBER,VENDOR_PAN_NUMBER - Line items:
ITEM,QUANTITY,PRICE,UNIT_PRICE,PRODUCT_CODE
Anything that does not fit the taxonomy comes back typed as OTHER. The response separates SummaryFields (vendor, date, total) from LineItemGroups (what was bought), and each field carries a Confidence score, the page number and a bounding box. AWS notes that it can find a vendor name even when the receipt shows it only in a logo; in that case there is no LabelDetection, just the value. Rows with extra text such as SKUs come back whole as EXPENSE_ROW.
You can call it synchronously with AnalyzeExpense, or asynchronously with StartExpenseAnalysis followed by GetExpenseAnalysis. Input can be base64 image bytes or an S3 object.
Azure prebuilt-receipt. Microsoft’s receipt model handles printed and handwritten receipts. Its documented fields include MerchantName, MerchantPhoneNumber, MerchantAddress, TransactionDate, TransactionTime, Subtotal, Tax, Tip, Total and an Items array with name, quantity, price and total price. Microsoft says v4.0 adds ReceiptType, CountryRegion and tax detail fields, plus VAT table extraction for hotel receipts. Its input guidance asks for one clear photo or good scan per document, with images between 50 x 50 and 10,000 x 10,000 pixels.
Here is the core of AWS’s official Python example, trimmed to the extraction loop (the original also draws bounding boxes with Pillow):
import boto3
def print_labels_and_values(field):
if "LabelDetection" in field:
print("Label:", field["LabelDetection"]["Text"],
field["LabelDetection"]["Confidence"])
if "ValueDetection" in field:
print("Value:", field["ValueDetection"]["Text"],
field["ValueDetection"]["Confidence"])
session = boto3.Session(profile_name='profile-name')
client = session.client('textract', region_name='region')
response = client.analyze_expense(
Document={'S3Object': {'Bucket': 'bucket', 'Name': 'document'}})
for expense_doc in response["ExpenseDocuments"]:
for group in expense_doc["LineItemGroups"]:
for line_item in group["LineItems"]:
for field in line_item["LineItemExpenseFields"]:
print_labels_and_values(field)
print("Summary:")
for field in expense_doc["SummaryFields"]:
print_labels_and_values(field)
AWS’s setup steps grant the calling user AmazonTextractFullAccess and AmazonS3ReadOnlyAccess. In production you would scope that down.
Use the confidence scores. A sensible rule is that if TOTAL or the receipt date falls below a threshold you pick, the claim goes to the employee or a reviewer to confirm, rather than moving on with a guessed value.
Step 2: map to expense categories
Extraction gives you a merchant and line items, not your chart of accounts. Start with a deterministic lookup: known merchants, card merchant category data if you have it, and keywords in line items. Only for the leftovers is a language model useful, and then only inside a fixed schema.
Anthropic’s structured outputs feature constrains Claude’s reply to a JSON schema you pass in output_config.format, and the Python SDK’s client.messages.parse() accepts a Pydantic model. Adapted from the classification example in Anthropic’s docs:
from typing import Literal
from pydantic import BaseModel
from anthropic import Anthropic
class CategoryGuess(BaseModel):
category: Literal["meals", "lodging", "ground_transport", "airfare", "office_supplies", "other"]
reason: str
client = Anthropic()
response = client.messages.parse(
model="claude-opus-5-5",
max_tokens=1024,
output_format=CategoryGuess,
messages=[{"role": "user",
"content": "Pick an expense category for: Vendor 'Shell', items: 'Unleaded 32L'"}],
)
print(response.parsed_output)
Two caveats from the same docs. The output may not match the schema if the model refuses (stop_reason: "refusal") or runs out of tokens (stop_reason: "max_tokens"), so check the stop reason. And string enum values are not guaranteed to keep their capitalisation, so compare them case-insensitively. A schema-valid answer is still only a suggestion: store it as such, and let the employee or reviewer see and change it.
Step 3: policy checks as explicit rules
Policy is where you most want predictability. Write the rules as plain functions over extracted fields, version them alongside your policy document, and log which rule fired. The sketch below is illustrative, not taken from any vendor:
def policy_flags(claim, policy):
flags = []
if claim["total"] > policy["limits"].get(claim["category"], float("inf")):
flags.append("over_category_limit")
if claim["category"] in policy["blocked_categories"]:
flags.append("blocked_category")
if claim["total"] >= policy["receipt_required_over"] and not claim["has_receipt"]:
flags.append("missing_receipt")
if claim["min_confidence"] < policy["min_confidence"]:
flags.append("low_extraction_confidence")
return flags
Each flag maps to a fixed action: ask the employee for something, or send the claim to a reviewer. The model never gets the final word on whether something is allowed.
Step 4: duplicate detection
Duplicates come from the same paper receipt being scanned twice, from a receipt that was also imported from email, or from an out-of-pocket claim for something already on the corporate card. Practical checks:
- An exact hash of the uploaded file catches a re-upload of the same image.
- A key built from vendor, date and total catches a second photo of the same receipt.
INVOICE_RECEIPT_IDfrom Textract, where present, is a strong signal when combined with vendor.- Matching receipts to card transactions catches personal reimbursement claims for card spend.
Treat near matches as a flag for a person, not an automatic rejection; two coffees on the same day for the same price are not always a duplicate.
Step 5: human approval for exceptions
Everything flagged above should land in a review queue with the receipt image, the extracted fields, their confidence scores, the rules that fired, and any model suggestion clearly marked as one. The reviewer approves, edits or returns it, and that decision is logged. Whether clean claims also need a manager’s sign-off is a policy choice for your finance team. For more on where to put approval points, see our piece on designing human-AI collaboration.
What expense platforms say their AI does
If you would rather buy than build, here is how three vendors describe their own products. These are vendor claims from their product pages, not independent tests.
| Vendor | What the vendor says | Where a person comes in, per the vendor |
|---|---|---|
| SAP Concur | ExpenseIt does “AI-powered receipt capture”; expenses are checked against company rules on submission | Managers review and approve expenses |
| Ramp | Captures receipts and fills memos and categories when the card is used; a Policy Agent reviews expenses | The agent approves compliant items and routes exceptions to a reviewer |
| Expensify | SmartScan reads merchant, date, total and currency; expenses are categorised using your policies | Concierge asks follow-up questions when a receipt is unclear |
Expensify also says a scanned receipt is matched to the linked card transaction, which avoids duplicate entries, and Concur lists fewer duplicate claims among its benefits.
Limits worth stating
Extraction services return confidence scores because they are sometimes wrong; build for that. Model-suggested categories need a person able to correct them. Policy rules are only as good as the policy document they encode. And for tax handling on expenses, the rules differ by country and are a separate problem; our Avalara write-up covers one vendor’s approach. More tools for this kind of work are in the productivity and automation hub, and ERP-side agents are covered in Oracle AI Agent Studio.
Written by AI Agents Directory
Editorial team
Facts in this guide are checked against official documentation and repositories, which are linked in the article.