{"uid":"cap_w-JVeiEUExQvt8etZuPxZ","slug":"ad-spend-fee-audit-advertising-invoice-reconciliation-61b26495","name":"Ad Spend & Fee Audit – Advertising Invoice Reconciliation","description":"Public static preview plus paid token controls, risk consensus, AI security, webhook reliability, developer security, schedule risk, decision analysis, API release compatibility, accounts-payable reconciliation, e-commerce return eligibility, SaaS subscription-proration, sales-commission reconciliation, parcel-charge reconciliation, SLA service-credit reconciliation, advertising spend-and-fee audit, contract-renewal audit, workforce timecard reconciliation, hotel booking-commission reconciliation, and warehouse cycle-count adjustment reconciliation products for autonomous agents.","url":"https://rooke-token-risk-pilot.rookepoole.workers.dev/v1/x402/ad-spend-fee-audit","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"invoice":{"type":"object","required":["invoiceId","observedMediaSpendMinor","observedFeeLines","observedCreditsMinor","observedTotalMinor"],"properties":{"invoiceId":{"type":"string","maxLength":120,"minLength":1},"observedFeeLines":{"type":"array","items":{"type":"object","required":["feeId","label","amountMinor"],"properties":{"feeId":{"type":"string","maxLength":120,"minLength":1},"label":{"type":"string","maxLength":120,"minLength":1},"amountMinor":{"type":"integer","maximum":9007199254740991,"minimum":0}},"additionalProperties":false},"maxItems":200},"observedTotalMinor":{"type":"integer","maximum":9007199254740991,"minimum":0},"observedCreditsMinor":{"type":"integer","maximum":9007199254740991,"minimum":0},"observedMediaSpendMinor":{"type":"integer","maximum":9007199254740991,"minimum":0}},"additionalProperties":false},"agreement":{"type":"object","required":["agreementId","agreementVersion","currency","periodStartDate","periodEndDate","mediaBudgetMinor","expectedCreditsMinor","feeRules"],"properties":{"currency":{"type":"string","pattern":"^[A-Z]{3}$"},"feeRules":{"type":"array","items":{"type":"object","required":["feeId","label","calculationMode","rateBps","fixedAmountMinor","minimumAmountMinor","maximumAmountMinor"],"properties":{"feeId":{"type":"string","maxLength":120,"minLength":1},"label":{"type":"string","maxLength":120,"minLength":1},"rateBps":{"type":"integer","maximum":100000,"minimum":0},"calculationMode":{"enum":["PERCENT_OF_MEDIA_SPEND","FIXED"],"type":"string"},"fixedAmountMinor":{"type":"integer","maximum":9007199254740991,"minimum":0},"maximumAmountMinor":{"anyOf":[{"type":"integer","maximum":9007199254740991,"minimum":0},{"type":"null"}]},"minimumAmountMinor":{"anyOf":[{"type":"integer","maximum":9007199254740991,"minimum":0},{"type":"null"}]}},"additionalProperties":false},"maxItems":100},"agreementId":{"type":"string","maxLength":120,"minLength":1},"periodEndDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"periodStartDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"agreementVersion":{"type":"string","maxLength":120,"minLength":1},"mediaBudgetMinor":{"type":"integer","maximum":9007199254740991,"minimum":0},"expectedCreditsMinor":{"type":"integer","maximum":9007199254740991,"minimum":0}},"additionalProperties":false},"campaigns":{"type":"array","items":{"type":"object","required":["campaignId","allocatedBudgetMinor","dailySpend"],"properties":{"campaignId":{"type":"string","maxLength":120,"minLength":1},"dailySpend":{"type":"array","items":{"type":"object","required":["date","mediaSpendMinor"],"properties":{"date":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"},"mediaSpendMinor":{"type":"integer","maximum":9007199254740991,"minimum":0}},"additionalProperties":false},"maxItems":1000},"allocatedBudgetMinor":{"type":"integer","maximum":9007199254740991,"minimum":0}},"additionalProperties":false},"maxItems":500,"minItems":1},"auditPolicy":{"type":"object","required":["evaluatedThroughDate","amountToleranceMinor"],"properties":{"amountToleranceMinor":{"type":"integer","maximum":1000000,"minimum":0},"evaluatedThroughDate":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}$"}},"additionalProperties":false}}},"responseSchema":{"type":"json","example":{"pacing":{"totalDays":10,"elapsedDays":1,"actualSpendThroughMinor":37500,"targetSpendThroughMinor":10000,"projectedMediaSpendMinor":375000},"verdict":"MATCHED_WITHIN_TOLERANCE","agreement":{"currency":"USD","agreementId":"MEDIA-2026-08","agreementVersion":"signed-v3","mediaBudgetMinor":100000},"invoiceId":"INV-88","riskFlags":["PROJECTED_MEDIA_BUDGET_OVERRUN","SPEND_AHEAD_OF_LINEAR_PACE"],"reportHash":"sha256-hex","evidenceGaps":["CALLER_SUPPLIED_AGREEMENT_CAMPAIGN_AND_INVOICE_FACTS_NOT_AUTHENTICATED"],"claimBoundary":{"fundsMoved":false,"paymentAttempted":false,"campaignPausedOrModified":false,"invoiceApprovedOrDisputed":false,"adPlatformOrAgencyConnected":false},"schemaVersion":"AD_SPEND_FEE_AUDIT_V1","reconciliation":{"expectedTotalMinor":42250,"observedTotalMinor":42250,"totalVarianceMinor":0,"expectedFeeTotalMinor":5750,"expectedMediaSpendMinor":37500},"campaignResults":[],"expectedFeeLines":[],"requestCommitment":"sha256-hex","recommendedDisposition":"MATCHED_NO_ACTION","unknownObservedFeeLines":[]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"9","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":"$9/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"9","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"9","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_30GuQfUPIucCKWsv0VLjU","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"9","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Reconciles an advertising invoice against a signed media agreement, verifying fee calculations, spend totals, and credits to produce a pass/fail verdict with risk flags and pacing analysis.","exampleAgentPrompt":"Audit invoice INV-88 for agreement MEDIA-2026-08 (signed-v3, USD, period 2026-08-01 to 2026-08-31, media budget $1,000, expected credits $0): the invoice shows $375 media spend, a $57.50 management fee at 1,500 bps of media spend, and a total of $432.50 — check whether the fees are correct and flag any budget pacing issues.","exampleUseCases":[{"title":"Monthly agency fee overbilling check","prompt":"My agency just sent invoice INV-2024-09 for our September campaign under agreement AGR-BRAND-001 v2 (USD, Sep 1–30, $50,000 media budget). The invoice shows $48,200 media spend, a $7,230 management fee listed as 1,500 bps of media spend, and a $200 credit, totaling $55,230. Check if the fee is correctly calculated and tell me if we're being overbilled."},{"title":"Campaign budget overrun risk alert","prompt":"We're 3 days into a 10-day campaign (agreement CAMP-Q3-PILOT, USD, Jul 1–10, $100,000 budget). Invoice INV-PRELIM shows $42,000 spend so far. Our contract has a 12% management fee on media spend with a $5,000 minimum. Flag whether we're on pace to exceed the budget and what the projected overrun looks like."},{"title":"Unknown fee line investigation","prompt":"Our media partner sent invoice INV-AUDIT-77 under agreement MED-2025-Q4 (USD, Oct 1–Dec 31, $200,000 budget). Besides the expected 1,000 bps platform fee, there are two extra line items I don't recognize — 'tech surcharge' for $1,500 and 'data activation fee' for $800. Run an audit and tell me which fees are not covered by the signed agreement."}],"resultDescription":"Returns a JSON object with: a verdict string (e.g. MATCHED_WITHIN_TOLERANCE), a reconciliation object showing expected vs observed media spend, fee totals, and variance in minor currency units, a list of risk flags (e.g. PROJECTED_MEDIA_BUDGET_OVERRUN), pacing data (elapsed/total days, projected spend), a list of unknown observed fee lines, expected fee lines with computed amounts, a recommended disposition, evidence gaps, a claim boundary object indicating no funds were moved or invoices approved, and a SHA-256 report hash for audit trail purposes.","failureModes":["Missing required invoice or agreement fields returns a 400 validation error","Fee rule calculationMode enum mismatch causes rule to be skipped or flagged as unknown","Period dates in wrong format (not YYYY-MM-DD) cause parsing errors","observedTotalMinor inconsistent with observed line items may produce a non-zero variance unexpectedly","Payment failure (x402) if USDC balance is insufficient — call is not executed","Agreement version mismatch between caller-supplied data and actual signed contract yields CALLER_SUPPLIED_AGREEMENT_CAMPAIGN_AND_INVOICE_FACTS_NOT_AUTHENTICATED evidence gap"],"whenToPreferThis":"Choose this endpoint when you need a structured, auditable verdict on whether an advertising invoice's fees, credits, and totals match a signed media agreement — especially when the agreement has complex fee rules (percent-of-spend with floors/ceilings, fixed fees). Prefer it over manual spreadsheet checks or generic reconciliation APIs when you need risk flags, budget pacing projections, and a tamper-evident report hash in a single call. It is purpose-built for ad-spend and agency-fee reconciliation, not general AP matching.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-16T00:37:46.015Z","isFirstParty":false}