You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds /api/payment/history (free with bearer token) returning the
purchase audit trail for the requesting token: tx hash, amount, credits
added, block number, confirmation timestamp. Pairs with the existing
/api/payment/usage (spend side) so a bearer can reconcile its full
token lifecycle.
- worker/src/payments.ts: new pay:purchases:{token} ring buffer
(cap 100), appendTokenPurchase() helper called on both confirm
paths (explicit confirm + x402 retry), getPaymentHistory() reader.
Backwards-compat: tokens minted before this ledger return current
balance with empty purchases array.
- worker/src/index.ts: route handler with the same Authorization:
Bearer pattern as /api/payment/usage.
- /api/meta and llms.txt updated.
- src/lib/api-reference-directory.ts: full per-endpoint page entry
at /api-reference/payment-history with FAQ, code samples, related
links to payment-usage / payment-balance / payment-confirm.
Unblocks TerminalFeed cross-site bundle, which needed this endpoint
to surface deposit history alongside spend history.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -204,6 +204,7 @@ All mounted under `https://tensorfeed.ai/api/*` via the Worker.
204
204
-`/api/payment/confirm` (POST): Verify USDC tx on-chain, mint a bearer token
205
205
-`/api/payment/balance`: Read remaining credits for the current bearer token
206
206
-`/api/payment/usage`: Per-token call history (last 100 calls aggregated by endpoint). Auth required, no credit cost. Powers the human /account dashboard.
207
+
-`/api/payment/history`: Per-token credit-purchase audit log (which on-chain txs added how many credits and when). Auth required (`Authorization: Bearer <token>`), no credit cost. Pairs with `/api/payment/usage` (spend side) to give the bearer's full token lifecycle. Backed by `pay:purchases:{token}` ring buffer (cap 100); tokens minted before this ledger existed return an empty `purchases` array but still expose `current_balance` and `token_short`.
Copy file name to clipboardExpand all lines: public/llms.txt
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,7 @@ TensorFeed accepts USDC on Base as the sole payment method for premium endpoints
65
65
- [Confirm Payment](https://tensorfeed.ai/api/payment/confirm): POST { tx_hash, nonce? } to verify a USDC tx and mint a bearer token
66
66
- [Check Balance](https://tensorfeed.ai/api/payment/balance): GET with `Authorization: Bearer tf_live_...` to see remaining credits
67
67
- [Token Usage History](https://tensorfeed.ai/api/payment/usage): GET with bearer token to see per-endpoint call counts and the most recent calls (last 100 entries, no credit cost). Powers the human-facing /account dashboard.
68
+
- [Token Payment History](https://tensorfeed.ai/api/payment/history): GET with bearer token to see the credit-purchase audit log (which on-chain txs added how many credits and when, last 100 purchases, no credit cost). Pairs with /api/payment/usage to cover the full token lifecycle (purchases + spend).
68
69
- [Premium Routing](https://tensorfeed.ai/api/premium/routing): Tier 2, 1 credit per call. Top 5 ranked models with full score breakdown, pricing, status, component-level detail. Same query params as the preview plus optional ?top_n=1-10, ?w_quality=, ?w_availability=, ?w_cost=, ?w_latency= for custom weights.
69
70
- [Premium Pricing Series](https://tensorfeed.ai/api/premium/history/pricing/series): Tier 1, 1 credit per call. Daily input/output/blended price points for one model across a date range, with min/max/delta summary. Params: `?model=<id-or-name>&from=YYYY-MM-DD&to=YYYY-MM-DD`. Range capped at 90 days, default 30 days back.
70
71
- [Premium Benchmark Series](https://tensorfeed.ai/api/premium/history/benchmarks/series): Tier 1, 1 credit per call. Score evolution for a single benchmark (e.g. swe_bench, mmlu_pro, gpqa_diamond, math, human_eval) on one model. Params: `?model=&benchmark=&from=&to=`. Range capped at 90 days.
// ── Free with token: payment history ─────────────────────────────
593
+
{
594
+
slug: 'payment-history',
595
+
name: 'Token Payment History',
596
+
path: '/api/payment/history',
597
+
method: 'GET',
598
+
tier: 'free-with-token',
599
+
cost: 'Free with bearer token',
600
+
category: 'payment',
601
+
seoTitle: 'TensorFeed Payment History API: Per-Token Credit Purchase Audit Log',
602
+
seoDescription:
603
+
'TensorFeed /api/payment/history returns the bearer\'s credit-purchase audit log: which on-chain txs added how many credits and when. Free with bearer token.',
604
+
intro:
605
+
'The /api/payment/history endpoint returns your token\'s purchase audit trail: every USDC tx that funded credits on this bearer, with amount, credits added, block number, and confirmation timestamp. Pairs with /api/payment/usage (spend side) so an agent can reconcile its full token lifecycle.',
606
+
whenToUse:
607
+
'When an agent needs to audit how its credits were funded, reconcile on-chain spend against credit additions, or render a deposit history alongside spend history in an internal dashboard.',
608
+
params: [],
609
+
exampleResponse: `{
610
+
"ok": true,
611
+
"token_short": "tf_live_eb0d0155...",
612
+
"current_balance": 49,
613
+
"total_purchased_usd": 1.0,
614
+
"total_credits_added": 50,
615
+
"purchase_count": 1,
616
+
"purchases": [
617
+
{
618
+
"tx_hash": "0xabc...",
619
+
"amount_usd": 1.0,
620
+
"credits_added": 50,
621
+
"block_number": 12345678,
622
+
"confirmed_at": "2026-04-27T17:49:32.918Z"
623
+
}
624
+
]
625
+
}`,
626
+
pythonExample: `from tensorfeed import TensorFeed
627
+
628
+
tf = TensorFeed(token="tf_live_...")
629
+
history = tf.payment_history()
630
+
for p in history["purchases"]:
631
+
print(f"+{p['credits_added']} credits via {p['tx_hash'][:12]}...")`,
632
+
typescriptExample: `import { TensorFeed } from 'tensorfeed';
633
+
634
+
const tf = new TensorFeed({ token: 'tf_live_...' });
a: 'The ring buffer holds the last 100 purchases per token. At one purchase per token in typical agent usage, that is effectively unbounded; only an agent that repeatedly tops up the same bearer rather than minting fresh tokens would ever roll off the buffer.',
643
+
},
644
+
{
645
+
q: 'What about tokens minted before this ledger existed?',
646
+
a: 'Older tokens still authenticate cleanly and return current_balance, but the purchases array will be empty until a new top-up is recorded. The replay-protection ledger at pay:tx:{txHash} is the authoritative cross-reference if you need to audit a pre-ledger purchase.',
647
+
},
648
+
{
649
+
q: 'Does this cost a credit?',
650
+
a: 'No. /api/payment/history is free for the holder of the bearer token, same as /api/payment/balance and /api/payment/usage.',
0 commit comments