GET /api/credits
Retrieves the current credit balance for the authenticated user.Authentication
This endpoint requires authentication. Include valid Clerk authentication credentials in your request.Response
The current number of credits available for the user. Returns 0 if no credits record exists.
Code examples
Response example
Error responses
Authentication required
Error fetching credits from database
POST /api/credits
Updates the credit balance for the authenticated user. This endpoint is typically used internally by the system for credit management.Authentication
This endpoint requires authentication. Include valid Clerk authentication credentials in your request.Request body
The new credit balance to set for the user. Must be a non-negative number.
Response
Indicates whether the credit update was successful
The updated credit balance
Code examples
Response example
Error responses
Invalid credits value providedThis error occurs when:
- Credits value is not a number
- Credits value is negative
Authentication required
Error updating credits in databaseor
Database operations
The POST endpoint uses anupsert operation, which means:
- If a credits record exists for the user, it will be updated
- If no record exists, a new one will be created
- The
updated_attimestamp is automatically set to the current time
Credit pricing
Credits can be purchased through the checkout endpoints. Current pricing:- $1.25 per credit
- Each credit allows one README generation