export_usage
Export ledger, hook, instance, lineage, outcome, profile, and retained-job data. Free; run BEFORE delete_account. Same JSON body as GET /v1/usage/export; CSV has events. UNBOUNDED: prefer paged reads on big accounts. Email is masked without admin scope. Returns account/email/count, ledger, hooks, instances, lineage, outcomes, jobs, profiles, source_evidence, and corrupt markers. Jobs and profiles retain their bounded receipts. Source evidence includes metrics, retractions, and separate research/extraction results. Filters narrow ledger events only; all retained data categories stay complete. Errors: unauthorized, forbidden (key lacks read scope), rate_limited.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | Filter to rows carrying EXACTLY this fleet tag (exact match, not a substring). Omit for every tag. | |
| api_key | No | API key for this call. Omit to fall back to the Authorization: Bearer / X-API-Key request header (streamable-HTTP only), then the VHGENGINE_API_KEY env var (the stdio default). No key resolvable -> unauthorized. | |
| key_prefix | No | Narrow the LEDGER to charges made with ONE api key, identified by the 12-char prefix from list_keys. `hooks`, `hook_instances`, `hook_lineage`, `outcomes`, `jobs`, `creator_profiles`, and `source_evidence` are always the full set and are NOT narrowed by this. Omit for every key. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jobs | No | Every currently retained async job, including exact commission snapshots, including schema-v2 capture-only intent when supplied, bounded request metadata, results, errors, and corruption markers. Rolling v1 execution views and worker charge identities are not presented as the accepted snapshot. | |
| count | No | Number of usage-ledger rows in events after event filters. | |
| No | Contact email in full for an admin-scoped key and masked for a read-only key. | ||
| hooks | No | Every currently retained hook, not narrowed by event filters. | |
| events | No | Usage-ledger rows, oldest first, narrowed by event filters. | |
| outcomes | No | Every retained outcome, not narrowed by event filters. | |
| account_id | No | The exporting account id. | |
| hook_lineage | No | Non-prose per-hook minimum occurrence counts retained until account deletion so expired or rolling-version rows cannot become falsely exact. | |
| corrupt_fields | No | Bounded markers for retained event, hook, or outcome JSON fields that could not be decoded safely. Raw malformed values and row identifiers are not echoed. | |
| hook_instances | No | Every immutable served-hook occurrence currently retained, including non-prose profile/version lineage when one was used. Unreferenced instances follow the hook TTL; every retained instance for a hook with any outcome remains so historical ambiguity cannot become false exactness. | |
| source_evidence | No | Immutable source observations, bounded exact extracts, and candidate-to-served lineage. Corrupt parent chains are suppressed without echoing raw values. | |
| creator_profiles | No | Every retained creator-profile version and consent event, plus bounded retraction markers for profiles whose direct declarations were erased. |