# POST /invoice/parse: $0.02 per call

Parse an invoice or receipt into clean JSON: supplier, VAT/tax ID, invoice number, dates, currency, line items, subtotal, tax, total, amount due and bank details. Send a PDF, Word or web page URL, or the text (for a photo, run image-ocr first). Our code then checks the maths: do the lines add up, does subtotal + tax = total. Missing fields are null, never guessed.

- **Price:** $0.02 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** yes, 20 free calls a day from Claude, Cursor or any MCP client ([set-up](/mcp/setup)).
- **Tier:** live
- **Answers cached for:** 1 hour(s)
- **Data sources:** our /markdown reader (PDF, Word, web pages); Workers AI: Mistral Small 3.1 (metered)
- **Lane:** AI tools ([OpenAPI](/openapi/ai.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/invoice-parse](/sample/invoice-parse). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/invoice-parse"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i -X POST https://aayatai.com/invoice/parse -H "content-type: application/json" -d '{"text":"Example Supplies Ltd, 1 High Street, London EC1A 1AA. VAT GB123456789.\nINVOICE INV-1042  Date: 2026-09-01  Due: 2026-10-01\nBill to: Example Buyer Ltd\n2 x Printer paper @ 4.50 = 9.00\n1 x Toner cartridge @ 51.00 = 51.00\nSubtotal 60.00\nVAT 20% 12.00\nTotal GBP 72.00"}'
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/invoice/parse", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"text":"Example Supplies Ltd, 1 High Street, London EC1A 1AA. VAT GB123456789.\nINVOICE INV-1042  Date: 2026-09-01  Due: 2026-10-01\nBill to: Example Buyer Ltd\n2 x Printer paper @ 4.50 = 9.00\n1 x Toner cartridge @ 51.00 = 51.00\nSubtotal 60.00\nVAT 20% 12.00\nTotal GBP 72.00"}),
});
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("invoice-parse", {"text":"Example Supplies Ltd, 1 High Street, London EC1A 1AA. VAT GB123456789.\nINVOICE INV-1042  Date: 2026-09-01  Due: 2026-10-01\nBill to: Example Buyer Ltd\n2 x Printer paper @ 4.50 = 9.00\n1 x Toner cartridge @ 51.00 = 51.00\nSubtotal 60.00\nVAT 20% 12.00\nTotal GBP 72.00"});
```

## Inputs

- `url` (string): Public URL of the invoice: PDF, Word, web page or text file (use this or text).
- `text` (string): The invoice or receipt text (use this or url).

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

Example only: the shape of an answer, with placeholder addresses and made-up figures. It is not data about any real token or wallet; call the service (or its free sample) for real results.

```json
{
  "documentType": "invoice",
  "supplier": {
    "name": "Example Supplies Ltd",
    "address": "1 High Street, London EC1A 1AA",
    "taxId": "GB123456789",
    "companyNumber": null,
    "email": null,
    "phone": null
  },
  "customer": {
    "name": "Example Buyer Ltd",
    "address": null,
    "taxId": null
  },
  "invoiceNumber": "INV-1042",
  "purchaseOrder": null,
  "issueDate": "2026-09-01",
  "dueDate": "2026-10-01",
  "currency": "GBP",
  "lineItems": [
    {
      "description": "Printer paper",
      "quantity": 2,
      "unitPrice": 4.5,
      "amount": 9,
      "taxRate": 20
    },
    {
      "description": "Toner cartridge",
      "quantity": 1,
      "unitPrice": 51,
      "amount": 51,
      "taxRate": 20
    }
  ],
  "subtotal": 60,
  "tax": 12,
  "discount": null,
  "shipping": null,
  "total": 72,
  "amountPaid": null,
  "amountDue": 72,
  "payment": {
    "iban": null,
    "bic": null,
    "sortCode": null,
    "accountNumber": null,
    "reference": null,
    "terms": null
  },
  "checks": {
    "linesMatchSubtotal": true,
    "totalAddsUp": true,
    "issues": []
  },
  "model": "@cf/mistralai/mistral-small-3.1-24b-instruct",
  "source": {
    "chars": 236,
    "truncated": false
  }
}
```

## Related

- [POST /document/ask](/services/document-ask) ($0.02): Ask a question about one document (PDF, Word, web page or pasted text) and get a short answer with the exact quotes that support it.
- [POST /entities](/services/entities) ($0.005): Named-entity extraction: the organisations, people, places, products, events, dates, amounts of money and laws in a text or document (URL to a page or PDF), wit
- [POST /keywords](/services/keywords) ($0.003): Key phrases and topics of a text, web page or PDF, for tagging, SEO and search indexes: up to 30 key phrases, most important first, each checked by code to real
- [POST /moderate](/services/moderate) ($0.005): Content moderation for AI agents and apps: is this text safe?
- [POST /pii/redact](/services/pii-redact) ($0.005): Remove personal data from text before an agent stores it or sends it to another model: emails, phone numbers, card numbers, IBANs, NI numbers, SSNs, IP addresse
- [POST /sentiment](/services/sentiment) ($0.005): Sentiment analysis for reviews, comments, support tickets and social replies: up to 50 texts per call, each labelled positive, neutral, negative or mixed with a
- [POST /text/cluster](/services/text-cluster) ($0.01): Group similar texts: send up to 200 pieces of feedback, support tickets, reviews or survey answers and get back the groups that say much the same thing, biggest
- [POST /text/rank](/services/text-rank) ($0.003): Semantic ranking: give a query and up to 100 candidate texts (search results, FAQ answers, products, document chunks) and get them sorted by how well they match

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).