DEV Community

Cover image for πŸš€ I built an API where an AI agent can verify an invoice and pay it in USDC
Mr Hamlin
Mr Hamlin

Posted on

πŸš€ I built an API where an AI agent can verify an invoice and pay it in USDC

Most accounts payable workflows still look like this:

  • Someone emails a PDF invoice
  • Someone checks it against a purchase order
  • Someone approves it
  • Someone logs into a bank and sends the payment

⏳ It takes days.
πŸ’Έ It costs money.
🧠 It requires humans in the loop.


⚑ So I built something simpler

An API where an AI agent can verify an invoice and pay a supplier in one flow.

No API keys.
No accounts.
Just pay per request.


🧠 The idea

Instead of humans doing invoice checks, an agent can run:

Create PO β†’ Submit invoice β†’ Verify β†’ Pay
Enter fullscreen mode Exit fullscreen mode

That’s it.

πŸ‘‰ From invoice β†’ verified β†’ paid in seconds.


πŸ”₯ The flow (3 calls that matter)

Here’s the entire loop.


🧾 1. Submit an invoice

curl -X POST https://gateway.spraay.app/api/v1/sctp/invoice \
  -H "Content-Type: application/json" \
  -d '{
    "poId": "po_123",
    "supplierId": "sup_abc",
    "items": [
      {
        "description": "Resistor 10K x1000",
        "quantity": 1000,
        "unitPrice": 0.02
      }
    ],
    "total": 20.00
  }'
Enter fullscreen mode Exit fullscreen mode

βœ… 2. Verify it (this is the interesting part)

curl -X POST https://gateway.spraay.app/api/v1/sctp/invoice/verify \
  -H "Content-Type: application/json" \
  -d '{"invoiceId": "inv_456"}'
Enter fullscreen mode Exit fullscreen mode

⚑ Exact match (instant)

{
  "status": "matched",
  "confidence": 0.99,
  "verifiedBy": "deterministic",
  "latencyMs": 42,
  "recommendation": "approve_payment"
}
Enter fullscreen mode Exit fullscreen mode

🧠 Fuzzy match (AI reasoning)

{
  "status": "partial_match",
  "confidence": 0.87,
  "verifiedBy": "ai",
  "latencyMs": 1340,
  "discrepancies": [
    "Description variation: 'Resistor 10K' vs 'Resistors 10KΞ© (1000pc)'"
  ],
  "recommendation": "approve_payment"
}
Enter fullscreen mode Exit fullscreen mode

πŸ’Έ 3. Pay the supplier

curl -X POST https://gateway.spraay.app/api/v1/sctp/pay \
  -H "Content-Type: application/json" \
  -d '{
    "invoiceId": "inv_456",
    "supplierId": "sup_abc",
    "amount": 20.00,
    "token": "USDC",
    "chain": "base"
  }'
Enter fullscreen mode Exit fullscreen mode

Response

{
  "status": "processing",
  "estimatedSettlement": "~2s"
}
Enter fullscreen mode Exit fullscreen mode

βš™οΈ How it works

The /verify endpoint uses a two-step system:

⚑ Fast path (~50ms)

  • Deterministic checks
  • Totals, quantities, prices
  • Instant match β†’ high confidence

🧠 Slow path (~1–2s)

  • LLM reasoning for fuzzy cases
  • Handles naming differences, rounding, inconsistencies

πŸ’‘ Why this matters

This isn’t just another API.

It changes how financial workflows work:

  • ❌ No dashboards
  • ❌ No logins
  • ❌ No subscriptions

Instead:

Programmable financial infrastructure that agents can use directly

An AI agent can:

  • receive an invoice
  • verify it
  • decide based on confidence
  • execute payment

All without a human.


πŸ‘€ Who this is for

  • πŸ€– AI CFO / finance agents
  • πŸͺ™ Crypto startups paying vendors
  • πŸ›οΈ DAOs managing contributor payments
  • πŸ§‘β€πŸ’» Indie hackers automating ops

πŸ§ͺ What this is (and isn’t)

This is v0.1 of something I’m calling:

Supply Chain Task Protocol (SCTP)

Right now it focuses on:

  • invoices
  • verification
  • payments

Later, it may expand into:

  • escrow
  • shipment tracking
  • document verification

…but only after this core loop is proven.


πŸ”— Try it yourself

πŸ‘‰ https://gateway.spraay.app

πŸ‘‰ https://github.com/plagtech/sctp


If you're building AI agents and want to automate real-world workflows, I’d love feedback.

This is one of those things that either clicks immediately…

or sounds insane.

I’m betting on the former.

Top comments (0)