# Billing

Source: https://docs.askaniela.com/guide/billing/

Everything is billed in **US dollars** - also during the beta. There are no credits. Each call has a **fixed price**
from the public, versioned [price list](https://docs.askaniela.com/guide/pricing.md) (`docs/pricing/pricing.yaml`, version `2026-11-v4.3`, Just Ask / pay-as-you-go
column). Only successful work is charged: failed pages, failed steps and cache hits cost **$0** and reserved amounts
are returned automatically.

## Price of a page check

| What | USD per page |
|---|---|
| Potential spam (`modes: ["spam"]`) | $0.0300 |
| Quality rater (`modes: ["quality"]`) | $0.0300 |
| Helpful content (`modes: ["helpful"]`) | $0.0150 |
| All three together (two or three kinds never cost more) | $0.0650 |
| Custom rule selection up to 40 rules (for example `preset:audit-quick`) | $0.0200 |
| Text check before publishing (`preset:guest-post`, guest post or sponsored article), per text, quotes included | $0.0300 |
| Custom rule selection over 40 rules (not a set of whole kinds) | $0.0650 |
| Page fetch (not charged for pages sent with your own HTML or text) | +$0.0015 |
| JavaScript rendering (only when the page was actually rendered, see [Fetching](https://docs.askaniela.com/guide/fetching.md)) | +$0.0060 |
| Protected page fetch (only on request, instead of rendering; price shown before start) | +$0.0125 |
| Evidence (`explain`) | included |

The minimum charge for a page check is $0.001. Example: a site audit of 500 pages, Potential spam, with fetch =
500 × ($0.0300 + $0.0015) = **$15.75**.

## How to fix (paid add-on)

The fix plan ("How to fix") is a paid add-on for a finished report, text check or site audit: **$0.10 per page that
needs changes** (pages with a confirmed finding in the plan). Pages without issues are free and there is no minimum.
Every report and audit shows the estimated work to fix for free.

1. `GET /v1/reports/{id}/fix-effort` (or `/v1/audits/{id}/fix-effort`) - free: pages by kind of change, hours as a
   range and `price_usd` of the plan.
2. `POST /v1/reports/{id}/fix-plan/order` (or `/v1/audits/{id}/fix-plan/order`) - buys the plan. The price is
   reserved now, charged when the plan is ready and refunded in full when it fails. A second order of the same plan
   costs nothing. Same as `POST .../addons` with `{"kind": "fix_plan"}`.
3. `GET /v1/reports/{id}/fix-plan?format=md` (or `json`) - answers `202` with `Retry-After` while the plan is being
   written. Before you buy it, the plan answers `402 fix_plan_not_purchased` with the price in `details`.

## Adding rules to a report (API)

The app has no report levels. Through the API a report can still grow in place (same `rep_…` ID) and you pay
**only the difference**. The API field `tier` names how much of the catalogue runs, per kind (spam, quality,
helpful content):

| `tier` value | What runs | USD per page (all kinds) |
|---|---|---|
| `lite` | quick rule set (`preset:audit-quick`) | $0.0200 |
| `basic` | full rule catalogue | $0.0650 (from `lite`: +$0.0450) |
| `premium` | full catalogue + rating scales (Page Quality, E-E-A-T) and quoted evidence with fixes for every finding | $0.0700 (from `basic`: +$0.0050) |

- With `basic` each kind costs its price above; with `lite` one third of the `lite` price; with `premium` the kind
  price plus one third of the evidence step. All three kinds never cost more than the price in the table. **Price of
  an upgrade** = price of the target `tier` − amount already paid for the page, so adding step by step never costs
  more than asking for the larger set at once.
- **Only missing rules and steps run**; existing scores stay unchanged.
- **Refunds**: a failed step (rules, evidence, search intent) is refunded and the report stays as it was.
- **Upgrade window = content retention** (3 years): within it we reuse the stored page
  content. After it, or for a page we never stored, the page is fetched again (+$0.0015, shown in the estimate). In
  private mode the content and URL are not stored, so a report cannot be upgraded: run a new check.

API: `GET /v1/tiers` (`audit_types[]` - spam, helpful, quality with a per-page `price_usd`; `page[]` - check scopes with `price_usd`, `id` is the `tier` value), `POST /v1/reports/{id}/upgrade/estimate` and
`POST /v1/reports/{id}/upgrade` with `{"tier": "basic"}` or `{"categories": ["spam"]}` (optional `query` + `market`
for the intent add-on); audits: `POST /v1/audits/{id}/upgrade/estimate` and `POST /v1/audits/{id}/upgrade`
with `{"tier": "premium", "flagged": true}` or `page_ids` (202, runs in the background, `GET /v1/audits/{id}/upgrade`
shows `reserved_usd` and `refunded_usd`). Estimates return `cost_usd` and `steps_usd`; results `charged_usd` and
`refunded_usd`. Errors: `409 upgrade_unavailable` (`details.reason`: `nothing_to_add`, `busy`, `private_mode`,
`no_pages`), `429 quota_exceeded`.

### Search intent

| Intent | What you get | USD per query + market |
|---|---|---|
| Ani's quick look (`tier: basic`) | intents, shares and best form from the search results | $0.0098 (recent results reused: $0.0030, analysis ready: $0) |
| Ani takes a closer look (`tier: premium`) | + the top pages: length, elements, expectations | $0.0750 |
| Ani compares your page (`tier: compare`) | + your page next to the top results | $0.0850 |

In a page check or site audit, each unique query + market is charged once. If the intent cannot be assessed, its
price is refunded.

## JavaScript rendering: reserve, then settle

With `on` and `auto` the estimate and the reservation include **+$0.0060 per fetched page**; after the fetch the
difference is settled in one transaction: pages that were not rendered get the surcharge back, failed pages get
everything back. `off` never adds the surcharge.

## Top up and balance history through the API

For agents and accounting systems that do not use the app. Keys need the `billing:read` or `billing:write` scope;
neither is in the default scope set, so create a key for this on purpose ([Authentication](https://docs.askaniela.com/guide/authentication.md)).

1. `GET /v1/billing/topups/options` (`billing:read`): the minimum (`min_usd`, $10), the room left under your
   top-up limit (`max_usd`, open payment links count until they expire), the service fee (`fee_percent`,
   `fee_fixed_usd`), how long a top-up stays valid (`valid_months`) and the consent text with `consent_ver`.
2. Show the consent text to the person who pays. It says the service starts before the 14-day withdrawal period
   ends; without it we cannot take the payment.
3. `POST /v1/billing/topups` (`billing:write`) with `{"amount_usd": 50, "consent_ver": "<from step 1>"}`. The answer
   (`201`) has `id`, `url`, `amount_usd`, `fee_usd` and `expires_in_s`. A person opens `url` and pays by card; card
   data never passes through the API. Only a signed-in user or a key of a user can do this (the consent is a
   statement of a person): project and organization keys get `403 forbidden`, and so do viewers.
   Send an `Idempotency-Key`: a retry with the same key and body returns the same link instead of a second one.
4. The balance grows when the payment is confirmed. Poll `GET /v1/billing/topups/{id}` (`billing:read`): `open`,
   `credited`, `failed`, `expired` or `rejected` (another top-up used the room first). An unpaid link expires after
   `expires_in_s` (1 hour).

```bash
curl -s "$ASKANIELA_URL/v1/billing/topups" \
  -H "Authorization: Bearer $ASKANIELA_API_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"amount_usd": 50, "consent_ver": "2026-10-22.1"}'
```

Errors: `422 consent_required` (`details.consent_ver` is the current version), `422 topup_below_min`,
`422 topup_invalid_amount` (whole cents only), `422 topup_over_limit` (`details.max_usd`), `422 promo_invalid`,
`503 billing_unavailable`. See [Errors](https://docs.askaniela.com/reference/errors.md).

**Balance history.** `GET /v1/billing/ledger?days=31` (`billing:read`, up to 92 days per page) lists money in
(`topup`, `package`, `credit`) and out (`usage` = what was taken from the balance that day after refunds, today
including work still running; `adjustment` = payment refunds and corrections), newest first, amounts in USD with a
sign. Next page: `?before=<next_before>`; `next_before` is `null` at the start of your history. Charges of single
jobs and reports are in their own responses (`charged_usd`, `X-Cost-USD`).

**Invoices.** `GET /v1/billing/invoices` (`billing:read`) lists invoices for top-ups and packages with `number`,
`status` (`pending` while being issued), a public `pdf_url` and `amount_usd`; a correction has its own number and PDF.

**Payments and test mode.** `GET /v1/billing/topups` (`billing:read`) lists your top-up payments, newest first, with
`state` and `mode`. While card payments are being prepared, the server can run in **test mode** (`mode: "sandbox"`):
payments go through the Stripe sandbox (test cards only), are recorded with `state: "sandbox"` and **do not top up
your balance**, and no invoice is issued. In this mode `GET /v1/billing/topups/options`, `POST /v1/billing/topups`
and the payment list also return `warning`: "Test mode: payments go through Stripe sandbox and do not top up your
balance." The app shows the same notice on the balance, top-up and invoices pages. With `mode: "live"` payments top
up the balance as described above.

## Balance, no monthly limit

Every charge comes from the organization's prepaid USD balance (top-ups valid 12 months, the part that expires
first is used first). There is no default monthly limit and no limit on the number of checks or audits: if the
balance covers the reserved amount, the work starts. An organization can ask us to set a monthly spending limit;
only then does `org.month.limit_usd` have a value. See [Pricing](https://docs.askaniela.com/guide/pricing.md) and the [closed beta FAQ](https://docs.askaniela.com/guide/beta.md).

## Checking usage

`GET /v1/usage` returns `unit: "usd"`, counters for `user`, `project` and `org` (`day`, `month`: `used_usd`,
`limit_usd`, `remaining_usd`; `null` limit = no limit), the `plan` (`limit_month_usd`) and the `balance`
(`balance_usd`, `overdraft_usd`, `expires_at`). When the balance cannot cover the start of a call (balance minus the
amount reserved may go down to -$5.00), the API responds `402 insufficient_balance` (`details`: `balance_usd`,
`requested_usd`, `overdraft_usd`, `topup_url`, `reason: "balance"`). Over a spending limit set for a user, project or
organization it responds `429 quota_exceeded` with amounts in USD (`details`: `limit_usd`, `used_usd`,
`requested_usd`, `remaining_usd`, for organizations also `balance_usd` and `reason: "limit"`; see
[Errors](https://docs.askaniela.com/reference/errors.md)). The panel shows the spend this month and the balance in the sidebar, on the
dashboard and in the site audit estimate. `plan.limit_month_usd` is `null` for every plan.
