Skip to main content
POST
/
check-and-deduct
Check & Deduct Credits
curl --request POST \
  --url https://api.nozle.app/api/v1/check-and-deduct \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_id": "<string>",
  "feature": "<string>",
  "credits": 123
}
'
{
  "allowed": true,
  "remaining": 123
}
Atomically check if a customer has sufficient credit balance and deduct in a single database transaction. Uses row-level locking to prevent race conditions under concurrent requests. Auth: sk_ only
customer_id
string
required
External customer ID
feature
string
required
Feature being consumed
credits
number
required
Number of credits to deduct (must be positive)
allowed
boolean
required
Whether sufficient balance existed to fulfill the deduction
remaining
number
required
Credit balance after deduction (or unchanged balance if denied)
When allowed is false, no credits are deducted. The remaining field returns the current balance as-is.