# Reports and add-ons

Source: https://docs.askaniela.com/guide/reports-addons/

What you can do with a page report (`rep_…`) or a site audit (`aud_…`) after it exists: add sections, check
Google indexing, keep drafts, archive, refresh quotes and fixes, read signal strength and page extras, report a
wrong result and share a project with people. Prices come from `GET /v1/tiers` and the
[pricing table](https://docs.askaniela.com/guide/pricing.md); every paid call reserves the amount first and returns what was not used.

| Task | Endpoint | Key scope | Price |
|---|---|---|---|
| What can be added | `GET /v1/reports/{id}/addons`, `GET /v1/audits/{id}/addons` | `reports:read` | free |
| Add a section | `POST /v1/reports/{id}/addons` (`judge`), `POST /v1/audits/{id}/addons` (`jobs`) | see left | per offer (`price_usd`) |
| Google indexing | `POST /v1/indexing`, `POST /v1/audits/{id}/indexing` | `judge` | $0.01 per address |
| Indexing result | `GET /v1/indexing/{run_id}`, `GET /v1/audits/{id}/indexing` | `reports:read` | free |
| Draft site audit | `POST /v1/audits/site` with `start: false`, `PUT /v1/audits/{id}/draft`, `POST /v1/audits/{id}/start` | `jobs` | free until started |
| Archive | `POST /v1/reports/{id}/archive`, `POST /v1/audits/{id}/archive` and `/unarchive` | `reports:write` | free |
| New quotes and fixes | `POST /v1/reports/{id}/evidence/refresh` (`judge`), `POST /v1/audits/{id}/evidence/refresh` (`jobs`) | see left | free, 1 per evidence version and 24 h |
| Signal strength per rule | `GET /v1/reports/{id}/signals` | `reports:read` | free |
| Page category and context vector | `GET /v1/reports/{id}/page-extras` | `reports:read` | ordered with the check |
| Report a wrong result | `POST /v1/reports/{id}/feedback` | `feedback:write` | free |
| Project members | `GET`/`POST /v1/projects/{id}/members`, `DELETE /v1/projects/{id}/members/{user_id}` | signed-in user | free |

## Add-ons

An add-on adds one section to an existing report without checking the rest again. The report keeps its id.

```bash
curl https://api.askaniela.com/v1/audits/aud_.../addons -H "Authorization: Bearer gsj_..."
```

```json
{"target": "audit", "target_id": "aud_...", "offers": [
  {"kind": "visibility", "category": null, "state": "available", "price_usd": 0.5, "units": 0, "reason": null, "ref": null},
  {"kind": "indexing", "category": null, "state": "available", "price_usd": 0.3, "units": 30, "reason": null, "ref": null},
  {"kind": "fix_plan", "category": null, "state": "done", "price_usd": 0.0, "units": 0, "reason": null, "ref": null},
  {"kind": "audit_type", "category": "helpful", "state": "available", "price_usd": 0.45, "units": 30, "reason": null, "ref": null}]}
```

| Field | Meaning |
|---|---|
| `kind` | `visibility` (site audit only), `indexing`, `topicality` (site audit only), `fix_plan` (How to fix), `audit_type` |
| `category` | the audit type to add (`spam`, `quality`, `helpful`), only for `kind: audit_type` |
| `state` | `available` = can be ordered; `in_progress` = ordered, being prepared; `done` = in the report; `unavailable` = see `reason` |
| `price_usd` | price of this order; `0` = included in the report price, no extra charge |
| `units` | pages or addresses the price covers (`0` = whole site) |
| `ref` | id of the running or last order (`idx_…`, `upg_…`) |

Order one offer with its `kind` (and `category` for `audit_type`):

```bash
curl -X POST https://api.askaniela.com/v1/audits/aud_.../addons \
  -H "Authorization: Bearer gsj_..." -H "Content-Type: application/json" \
  -d '{"kind": "audit_type", "category": "helpful"}'
```

The answer is `{offer, created}`: `202` while the section is prepared, `200` when it is already done. Ordering the
same add-on again while it runs returns it with `created: false` and charges nothing. Poll `GET .../addons` until
`state` is `done`. Prices: visibility $0.50 per domain, indexing $0.01 per address, How to fix $0.10 per page that needs
changes (pages without issues free; exact `price_usd` in the offer), Topicality included in the report price; a missing audit type costs only its missing rules. Failed parts are refunded.

Errors: `409 addon_unavailable` (`details.reason` says why), `409 audit_in_progress` for a site audit that is still
running or finishing its report parts (see [When the audit is ready](https://docs.askaniela.com/guide/site-audits.md#when-the-audit-is-ready)),
`429 quota_exceeded` when the balance is too low.

## Google indexing

Checks whether Google has addresses in its index. Charged per unique address that gets a result; addresses the
service could not check are refunded. Not available in private projects.

```bash
curl -X POST https://api.askaniela.com/v1/indexing \
  -H "Authorization: Bearer gsj_..." -H "Content-Type: application/json" \
  -d '{"urls": ["https://example.com/", "https://example.com/blog/"]}'
# 202 {"id": "idx_...", "status": "queued", "total": 2, "price_usd": 0.02, ...}
```

Up to 1000 addresses per call (duplicates count once). `POST /v1/audits/{id}/indexing` checks every page of a
finished audit at the same price; while the audit is running it answers `409 audit_in_progress`. Read the result
with `GET /v1/indexing/{run_id}` or `GET /v1/audits/{id}/indexing`: `status` (`queued`, `running`, `done`,
`partial`, `failed`), `indexed`, `not_indexed`, `errors`, `pages[]`, `price_usd` (reserved) and `charged_usd`
(after the check). While it runs the response has `Retry-After`.

## Draft site audits

`POST /v1/audits/site` with `"start": false` saves the configuration as a draft: `201`, `status: draft`, no
`job_id`. Nothing is discovered, charged or queued.

- `PUT /v1/audits/{id}/draft` replaces the whole configuration (same body as `POST /v1/audits/site`; `start` and
  `project_id` are ignored).
- `POST /v1/audits/{id}/start` starts it like a new audit: fresh page discovery, price, balance and limit checks,
  then the queue. The `audit_id` stays the same. Accepts `Idempotency-Key`.
- A started audit answers `409 not_a_draft` to both calls. Remove a draft with `POST /v1/audits/{id}/archive`.

## Archive

`POST /v1/reports/{id}/archive` hides a page report from default lists; `POST /v1/audits/{id}/archive` does the
same for an audit and all its page reports. Share links keep working. `.../unarchive` brings them back. The answer
is `{"id": "...", "archived": true, "reports": 31}` (`reports` = page reports changed). List archived items with
`GET /v1/reports?archived=true` or `GET /v1/audits?archived=true`. Deleting for good (`DELETE /v1/reports/{id}`,
`DELETE /v1/audits/{id}`) is only for an organization owner or admin signed in as a user.

## New quotes and fixes

`POST /v1/reports/{id}/evidence/refresh` writes the quotes and fixes again for findings that already have evidence,
with the current guidelines and in the language from `{"lang": "pl"}` (default: the request language). Scores do not
change and the page is not checked again; it works on the stored copy of the page. Free, with a limit: one refresh
per evidence version (a refresh after we update the guidelines is allowed again) and at least 24 hours between
refreshes of the same report or audit. Over the limit: `429 evidence_refresh_limited` with `Retry-After` and
`details.reason` (`same_prompt_version` or `cooldown`). A refresh that wrote nothing new does not count. The answer
has `hits`, `refreshed`, `failed` and `lang`.

For a whole audit, `POST /v1/audits/{id}/evidence/refresh` runs in the background (`202`, `upg_…`); follow it with
`GET /v1/audits/{id}/evidence/refresh` (`status`, `done`, `failed`). While the audit is running: `409 audit_in_progress`.
The same limit applies to the whole audit.

## Signal strength per rule

`GET /v1/reports/{id}/signals` returns one row per rule of the report, also without a finding:
`{rule_id, kind, signal, signal_level, hit, near}`. `signal` is 0-100 signal strength, not a percentage. `hit` =
confirmed finding; `near` = no finding, but the signal is in the range where the method is less certain. Findings
that were not confirmed are left out, as in `GET /v1/reports/{id}`.

## Page category and context vector

When a single page check is ordered in the app with page categories or the page context vector, read them with
`GET /v1/reports/{id}/page-extras`: `categories` (IAB 3.1 and Google, strength 0-100) and `context` (core content
vector and heading coherence). Each part has `status` `pending`, `running`, `done` or `error`; poll until `done`.
`null` = not ordered; a report without any of them answers `404 page_extras_not_found`. For labels and page context
through the API see [Page labels](https://docs.askaniela.com/guide/labels.md) and [Page context](https://docs.askaniela.com/guide/page-context.md).

## Report a wrong result

```bash
curl -X POST https://api.askaniela.com/v1/reports/rep_.../feedback \
  -H "Authorization: Bearer gsj_..." -H "Content-Type: application/json" \
  -d '{"rule_id": "SP-KWS-REPEAT", "label": "false_positive", "comment": "The list is a product spec, not keyword stuffing."}'
```

`label`: `false_positive`, `false_negative`, `unclear` or `problem`. Without `rule_id` the feedback is about the
whole report. Rule version, signal and project are taken from the stored report; a rule that is not in the report
answers `422`. `201` returns the stored feedback. An organization owner or admin can list it with `GET /v1/feedback`
(`?rule_id=`, `?label=`, `?report_id=`, `?limit=`).

## Project members

Project members see the project's reports and audits. These calls need a signed-in user (session or token); API
keys get `403`.

- `GET /v1/projects/{id}/members` - `[{user_id, email, role}]`, `role` is `owner` or `member`.
- `POST /v1/projects/{id}/members` with `{"email": "...", "role": "member"}` adds a person who is already a member
  of the organization; anyone else answers `404`. The `owner` role cannot be granted here (`400`).
- `DELETE /v1/projects/{id}/members/{user_id}` removes a member; the project owner cannot be removed (`400`).

Adding and removing needs the project owner or an organization owner or admin. Organization members are managed with
`/v1/orgs/{org_id}/members`.
