{"openapi":"3.1.0","info":{"title":"TaxRail API","version":"0.1.0","description":"Autonomous Tax-Optimization Rail for AI Agents (US + Brazil). Free tax-impact previews and x402-gated execution payloads & accounting dossiers.","contact":{"name":"TaxRail","email":"samuelaguiar1242@gmail.com","url":"https://taxrail.online"}},"servers":[{"url":"https://api.taxrail.online"}],"tags":[{"name":"defi","description":"DeFi pre-trade tax routing and Aave v3 calldata"},{"name":"crypto-tax","description":"US IRS 1099-DA / Form 8949 and Brazil Lei 14.754 calculation"},{"name":"x402","description":"Pay-per-call USDC endpoints on Base (eip155:8453)"},{"name":"tax-loss-harvesting","description":"Year-end TLH lot discovery and loss offsetting"},{"name":"wallet-scanner","description":"On-chain EVM cost-basis reconstruction via Alchemy"},{"name":"us-irs-1099-da","description":"Per-wallet HIFO / SpecID cost-basis tracking"},{"name":"brazil-lei-14754","description":"Lei 14.754/2023 15% flat tax, R$35k exemption & Lucro Real"},{"name":"aave-v3","description":"Borrow-vs-sell DeFi liquidity simulation and 0x calldata"},{"name":"base","description":"Base mainnet USDC payments and 0x v2 execution"}],"paths":{"/health":{"get":{"tags":["base"],"operationId":"getHealth","summary":"Service health check","security":[],"responses":{"200":{"description":"Healthy","content":{"application/json":{"schema":{"type":"object","properties":{"status":{"type":"string"},"service":{"type":"string"},"version":{"type":"string"}}}}}}}}},"/api/v1/check-tax-impact":{"post":{"tags":["crypto-tax","defi","us-irs-1099-da","brazil-lei-14754","tax-loss-harvesting"],"operationId":"checkTaxImpact","summary":"Compare baseline FIFO vs tax-optimized crypto disposal (FREE)","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckTaxImpactInput"}}}},"responses":{"200":{"description":"Redacted tax optimization preview with planId and dynamic x402 quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckTaxImpactRedactedResponse"}}}},"400":{"description":"Validation error"}}}},"/api/v1/borrow-vs-sell":{"post":{"tags":["defi","aave-v3","crypto-tax","base"],"operationId":"compareBorrowVsSell","summary":"Compare selling appreciated crypto vs borrowing on Aave v3 (FREE)","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BorrowVsSellInput"}}}},"responses":{"200":{"description":"Borrow-vs-sell preview with planId and dynamic x402 quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BorrowVsSellPreview"}}}},"400":{"description":"Validation error"}}}},"/api/v1/classify-expense":{"post":{"tags":["crypto-tax","brazil-lei-14754"],"operationId":"classifyDeductibleExpense","summary":"Classify business expense deductibility and tax shield (FREE)","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeductibleExpenseInput"}}}},"responses":{"200":{"description":"Deductible expense preview with planId and dynamic x402 quote","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeductibleExpensePreview"}}}},"400":{"description":"Validation error"}}}},"/api/v1/prepare-execution":{"post":{"tags":["defi","crypto-tax","aave-v3","base"],"operationId":"prepareExecution","summary":"Prepare $0-upfront 1-click swap or Aave v3 borrow batch paying 10% fee from operation (FREE)","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PrepareExecutionInput"}}}},"responses":{"200":{"description":"Ready-to-sign calldata with 10% savings fee embedded inside the operation"},"400":{"description":"Unsupported plan type or invalid input"},"404":{"description":"Plan not found or expired"}}}},"/api/v1/claim-dossier":{"post":{"tags":["defi","crypto-tax","aave-v3","base"],"operationId":"claimDossier","summary":"Verify on-chain operation fee receipt by txHash and unlock SpecID lots + Form 8949 / DeCripto CSV","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClaimDossierInput"}}}},"responses":{"200":{"description":"Verified settlement receipt and full unlocked optimization plan + CSV dossier"},"402":{"description":"On-chain fee receipt not yet verified or below required minimum"},"404":{"description":"Plan not found or expired"}}}},"/api/v1/unlock-plan":{"post":{"tags":["x402","defi","crypto-tax","aave-v3","base"],"operationId":"unlockTaxPlan","summary":"Unlock full execution plan, calldata, and accounting dossier (PAID via x402)","x-payment":"x402","x-x402":{"version":2,"scheme":"exact","network":"eip155:8453","asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","pricingModel":"dynamic-10pct-of-verified-tax-savings","headerNames":["PAYMENT-SIGNATURE","X-PAYMENT"]},"parameters":[{"name":"PAYMENT-SIGNATURE","in":"header","required":false,"description":"Base64-encoded x402 v2 PaymentPayload","schema":{"type":"string"}},{"name":"X-PAYMENT","in":"header","required":false,"description":"Legacy/alias x402 payment header","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnlockPlanInput"}}}},"responses":{"200":{"description":"Full unlocked tax optimization plan with calldata and accounting dossier","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FullTaxOptimizationPlan"}}}},"402":{"description":"x402 v2 Payment Required with dynamic USDC quote","headers":{"PAYMENT-REQUIRED":{"description":"Base64-encoded x402 v2 PaymentRequired payload","schema":{"type":"string"}}}},"404":{"description":"Plan not found or expired"}}}},"/api/v1/x402/tlh-scan":{"get":{"tags":["x402","wallet-scanner","tax-loss-harvesting","crypto-tax","us-irs-1099-da","brazil-lei-14754","base"],"operationId":"scanWalletTlhX402","summary":"1-parameter wallet TLH & tax-risk scanner ($0.01 USDC via x402 on Base)","x-payment":"x402","x-x402":{"version":2,"scheme":"exact","network":"eip155:8453","asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","pricingModel":"flat-0.01-usdc","headerNames":["PAYMENT-SIGNATURE","X-PAYMENT"]},"parameters":[{"name":"walletAddress","in":"query","required":true,"description":"Public EVM wallet address (0x...) to scan for TLH and HIFO savings","schema":{"type":"string"}},{"name":"chain","in":"query","required":false,"schema":{"type":"string","enum":["base","ethereum","arbitrum"]}},{"name":"asset","in":"query","required":false,"description":"Default: ALL — scans up to 25 volatile tokens in wallet and returns savings + unlockable planId per token","schema":{"type":"string","default":"ALL"}},{"name":"jurisdiction","in":"query","required":false,"schema":{"type":"string","enum":["US","BR"]}},{"name":"referrerWallet","in":"query","required":false,"description":"Optional developer wallet to earn 20% affiliate revshare","schema":{"type":"string"}}],"responses":{"200":{"description":"Wallet TLH diagnostic, risk score, estimated tax savings & planId"},"402":{"description":"x402 v2 Payment Required ($0.01 USDC on Base)"}}}},"/api/v1/x402/optimize":{"post":{"tags":["x402","defi","crypto-tax","us-irs-1099-da","brazil-lei-14754","base"],"operationId":"quickOptimizeX402","summary":"1-step tax optimization returning lots, calldata & accounting dossier ($0.10 USDC via x402)","x-payment":"x402","x-x402":{"version":2,"scheme":"exact","network":"eip155:8453","asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","pricingModel":"flat-0.10-usdc","headerNames":["PAYMENT-SIGNATURE","X-PAYMENT"]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckTaxImpactInput"}}}},"responses":{"200":{"description":"Full unlocked tax optimization plan","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FullTaxOptimizationPlan"}}}},"402":{"description":"x402 v2 Payment Required ($0.10 USDC on Base)"}}}},"/api/v1/x402/pre-trade-check":{"get":{"tags":["x402","defi","crypto-tax","base","aave-v3"],"operationId":"preTradeCheck","summary":"Pre-trade swap/sell tax guardrail check ($0.01 USDC via x402 on Base)","x-payment":"x402","parameters":[{"name":"walletAddress","in":"query","required":true,"schema":{"type":"string"}},{"name":"sellAsset","in":"query","required":true,"schema":{"type":"string"}},{"name":"sellAmount","in":"query","required":true,"schema":{"type":"string"}},{"name":"chain","in":"query","required":false,"schema":{"type":"string","enum":["base","ethereum","arbitrum"]}},{"name":"jurisdiction","in":"query","required":false,"schema":{"type":"string","enum":["US","BR"]}},{"name":"referrerWallet","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Pre-trade recommendation, HIFO savings, cliff alert, and unlockable planId"},"402":{"description":"x402 v2 Payment Required ($0.01 USDC on Base)"}}}},"/api/v1/x402/br-35k-status":{"get":{"tags":["x402","brazil-lei-14754","crypto-tax"],"operationId":"getBr35kStatus","summary":"Brazil R$35k monthly exemption & Lei 14.754 status check ($0.005 USDC via x402 on Base)","x-payment":"x402","parameters":[{"name":"monthlySalesBrl","in":"query","required":false,"schema":{"type":"string"}},{"name":"plannedSaleUsd","in":"query","required":false,"schema":{"type":"string"}},{"name":"custodyLocation","in":"query","required":false,"schema":{"type":"string","enum":["DOMESTIC","OFFSHORE"]}},{"name":"usdBrlRate","in":"query","required":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"Brazil R$35k exempt headroom & Lei 14.754 tax calculation"},"402":{"description":"x402 v2 Payment Required ($0.005 USDC on Base)"}}}},"/api/v1/feedback":{"post":{"tags":["crypto-tax","x402"],"operationId":"submitAgentFeedback","summary":"Submit product feedback or a post-settlement verified review (FREE)","x-payment":"none","security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackInput"}}}},"responses":{"201":{"description":"Feedback recorded with server-side payment verification"},"400":{"description":"Validation error"},"409":{"description":"Duplicate review for same settlementTx"}}}},"/api/v1/reputation":{"get":{"tags":["crypto-tax","x402"],"operationId":"getPublicReputation","summary":"Read aggregated agent ratings and verified paid BaseScan reviews (FREE)","x-payment":"none","security":[],"responses":{"200":{"description":"Public verified reputation summary and reviews"}}}}},"components":{"schemas":{"UnlockPlanInput":{"type":"object","required":["planId"],"properties":{"planId":{"type":"string"}}},"PrepareExecutionInput":{"type":"object","required":["planId"],"properties":{"planId":{"type":"string"},"takerAddress":{"type":"string"},"buyAsset":{"type":"string"},"borrowerAddress":{"type":"string"}}},"ClaimDossierInput":{"type":"object","required":["planId","txHash"],"properties":{"planId":{"type":"string"},"txHash":{"type":"string"},"chain":{"type":"string","enum":["base","ethereum","arbitrum"]},"feeTxHash":{"type":"string"}}},"CheckTaxImpactInput":{"type":"object","required":["jurisdiction","regime","targetAsset","currentPriceUsd","lots"],"properties":{"jurisdiction":{"type":"string","enum":["US","BR"]},"regime":{"type":"string","enum":["INDIVIDUAL","LLC_PASS_THROUGH","C_CORP","PF_LEI_14754","PF_DOMESTIC","PJ_LUCRO_REAL","PJ_SIMPLES_EXPORT"]},"chain":{"type":"string","enum":["base","ethereum","arbitrum","solana"]},"walletAddress":{"type":"string"},"targetAsset":{"type":"string"},"sellQuantity":{"type":"number"},"targetProceedsUsd":{"type":"number"},"currentPriceUsd":{"type":"number"},"targetQuoteAsset":{"type":"string"},"lots":{"type":"array","items":{"type":"object"}},"context":{"type":"object"},"referrerWallet":{"type":"string"},"pricingTier":{"type":"string","enum":["STANDARD","VOLUME","ENTERPRISE"]},"asOfDate":{"type":"string"}}},"BorrowVsSellInput":{"type":"object","required":["jurisdiction","regime","collateralAsset","collateralAmount","collateralPriceUsd","collateralCostBasisUsd","holdingDays","liquidityNeededUsd"],"properties":{"jurisdiction":{"type":"string","enum":["US","BR"]},"regime":{"type":"string"},"chain":{"type":"string","enum":["base","ethereum","arbitrum"]},"borrowerAddress":{"type":"string"},"collateralAsset":{"type":"string"},"collateralAmount":{"type":"number"},"collateralPriceUsd":{"type":"number"},"collateralCostBasisUsd":{"type":"number"},"holdingDays":{"type":"number"},"liquidityNeededUsd":{"type":"number"},"borrowApr":{"type":"number"},"horizonDays":{"type":"number"},"marginalOrdinaryRate":{"type":"number"},"referrerWallet":{"type":"string"},"pricingTier":{"type":"string","enum":["STANDARD","VOLUME","ENTERPRISE"]}}},"DeductibleExpenseInput":{"type":"object","required":["jurisdiction","regime","vendorName","description","amountUsd"],"properties":{"jurisdiction":{"type":"string","enum":["US","BR"]},"regime":{"type":"string"},"vendorName":{"type":"string"},"description":{"type":"string"},"amountUsd":{"type":"number"},"currency":{"type":"string","enum":["USD","BRL"]},"paidWithInternationalCard":{"type":"boolean"},"hasFiscalDocument":{"type":"boolean"},"fiscalDocumentId":{"type":"string"},"usdBrlRate":{"type":"number"},"referrerWallet":{"type":"string"},"pricingTier":{"type":"string","enum":["STANDARD","VOLUME","ENTERPRISE"]}}},"CheckTaxImpactRedactedResponse":{"type":"object"},"BorrowVsSellPreview":{"type":"object"},"DeductibleExpensePreview":{"type":"object"},"FullTaxOptimizationPlan":{"type":"object"},"FeedbackInput":{"type":"object","required":["rating","comment"],"properties":{"rating":{"type":"integer","minimum":1,"maximum":5},"category":{"type":"string","enum":["PRAISE","BUG","FEATURE_REQUEST","ACCURACY","GENERAL"]},"comment":{"type":"string","maxLength":500},"planId":{"type":"string"},"settlementTx":{"type":"string"},"agentName":{"type":"string"},"allowPublicQuote":{"type":"boolean"}}}}}}