Get credit balance for current user's organization
Get credit balance for the current user’s organization.
Returns the current credit balance including grants, consumption, and remaining credits for the authenticated user’s organization.
M1 Note: Currently only shows granted credits. Usage tracking will be added in a future release, so credits_consumed is always 0.
Authorization:
- Organization admins and users can view their own organization’s credits
- RLS policies enforce organization-level data isolation at database level
Context:
- Credits are tracked at the organization level, not per user
- Grants are permanent allocations (cannot be revoked)
- New organizations receive 30,000 credits automatically
- Credits consumed will track usage across all users in the organization
Use Cases:
- Display credit balance in user dashboard
- Check remaining credits before starting workflows
- Monitor organization usage
Related Endpoints:
- POST /admin/organizations//grants - Admin can grant additional credits (backoffice only)
Security:
- @require_roles decorator enforces role-based access
- Uses current_user.organization_id (no path parameter to validate)
- RLS policies provide database-level enforcement
Authorizations
API key authentication. Include your API key in the X-API-Key header as: X-API-Key YOUR_API_KEY
Example:
JWT Bearer token authentication. Include your access token in the Authorization header as: Bearer YOUR_ACCESS_TOKEN
Example:
Response
Credit balance retrieved successfully
Credit balance for an organization (M1: grants only, no usage yet).