CreditsCheck affordability

Check affordability

Confirm whether your current balance covers an upcoming request.

curl -X POST https://api.chuger.com/v1/credits/can-afford \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"service_type": "content", "quantity": 50}'
{
  "can_afford": true,
  "preview": {
    "service_type": "content",
    "service_name": "Content Extraction",
    "credit_cost_per_request": 2,
    "quantity": 50,
    "total_cost": 100,
    "current_balance": 18675,
    "remaining_after": 18575,
    "can_afford": true
  }
}

A thin convenience wrapper around /preview-cost that promotes the affordability flag to the top level — handy for in-app gating where you don't need the full cost breakdown.

POST https://api.chuger.com/v1/credits/can-afford

No credits are deducted by this endpoint.

All /v1/credits/* endpoints are free to call and not subject to per-minute rate limits.

Authentication

Bearer token in the Authorization header. See Authentication.

Request body

Same shape as /preview-cost:

body
service_typestring
Required

One of scrape, content, serp, prompt.

body
quantityinteger

Integer between 1 and 100. Defaults to 1.

Example

Response fields

can_affordboolean
Required

true if the current balance covers the previewed cost.

previewobject
Required

Full preview payload — identical shape to /preview-cost so a single response can drive both gating and display.

Errors

StatusWhen
401Missing or invalid token
422service_type missing/invalid, or quantity out of range

See Errors for the full reference.