Guide

Errors

Error shape, codes, and how to handle 402.

view as markdown

Errors are JSON with a stable shape — the HTTP status tells you how to react, the code tells you what happened. Try each one:

HTTP 402 · insufficient_credits
{
  "error": {
    "message": "This call costs 10 credits and your balance is 4. Top up at https://eroq.ai/dashboard/billing.",
    "type": "insufficient_credits",
    "code": "insufficient_credits"
  }
}

React by: Top up — nothing was charged. Surface this to your own billing.

The one rule worth encoding

402 is a product event, not a bug. It is how your app learns the wallet is empty — catch it and route the user to your own top-up flow instead of logging it as an exception.