Purchase a credit pack
POST
/api/v1/credits/purchase
Development implementation directly adds credits. Production checkout can use the same response shape after payment confirmation.
Authentication
Bearer Token API Key (cookie: better-auth.session_token)
Request Body
application/jsonpackId
string
REQUIRED
Credit pack ID
Values
"5" "20" "50" "100"Responses
200
Credits added
application/jsonsuccess
boolean
REQUIRED
Values
truecreditsAdded
number
REQUIRED
balance
number
REQUIRED
transactionId
string
REQUIRED
pack
object
REQUIRED
id
string
REQUIRED
Values
"5" "20" "50" "100"credits
number
REQUIRED
price
number
REQUIRED
perCredit
number
REQUIRED
savings
number
REQUIRED
label
string
REQUIRED
popular
boolean
400
Invalid pack
401
Unauthorized
curl -X POST 'https://littledemo.com/api/v1/credits/purchase' \ -H 'Authorization: Bearer YOUR_API_TOKEN' \ -H 'Content-Type: application/json' \ -d '{ "packId": "5"}'
const response = await fetch('https://littledemo.com/api/v1/credits/purchase', { method: 'POST', headers: { "Authorization": "Bearer YOUR_API_TOKEN", "Content-Type": "application/json" }, body: JSON.stringify({ "packId": "5" })});const data = await response.json();console.log(data);
import requestsheaders = { 'Authorization': 'Bearer YOUR_API_TOKEN'}response = requests.post('https://littledemo.com/api/v1/credits/purchase', headers=headers, json={ "packId": "5"})print(response.json())
200
Response
{ "success": true, "creditsAdded": 123, "balance": 123, "transactionId": "<string>", "pack": { "id": "5", "credits": 123, "price": 123, "perCredit": 123, "savings": 123, "label": "<string>", "popular": true }}
API Playground
Try this endpoint
POST
/api/v1/credits/purchase