# Quickstart

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

## 1. Account, project and API key

Log in, create (or pick) a project and create a project API key - see [Authentication](https://docs.askaniela.com/guide/authentication.md).
The key (`gsj_...`) is shown once.

```bash
export ASKANIELA_URL=https://api.askaniela.com
export ASKANIELA_API_KEY=gsj_...             # from POST /v1/projects/{id}/keys
```

Every request sends the key as `Authorization: Bearer gsj_...`; without it the API returns `401 unauthorized`.
`GET /v1/me` shows what the key is: its organization and role, project, scopes and the balance
([Authentication](https://docs.askaniela.com/guide/authentication.md#check-what-a-key-can-do)).

## 2. Top up the balance

Paid calls take their price from the organization's prepaid USD balance (API keys and the app share it). Top up in
the app under **Balance** (`https://app.askaniela.com/balance`), from $10, by card; see [Billing](https://docs.askaniela.com/guide/billing.md).
`GET /v1/usage` shows `balance.balance_usd`. With too little balance a paid call answers `402 insufficient_balance`
(`details.topup_url` links to the top-up page) and does no work.
An agent can also ask for a payment link with `POST /v1/billing/topups` (key of a user with the `billing:write`
scope); a person opens the link and pays by card. See
[Top up through the API](https://docs.askaniela.com/guide/billing.md#top-up-and-balance-history-through-the-api).

## 3. Judge one page

Send exactly one of `url`, `html` or `text`. `rules` (rule ids) is optional. The call is synchronous and can take a
few minutes, so set the client timeout to at least 300 seconds.

```bash
curl -s "$ASKANIELA_URL/v1/judge" --max-time 300 \
  -H "Authorization: Bearer $ASKANIELA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/", "rules": ["SP-KWS-REPEAT", "QR-AIPHRASE"]}'
```

The response is a report with `violations` (spam policies), `quality_signals` (SQRG), `labels` (neutral info,
e.g. YMYL), `positives` and `not_assessed`. Each item carries `rule_id`, `signal` (0-100) and, for high scores,
`evidence`. See [Concepts](https://docs.askaniela.com/guide/concepts.md). Unknown rule ids return `400 unknown_rule` ([Errors](https://docs.askaniela.com/reference/errors.md));
list ids with `GET /v1/rules` (requires an API key or session) or the [Rules catalog](https://docs.askaniela.com/reference/rules.md).

## 4. Batch (up to 10 pages)

```bash
curl -s "$ASKANIELA_URL/v1/judge/batch" --max-time 300 \
  -H "Authorization: Bearer $ASKANIELA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items": [{"url": "https://example.com/"}, {"url": "https://example.org/"}]}'
```

`results[]` holds `{index, report, error}` per page; one failed page does not fail the batch. Larger sets go to
asynchronous [jobs](https://docs.askaniela.com/guide/webhooks.md) (scope `jobs`).

## 5. Read stored reports

`GET /v1/reports` lists recent reports (`?audit_id=` for one audit; when more match, the `X-Next-Cursor` header
gives the `?cursor=` of the next page), `GET /v1/reports/{id}` returns one, and
`GET /v1/reports/{id}/export.pdf` renders it as PDF.

## 6. Check your usage

Every checked page has a price in USD ([Billing](https://docs.askaniela.com/guide/billing.md)): spam $0.0300, quality $0.0300, helpful content
$0.0150 per page, all three $0.0650, page fetch +$0.0015. Every paid response has an `X-Cost-USD` header.
`GET /v1/usage` shows the balance and spending per user, project and organization. There is no monthly limit by
default; when the balance is too low the API returns `402 insufficient_balance`, and `429 quota_exceeded` only when a
spending limit was set for you, the project or the organization. What to do with each error:
[API quickstart](https://docs.askaniela.com/user/api-quickstart.md#9-usage-retries-and-errors).
