Credits
View and adjust organization credit balances from the admin Organizations page.
The shipped kit manages credits from /dashboard/admin/organizations. It does
not include a standalone /dashboard/admin/credits route or an
admin.credit tRPC router.
Included Admin Controls
The Organizations table shows the current credit balance for each organization. Admins can:
- Search for an organization by name
- Filter organizations by credit balance
- Open Adjust credits from an organization's row menu
- Add or subtract credits with a required description
The balance filters are zero, low, medium and high. Their ranges are
defined by admin.organization.list in
trpc/routers/admin/admin-organization-router.ts.
List Organization Balances
Credit balances are returned by the existing organization list procedure:
const { data, isPending } = trpc.admin.organization.list.useQuery({
limit: 25,
offset: 0,
query: '',
sortBy: 'name',
sortOrder: 'asc',
filters: {
balanceRange: ['low']
}
});
const organizations = data?.organizations ?? [];
// Each organization includes `credits`, the current balance.The list procedure does not return an admin-wide credit transaction history.
Adjust Organization Credits
Use the procedure called by
components/admin/credits/adjust-credits-modal.tsx:
const adjustCredits = trpc.admin.organization.adjustCredits.useMutation();
adjustCredits.mutate({
organizationId,
amount: 500,
description: 'Support credit'
});A positive amount adds credits and a negative amount subtracts credits. The amount cannot be zero. The description must contain between 1 and 500 characters.
The mutation records the adjustment through lib/billing/credits.ts and
returns newBalance plus transactionId. It also stores the acting admin's ID
and email in the transaction metadata.
Not Included
The current kit does not include:
- A separate admin credits page
trpc.admin.credit.list,trpc.admin.credit.getortrpc.admin.credit.listTransactions- An admin-wide credit transaction browser
- User-level credit balances
The credit system is organization-scoped. The
trpc.organization.credit.getTransactions procedure is available to the active
organization through protectedOrganizationProcedure. It is not a global
admin query.
Related Documentation
- Organizations - Use the shipped admin interface
- Credits - Understand the organization credit system
- Billing Overview - Review the billing architecture