Skip to content

feat(billing): add email usage grants and attributed credit removal - #10782

Draft
mzxchandra wants to merge 1 commit into
codex/grants-s1-admin-credentialsfrom
codex/grants-s2-email-credits
Draft

mzxchandra wants to merge 1 commit into
codex/grants-s1-admin-credentialsfrom
codex/grants-s2-email-credits

Conversation

@mzxchandra

Copy link
Copy Markdown
Contributor

Summary

Admins can issue, edit, list and bulk-import email-matched usage-credit grants through the shared API. A verified recipient who owns an eligible paid organization can claim each award once. Intentional repeat awards are supported; permanent issuance keys prevent duplicate retries.

Adds email_credit_grant and immutable usage_credit_entry receipts. Existing organization settlement paths consume oldest claimed grants first, then other credit. Full or partial removal takes effect in the request transaction, returns a final result and preserves purchased/legacy balance. In-flight costs arriving later use remaining funding or ordinary overage; no producer-registration barrier or pending-removal finalizer is introduced. Credits remain usage-only.

Stacked on #10781. Sponsorship, fresh-org setup and paid continuation are later slices.

Storage and rollout

Additive migration 0492; no historical credit-provenance backfill. Live org/user references use SET NULL with retained claim snapshots; financial entries restrict grant deletion. Native checks enforce conservation and valid lifecycle state. Before the first claim, deploy source-preserving debit writers and verify relevant old writers have drained. Rollback after claims must retain attributed debits.

Testing

  • 16 real-PostgreSQL lifecycle, attribution and migration-invariant tests passed.
  • 21 cycle-close regressions passed.
  • Affected-workspace types, generated artifacts, formatting and migration checks passed.
  • Hosted checks dispatched against the parent commit for this stacked PR. Deployed staging remains NOT RUN; preserve a legacy-credit/personal-payer fixture before rollout and verify claim, consumption and removal after deployment.

Type of Change

  • New feature

@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 5, 2026 8:50am UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview — bc62b880 Deployed Dec 5, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant