Routes Invoice From Data
by Stack Billing in Markets & finance
Generate a finished, professional invoice PDF from JSON — recipient and line items in, a ready-to-send application/pdf out. Layouts: standard, legal, creative. Totals and tax are computed server-side so the numbers always add up. First payment auto-creates a wallet profile (token + API key in response headers); returning wallets get sequential invoice numbering and can save a sender letterhead. USD only.
https://stackbill.app/routes/x402/invoice-from-data- Price
- $0.1
- per call in USDC
- Uptime
- 100%
- last 30 days
- Response time
- 261 ms
- 338 ms slowest 5%
- Last check
- Passed
- 3 h ago, next any minute now
Reliability
How to call it
POST https://stackbill.app/routes/x402/invoice-from-data
Each call costs $0.1 in USDC on Base, paid with the request over x402.
Run a free test callOne unpaid request, the way an agent sends it. You see the payment challenge it gets back. Nothing is charged.
Example request
From the listing.
POST https://stackbill.app/routes/x402/invoice-from-data
content-type: application/json
{
"currency": "USD",
"dueDate": "2026-08-01",
"invoiceNumber": "INV-2026-042",
"lineItems": [
{
"description": "Backend development",
"quantity": 10,
"unitPrice": 95
},
{
"description": "Code review",
"quantity": 2,
"unitPrice": 120
}
],
"notes": "Payment due within 30 days.",
"recipient": {
"address": "456 Oak Ave, Chicago, IL 60601",
"name": "Acme Corp"
},
"sender": {
"address": "123 Main St, Springfield, IL 62701",
"name": "Jane Doe Consulting"
},
"taxRate": 7.5
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
currency | string | No | Optional; must be "USD" if present (v1 renders USD only) |
dueDate | string | No | Optional due date, YYYY-MM-DD |
invoiceNumber | string | No | Invoice number printed on the PDF. Optional when the request carries an X-StackApps-Token header from a previous paid call — the next sequential number for that wallet is used and returned in the X-Invoice-Number response header |
lineItems | array of object | Yes | At least one line item; amount per line, subtotal, tax and total are computed server-side |
notes | string | No | Optional notes printed at the bottom of the invoice |
recipient | object | Yes | Who the invoice is billed to |
sender | object | No | Who the invoice is from. Optional for activated wallet profiles (send X-StackApps-Token) — the profile's saved name and address are used |
taxRate | number | No | Optional tax percent applied to the subtotal (e.g. 7.5) |
template | string | No | Optional PDF layout (default standard): legal = billing statement with a per-line Date column (populated when descriptions start with 'Work session on YYYY-MM-DD: '); creative = service/fee layout without hours-rate columns (service name taken from the text before ': ' in each description) One of: standard, legal, creative. |
Example response
The provider's example. We can't check it without paying.
{
"note": "application/pdf — the finished invoice document"
}Call it from code
The curl command shows the payment challenge. The JavaScript and Python versions pay and call, and never pay more than $0.1.
curl: see the payment challenge
# bash or zsh: see the payment challenge. Nothing is charged.
curl -sS -g -i -X POST 'https://stackbill.app/routes/x402/invoice-from-data' \
-H 'content-type: application/json' \
--data-raw '{"currency":"USD","dueDate":"2026-08-01","invoiceNumber":"INV-2026-042","lineItems":[{"description":"Backend development","quantity":10,"unitPrice":95},{"description":"Code review","quantity":2,"unitPrice":120}],"notes":"Payment due within 30 days.","recipient":{"address":"456 Oak Ave, Chicago, IL 60601","name":"Acme Corp"},"sender":{"address":"123 Main St, Springfield, IL 62701","name":"Jane Doe Consulting"},"taxRate":7.5}'
# x402 v2 sends the challenge base64-encoded in the PAYMENT-REQUIRED header (v1 sends it in the body).
# To read the header:
curl -sS -g -o /dev/null -D - -X POST 'https://stackbill.app/routes/x402/invoice-from-data' \
-H 'content-type: application/json' \
--data-raw '{"currency":"USD","dueDate":"2026-08-01","invoiceNumber":"INV-2026-042","lineItems":[{"description":"Backend development","quantity":10,"unitPrice":95},{"description":"Code review","quantity":2,"unitPrice":120}],"notes":"Payment due within 30 days.","recipient":{"address":"456 Oak Ave, Chicago, IL 60601","name":"Acme Corp"},"sender":{"address":"123 Main St, Springfield, IL 62701","name":"Jane Doe Consulting"},"taxRate":7.5}' \
| grep -i '^payment-required:' | cut -d' ' -f2 | tr -d '\r' | base64 --decodeJavaScript: pay and call
// npm i @x402/fetch @x402/evm viem
import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
// Pays at most $0.1 per call.
const client = new x402Client().setSpendControls({ maxAmountPerPayment: "$0.1" });
registerExactEvmScheme(client, { signer: privateKeyToAccount(process.env.EVM_PRIVATE_KEY) });
const pay = wrapFetchWithPayment(fetch, client);
// Not sure it's safe to pay? ToolVet checks it first for $0.005. Pay for that from a separate
// client: this one is capped at $0.1 per payment. GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fstackbill.app%2Froutes%2Fx402%2Finvoice-from-data&method=POST
const res = await pay("https://stackbill.app/routes/x402/invoice-from-data", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
"currency": "USD",
"dueDate": "2026-08-01",
"invoiceNumber": "INV-2026-042",
"lineItems": [
{
"description": "Backend development",
"quantity": 10,
"unitPrice": 95
},
{
"description": "Code review",
"quantity": 2,
"unitPrice": 120
}
],
"notes": "Payment due within 30 days.",
"recipient": {
"address": "456 Oak Ave, Chicago, IL 60601",
"name": "Acme Corp"
},
"sender": {
"address": "123 Main St, Springfield, IL 62701",
"name": "Jane Doe Consulting"
},
"taxRate": 7.5
}),
});
console.log(res.status, await res.text());Python: pay and call
# pip install "x402[requests,evm]"
import os
from eth_account import Account
from x402 import x402ClientSync
from x402.http.clients import x402_requests
from x402.mechanisms.evm import EthAccountSigner
from x402.mechanisms.evm.exact.register import register_exact_evm_client
# Pays at most $0.1 per call.
client = x402ClientSync().set_spend_controls({"max_amount_per_payment": "$0.1"})
register_exact_evm_client(client, EthAccountSigner(Account.from_key(os.environ["EVM_PRIVATE_KEY"])))
with x402_requests(client) as session:
res = session.post(
"https://stackbill.app/routes/x402/invoice-from-data",
json={
"currency": "USD",
"dueDate": "2026-08-01",
"invoiceNumber": "INV-2026-042",
"lineItems": [
{
"description": "Backend development",
"quantity": 10,
"unitPrice": 95,
},
{
"description": "Code review",
"quantity": 2,
"unitPrice": 120,
},
],
"notes": "Payment due within 30 days.",
"recipient": {
"address": "456 Oak Ave, Chicago, IL 60601",
"name": "Acme Corp",
},
"sender": {
"address": "123 Main St, Springfield, IL 62701",
"name": "Jane Doe Consulting",
},
"taxRate": 7.5,
},
)
print(res.status_code, res.text)Security scan
No findings
We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.
Recent checks
| When | Result | HTTP | Time | Price |
|---|---|---|---|---|
| 3 h ago | Passed | 402 | 266 ms | $0.1 |
| 7 h ago | Passed | 402 | 250 ms | $0.1 |
| 11 h ago | Passed | 402 | 338 ms | $0.1 |
| 16 h ago | Passed | 402 | 274 ms | $0.1 |
| 20 h ago | Passed | 402 | 314 ms | $0.1 |
Show 10 older checks
| 24 h ago | Passed | 402 | 233 ms | $0.1 |
| 28 h ago | Passed | 402 | 284 ms | $0.1 |
| 32 h ago | Passed | 402 | 234 ms | $0.1 |
| 36 h ago | Passed | 402 | 284 ms | $0.1 |
| 39 h ago | Passed | 402 | 224 ms | $0.1 |
| 43 h ago | Passed | 402 | 312 ms | $0.1 |
| 47 h ago | Passed | 402 | 250 ms | $0.1 |
| 2 days ago | Passed | 402 | 270 ms | $0.1 |
| 2 days ago | Passed | 402 | 246 ms | $0.1 |
| 2 days ago | Passed | 402 | 261 ms | $0.1 |