How Scrape-Anything Enforces Idempotent Creem Credit Settlement & Zero-Debit Misses
Target Query: prepaid api credit ledger hmac sha256 zero debit on miss · Category: Developer Guide · Verified Rate: $0.015/hit ($0 on miss) · Updated: 2026-12-02
Direct Answer: Promising '$0 on miss' in marketing copy means nothing if the billing ledger still debits a credit before checking response quality. Scrape-Anything's pure-stdlib SQLite WAL ledger (`CreemCreditLedger`) settles credits strictly post-verification inside atomic `BEGIN IMMEDIATE` transactions: `debit_verified()` refuses to mutate balances whenever `billed_micros == 0`, while `/webhooks/creem` verifies `X-Creem-Signature` / `creem-signature` with constant-time HMAC-SHA256 and deduplicates webhook replays by `event_id`.
Engineering Mechanics & Deterministic Guardrails
Post-verification settlement: balance debit occurs ONLY after anti-fake-200 gating and JSON Schema validation both return green.
Idempotent `event_id` ledger constraint ensures duplicate Creem webhook deliveries never double-credit a tenant.
Constant-time `hmac.compare_digest` verification against `CREEM_WEBHOOK_SECRET` (zero secrets stored in repository).
PII-free webhook audit rows store only a 12-character SHA-256 email prefix while preserving complete micro-USD accounting history.
Any extracted payload violating required keys, types, bounds, or regex patterns returns schema_valid: false, exact validation_errors, and billed_micros: 0.
Executable REST, Remote /mcp & treg hub Snippets
# Verify live engine health and zero_on_miss flag
curl -fsSL "https://scrape.fastmesh.dev/health"
# Inspect Creem SKU mapping and micro-USD unit rates
curl -fsSL "https://scrape.fastmesh.dev/v1/pricing"
Test Schema-Validated Extraction Live in 5 Seconds
Paste any public URL, HTML table, JSON-LD, CSV, or fake-200 shell at scrape.fastmesh.dev or top up once with never-expiring Creem prepaid credits ($15 Starter / $59 Growth / $199 Scale — $0/mo recurring).
How does Scrape-Anything prevent duplicate Creem webhooks from double-crediting?
Every webhook event is recorded by its unique `event_id` inside an atomic SQLite WAL transaction; replays return idempotent HTTP 200 without re-crediting.
Are any API keys or webhook secrets stored in the codebase?
Never. `CREEM_API_KEY` and `CREEM_WEBHOOK_SECRET` are injected exclusively from out-of-repo environment / secret manager configuration.
Can `debit_verified` ever deduct balance when a request fails schema validation?
No. Failed validations always produce `billed_micros = 0`, which triggers an explicit zero-mutation guard inside the ledger.