AgentTax
Network
Blog
API Docs
Log In
AMPERSEND INTEGRATION

One line. Estimated US sales tax liability.

Wrap your Ampersend X402Treasurer with automatic US sales tax calculation across all 50 states. Runs async — never touches your payment flow. Every settled transaction gets a tax calculation and audit trail.

$ npm install @agenttax/ampersend
GitHub

How it works

Your Treasurer
x402 payment settles
withTaxCompliance
Async tax calculation
taxLog
Audit trail per txn
Zero latency
Tax runs async after settlement. Your payment flow is untouched.
Zero dependencies
Only needs the Ampersend SDK you already have.
50 states + DC
Every jurisdiction, every service type, every edge case.

Quick start

Wrap your existing Treasurer. Everything else stays the same.

import { createAmpersendTreasurer } from "ampersend-sdk";
import { withTaxCompliance } from "@agenttax/ampersend";

// Your existing Ampersend setup
const treasurer = createAmpersendTreasurer({
  wallet: myWallet,
  apiKey: process.env.AMPERSEND_SESSION_KEY,
});

// Wrap it — one line
const taxTreasurer = withTaxCompliance(treasurer, {
  apiKey: "atx_live_...",          // Free at agenttax.io — 100 calls/mo
  defaultBuyerState: "TX",         // Buyer's US state
  transactionType: "compute",      // compute, saas, api_access, consulting, etc.
});

// Use taxTreasurer exactly like your original treasurer.
// Tax is calculated async on every accepted payment — never blocks.

Get tax summary

Aggregate all tax calculations for reporting.

// After some transactions...
const summary = taxTreasurer.getTaxSummary();

console.log(summary);
// {
//   transactions: 47,
//   totalAmount: 125.50,
//   totalTax: 6.28,
//   effectiveRate: 0.05,
//   byState: { TX: 4.50, CA: 0, NY: 1.78 }
// }

Per-transaction callback

Get notified on every tax calculation with full jurisdiction details and statute citations.

const taxTreasurer = withTaxCompliance(treasurer, {
  apiKey: "atx_live_...",
  defaultBuyerState: "TX",
  transactionType: "compute",
  onTaxCalculated: (entry) => {
    console.log(`Payment ${entry.authorizationId}: ${entry.amount}`);
    console.log(`  Tax: ${entry.tax.total_tax} (${entry.tax.sales_tax?.jurisdiction})`);
    console.log(`  Rate: ${(entry.tax.sales_tax?.rate * 100).toFixed(2)}%`);
    console.log(`  Note: ${entry.tax.sales_tax?.note}`);
    // → Payment abc123: $5.00
    // →   Tax: $0.25 (Texas)
    // →   Rate: 6.25%
    // →   Note: TX Tax Code §151.351 — 20% statutory exemption
  },
});

Standalone calculator

Not using X402Treasurer? Use the standalone calculator for batch or retroactive tax on existing payments.

import { createTaxCalculator } from "@agenttax/ampersend";

const tax = createTaxCalculator({
  apiKey: "atx_live_...",
  defaultBuyerState: "NY",
  transactionType: "api_access",
});

// Calculate tax for any transaction
const result = await tax.calculate({ amount: 100.00 });
console.log(result.total_tax);  // 4.00 (NY 4% state rate)

// Batch — retroactive calculation on existing payments
for (const payment of ampersendPaymentHistory) {
  await tax.calculate({
    amount: payment.amountUsd,
    buyerState: payment.buyerState,
    counterpartyId: payment.sellerId,
  });
}

console.log(tax.getTaxSummary());

Direct REST (no SDK)

Prefer zero dependencies? Call the API directly.

// Direct REST — no SDK needed
const response = await fetch('https://agenttax.io/api/v1/calculate', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': process.env.AGENTTAX_API_KEY,
  },
  body: JSON.stringify({
    role: 'seller',
    amount: 1250.00,
    buyer_state: 'WA',
    transaction_type: 'saas',
    counterparty_id: 'amp_buyer_77a3f',
    is_b2b: false,
  }),
});

const tax = await response.json();
// { taxable: true, total_tax: 87.50, combined_rate: 0.07, ... }

Why Ampersend sellers need this

Economic nexus at scale
Once you cross $100K in sales or 200 transactions in a state, you have nexus — and must collect tax. AgentTax tracks this per-agent automatically.
Service type matters
The same payment can be taxable in one state and exempt in another, depending on whether it's SaaS, compute, consulting, or content. Wrong classification = penalty risk.
B2B exemptions
Selling to another business? Some states (Iowa, PA) exempt B2B digital services. AgentTax detects this from the buyer's AgentTax network profile.
Audit trail
Every calculation returns a transaction_id with the jurisdiction, statute citation, and confidence score. Per-transaction proof if you're ever audited.

Other integrations

LangChainCrewAIAPI DocsBlog

npm install @agenttax/ampersend

Free tier — 100 calls/month, no credit card. One line to add, runs async.

View on GitHub
AgentTax
Tax intelligence for AI-driven commerce. 50-state coverage, verified daily.

© 2026 Agentic Tax Solutions LLC. Tax rates verified daily against Tax Foundation, Sales Tax Institute, state DOR websites, Anrok, TaxJar, TaxCloud, and Kintsugi. AgentTax provides tax calculations for informational purposes only. Consult a qualified tax professional for compliance decisions.