{"uid":"cap_jX_4hvLo9DXPyuqKgUAr2","slug":"ailabra-profit-calculator-091637d1","name":"Ailabra Profit Calculator","description":"Calculate deterministic profit and cash flow from autonomous-agent economic events.","url":"https://x402.ailabra.org/api/v1/x402/profit/calculate","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"events":{"type":"array","items":{"$id":"https://x402.ailabra.org/api/v1/schemas/economic-event","type":"object","title":"Ailabra Economic Event v1","$schema":"https://json-schema.org/draft/2020-12/schema","required":["schemaVersion","externalId","occurredAt","kind","direction","amount","currency","category","source"],"properties":{"kind":{"enum":["revenue","expense","refund","fee","transfer","capital","withdrawal","asset_purchase","asset_sale","adjustment"],"type":"string"},"amount":{"type":"string","pattern":"^(?:0|[1-9]\\d*)(?:\\.\\d+)?$"},"source":{"type":"object","required":["name","type","verification"],"properties":{"name":{"type":"string","maxLength":120,"minLength":1,"description":"Identifies the originating ledger or integration and participates in duplicate detection with externalId."},"type":{"type":"string"},"reference":{"type":"string"},"verification":{"enum":["self_reported","receipt_supplied","receipt_verified","onchain_verified","system_observed"],"type":"string"}},"additionalProperties":false},"agentId":{"type":"string"},"category":{"type":"string","maxLength":120,"minLength":1},"currency":{"type":"string","pattern":"^[A-Z][A-Z0-9]{1,11}$"},"metadata":{"type":"object"},"direction":{"enum":["inflow","outflow"],"type":"string"},"productId":{"type":"string"},"ventureId":{"type":"string"},"adjustment":{"type":"object","required":["reason","profitTreatment"],"properties":{"reason":{"type":"string"},"profitTreatment":{"enum":["revenue","cost","exclude"],"type":"string"}}},"customerId":{"type":"string"},"externalId":{"type":"string","maxLength":160,"minLength":1},"occurredAt":{"type":"string","format":"date-time"},"assetPolicy":{"enum":["expense","exclude"],"type":"string"},"experimentId":{"type":"string"},"schemaVersion":{"const":"1"},"x402PaymentId":{"type":"string"},"relatedEventId":{"type":"string"},"transactionHash":{"type":"string"}},"additionalProperties":false},"maxItems":1000,"minItems":1}}},"responseSchema":{"type":"json","example":{"totals":{"USDC":{"netOperatingProfit":"82.5"}},"schemaVersion":"2","serviceVersion":"1.0.9","calculationEngineVersion":"2.0.0"}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_LV6anuwibI4UpZBEOPpPV","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates deterministic profit and cash flow metrics from a batch of structured autonomous-agent economic events.","exampleAgentPrompt":"Calculate the profit and cash flow for my AI agent venture 'venture-42' from these events: a $500 USDC revenue inflow from customer 'cust-001' on 2024-06-01, a $50 USDC fee outflow on 2024-06-02, and a $20 USDC refund outflow on 2024-06-03 — all self-reported and categorized as 'saas-sales' or 'platform-fee'.","exampleUseCases":[{"title":"Monthly agent revenue reconciliation","prompt":"Here are all the revenue, fee, and refund events my trading agent logged in June — can you calculate the net profit and total cash flow for the month? I have about 200 events with amounts in USDC, including some x402 payment IDs."},{"title":"Multi-agent venture P&L report","prompt":"I'm running three AI agents under venture 'venture-X' and want to know the combined profit across all of them for Q1. I have a list of 150 economic events covering revenues, expenses, and transfers — can you compute the deterministic profit from those?"},{"title":"Expense vs revenue breakdown for a single agent","prompt":"My agent 'agent-007' had a bunch of inflows and outflows last week — revenues from API calls and some platform fees as outflows, all in USDC. Can you crunch the numbers and tell me what the net profit and cash flow looks like?"}],"resultDescription":"A deterministic profit and cash flow summary computed from the submitted economic events. The response aggregates inflows and outflows by kind (revenue, expense, fee, refund, etc.), applies asset and adjustment policies, and returns net profit, total inflows, total outflows, and per-category breakdowns.","failureModes":["Missing required event fields (schemaVersion, externalId, occurredAt, kind, direction, amount, currency, category, source) return validation errors","Invalid amount format (non-numeric or negative) triggers pattern validation failure","Currency code not matching ^[A-Z][A-Z0-9]{1,11}$ returns schema error","Submitting more than 1000 events in a single call returns a maxItems violation","Invalid kind or direction enum values return enum constraint errors","Payment failure (insufficient USDC balance) results in 402 response before processing"],"whenToPreferThis":"Use this endpoint when you need a deterministic, auditable profit and cash flow computation from structured agent economic events, especially in x402-payment-enabled autonomous agent pipelines. Prefer it over generic accounting APIs when your events include x402 payment IDs, on-chain transaction hashes, agent/venture/experiment IDs, or when you need schema-validated verification levels (onchain_verified, receipt_verified, etc.).","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T00:31:37.815Z","isFirstParty":false}