PPactDocs
Enrichment

Cost ledger

Every enrichment provider call recorded with its three-number cost breakdown, provider, level, outcome, and provenance — queryable and exportable to CSV.

One row per provider call

Every enrichment provider call lands exactly one row in the enrichment_calls table — the cost ledger. Each row records the provider, target, enrichment type and level, outcome, and the full cost breakdown, so you can answer "what did we spend, on whom, with which vendor, and did it succeed?" without guesswork.

Row shape

FieldMeaning
provider, target_type, target_idWhich vendor enriched which record
enrichment_type, levelWhat was requested
cost_centsTotal billed to you (customer price)
provider_cost_centsRaw vendor cost
platform_fee_centsPact's markup
customer_price_centsProvider + fee
applied_pricing_policy_idWhich pricing policy set the fee
statussuccess, failure, etc.
facts_recorded, quarantined_countValues written vs. held for review
error_message, latency_ms, created_atDiagnostics

Two cost stores, by design

The multi-scope budget engine reads enrichment_calls. A separate legacy ledger, enrichment_costs (core/enrichment/cost.py), tracks token-level LLM spend and backs GET /v1/enrichment/cost/summary. Direct (run-less) enrichment spend that historically only hit the legacy enrichment_costs ledger is now also written to enrichment_calls by record_direct_call (core/enrichment/budgets.py), so that spend is no longer invisible to the multi-scope budget engine. The three-cost columns fall back gracefully on older deploys that predate them.

Querying the ledger

GET /v1/enrichment/ledger returns rows newest-first, filterable by provider, status, run_id, and a since/until window, up to limit 1000.

bash
curl "https://api.pact.place/v1/enrichment/ledger?provider=clearbit&status=success&limit=100" \
  -H "Authorization: Bearer $PACT_API_KEY"

CSV export

GET /v1/enrichment/ledger/export streams up to 50,000 rows as a CSV attachment (enrichment_ledger.csv) over an optional since/until window — the file finance and RevOps use for month-end reconciliation.

bash
curl "https://api.pact.place/v1/enrichment/ledger/export?since=2026-07-01" \
  -H "Authorization: Bearer $PACT_API_KEY" -o ledger.csv

Per-record provenance

Beyond the aggregate ledger, every field Pact wrote carries its own provenance. GET /v1/enrichment/contacts/{id}/provenance (and the company equivalent) returns the full fact history, the current winning value per field, and any pending quarantine — each fact tagged with source_provider, confidence, and fetched_at.