Skip to main content

Revenue tracking

Sellable product

This capability is granted by an API key scoped to the `` product (product face). See the product reference below.

Shared cross-provider revenue LEDGER capability. Records revenue events (native first-party shape OR the ads-serving / affiliate sibling emit envelopes) into one org-scoped store, and serves a multi-dimensional aggregation (by_type / by_provider / by_channel / by_site + ad/subscription split + this_month + CPM/CPC imputed telemetry) with an optional user_id scope for the per-user breakdown, plus a recent-event feed. The event-type / provider / channel registries and the imputation rates are config-driven.

  • Group: Commerce & revenue
  • Contract: contracts/revenue-tracking/v1/openapi.yaml
  • Public base: https://api.vagarylabs.com (the consolidated API gateway — one host, per-brand sibling api.<zone>)
  • Auth: a product API key (vgk_…) issued from the console — Authorization: Bearer vgk_…
  • Product face (customer-keyed):
    • https://api.vagarylabs.com/product/v1/revenue/events

Endpoints

MethodPathSummary
POST/v1/revenue/eventsRecord a revenue event. Accepts the NATIVE revenue-event shape, or an ads-serving emit ({source:ads-serving, campaign_id, event_type:impression
GET/v1/revenue/eventsRecent-event feed (org-scoped), newest-first, optionally site-filtered — ports RevenueTrackingService.get_recent_events.
GET/v1/revenue/summaryAggregated revenue summary — the SUPERSET read surface. With no scope it is platform-wide (by_site + ad/subscription split + this_month + imputed ETL, = get_platform_revenue); site_id scopes to one site (by_type/by_provider, = get_revenue_summary); user_id scopes to one user (by_channel, = get_user_revenue_breakdown). by_channel is always present (= get_revenue_dashboard). Window defaults to 30 days.
POST/v1/revenue/erase-subjectGDPR Art-17 subject erasure by PSEUDONYMISATION (first-party admin only)
GET/healthliveness + store/tenancy posture
GET/metricsPrometheus exposition

Schemas

EraseSubjectResult

pseudonymized and deleted are separate fields on purpose: deleted is ALWAYS 0 here because these are statutory-retention financial records. matched is reported separately so a zero-match is visible to the compliance fan-out rather than reading as a successful erasure.

FieldTypeDescription
successboolean
capabilitystring
dispositionstring
selectorstring
matchedintegerledger rows belonging to the subject
pseudonymizedintegerrows whose subject link was severed
deletedintegeralways 0 — statutory retention forbids deletion
dry_runboolean
retained_reasonstringthe legal basis for retaining the unlinked record

EventCreate

A native revenue event, or an ads-serving / affiliate sibling emit envelope (discriminated by source). For a sibling envelope only source + event_type (+ the sibling id + optional cost/amount) are needed; the server maps event_type (impression->ad_impression, click->ad_click / affiliate_click, conversion->affiliate_purchase) and stashes campaign_id/affiliate_id/article_id in metadata.

FieldTypeDescription
organization_idstringend-customer tenant (I6); resolved/verified server-side, never trusted raw
sourcestringnative
event_typestringnative canonical type, OR the sibling raw type (impression/click/conversion)
amountnumberdollars (native/ads cost); 0 for an affiliate click
costnumberads-serving emit budget-accounting amount (mapped to amount)
providerstringadsense
channelstringthe 13-channel dim (from the news facade)
site_idstring
currencystring
user_idstringthe per-user dim
campaign_idstringads-serving emit — stashed in metadata
affiliate_idstringaffiliate emit — stashed in metadata
article_idstringsibling emit — stashed in metadata
event_idstringidempotency key within (organization_id, source); server-generated if omitted
metadataobject

RecordResult

FieldTypeDescription
successboolean
event_idstring

Summary

FieldTypeDescription
successboolean
organization_idstring
site_idstring
user_idstring
totalnumber
by_typeobject
by_providerobject
by_channelobject
by_siteobject
ad_revenuenumber
subscription_revenuenumber
this_monthnumber
event_countinteger
period_secondsinteger
channel_catalogarray

EventFeed

FieldTypeDescription
successboolean
countinteger
eventsarray

Error

FieldTypeDescription
errorstringstable machine code (e.g. validation_error, not_found, unauthorized)
reasonstringhuman-readable one-line explanation (no secrets/PII)
detailobject
request_idstring

Generated by scripts/gen-capability-docs.py from contracts/revenue-tracking/v1/openapi.yaml — the contract IS the source of truth; edit the contract, not this page.