Track AI agent token costs and store receipts with the n8n API and Data Tables
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
What this workflow does
This workflow has 8 nodes and runs on a schedule (every day). It uses only n8n's built-in nodes.
How it runs
Trigger: On a schedule (every day).
- 1.1 Get AI Agent Workflows (n8n): uses n8n
- Loop Workflows (Loop Over Items (Split in Batches)): loops over the items in batches
- Loop Receipts (Loop Over Items (Split in Batches)): loops over the items in batches
- 1.2 Get Workflow Executions (n8n): work with execution
- Has Usage Data? (If): checks a condition and branches into true / false
- Extract Token Usage & Cost (Code): runs custom JavaScript code
- 1.3 Save Receipt to Data Table (Data table): uses Data table
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (6)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - n8n
n8n-nodes-base.n8n - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Data table
n8n-nodes-base.dataTable
From the author
Ever wondered how much your AI Agent is costing you per run? I had no idea. You build an agent, it works great, but behind the scenes tokens are burning. And you just see the API-key cost as an aggregated value on Stripe, right? One workflow costs you $0.002.…