# API reference
Base URL, authentication, the routes an agent uses, the error envelope and rate limits. The complete machine-readable description is /openapi.json.

## Basics

- Base URL: `https://sibearsecurity.com/v1`
- OpenAPI description of the agent routes: [/openapi.json](/openapi.json)
- Send JSON with `Content-Type: application/json`, and a descriptive `User-Agent` such as `sibear-client/1.0 (+https://sibearsecurity.com/docs)`. See [Limits and errors](/docs/limits-and-errors) for the Cloudflare 1010 note.
- Prepare and lookup need no account. Status, credential and result routes need `Authorization: Bearer <owner_token>`, the secret the scan gave when it was queued.
- A second security scheme, `agentToken`, is a bearer token `sb_agent_...` from [Agent access](/docs/agent-access). It works on the Review routes under `/v1/account/reviews` and on the free scan's status and result routes, for its own agent host only.
- The ownership routes are keyed by the request id.
- Never send tokens in a URL.

## Routes for agents

| Route | What it does |
| --- | --- |
| `GET /v1/intake/form` | The form's wording and versions. |
| `POST /v1/prefilled-scan-requests` | Prepare a scan for a person: returns `link`, `token`, `expires_at`. Nothing is emailed. |
| `POST /v1/prefilled-scan-requests/lookup` | With the token: `pending`, or `submitted` with `request_id` and `scan`. |
| `GET /v1/scan-requests/{request_id}` | State of the request, for example whether the email is confirmed. |
| `POST /v1/scan-requests/{request_id}/ownership` | The ownership proof to publish (`dns` and `file`; `attestation` for platform agents). |
| `POST /v1/scan-requests/{request_id}/ownership/check` | Check the proof: `verified`, `reason`, `method`, `scan`, `owner_token`, `refusal`, `token_expires_at`. |
| `GET /v1/scans/{request_id}/status` | Scan state; `?wait=0..25` holds the request until it settles. Bearer owner token. |
| `POST /v1/scans/{request_id}/credential` | Give a fresh test key when status says `awaiting_credential`. Bearer owner token. |
| `GET /v1/results/{result_id}` | The result as JSON. Bearer owner token. |
| `GET /v1/results/{result_id}/export.json` | The result as a JSON download. Bearer owner token. |
| `GET /v1/results/{result_id}/export.pdf` | The result as a PDF. Bearer owner token. |

### Agent access

| Route | What it does |
| --- | --- |
| `POST /v1/agent-access/requests` | Ask for access with `email` and `agent_url`: returns `code`, `poll_token`, `expires_at`, `poll_interval_s`. One approval email is sent. |
| `POST /v1/agent-access/requests/poll` | With the poll token: `pending`, `approved` (carries `token` once), `delivered` or `revoked`. |

### Review set-up link (no token)

| Route | What it does |
| --- | --- |
| `POST /v1/prefilled-review-orders` | Prepare a Review set-up for the person with two fields, `email` and `agent_url`; SiBear reads the rest from their code. Optional: the test key, `repositories`, `brand_rules` and `business_facts` (SiBear reads both from the code), a plain on or off for each optional check (`checks`) and for the destructive test (`destructive.on`), and `coupon_code`. Deprecated but still accepted: `api_preset`, `custom_json`, `api_sample`, `checklist`, `markers` and `packs`. Never a consent or a signature. Returns `link`, `token`, `expires_at`, `ownership`, `paid_by_code` and `test_key_provided`. Nothing is emailed. See [Prepare it for the person to approve](/docs/paid-review#prepare-it-for-the-person-to-approve). |
| `POST /v1/prefilled-review-orders/key` | With the token: the test key you did not send with the set-up (`test_key` with `credential_kind`), or `no_key`. Until the Review starts. Returns `test_key_provided`, `no_key` and `delete_by`. See [Send the key later](/docs/paid-review#send-the-key-later). |
| `POST /v1/prefilled-review-orders/lookup` | With the token: `pending` with the set-up (never the key: only `test_key_provided`), or `used`. |

The person then authorizes the test and connects GitHub (`POST /v1/account/reviews/{order_id}/authorize`) and starts the Review (`POST /v1/account/reviews/{order_id}/approve`) on one page. Both are theirs alone: a token gets `403 person_only`.

### Review routes (bearer `agentToken`)

| Route | What it does |
| --- | --- |
| `GET /v1/account/reviews` | List orders. Scope `review:read`. |
| `GET /v1/account/reviews/{order_id}` | The order view, with `needs_person` links and, once the person connected GitHub, `setup_reading` (what SiBear read in their code). Scope `review:read`. |
| `GET /v1/account/reviews/{order_id}/status` | Run status. Scope `review:read`. |
| `PUT /v1/account/reviews/{order_id}/agent` | The agent address, on the token's host, and optionally `mcp_url` (the MCP server on the same registrable domain the Review reads at run time, tool list only) with `mcp_manifest` (the approved `tools/list` result). SiBear reads how the agent is called from the person's code. Scope `review:prepare`. |
| `POST /v1/account/reviews/{order_id}/repository-link` | The link the person opens to connect GitHub. Scope `review:prepare`. |
| `PUT /v1/account/reviews/{order_id}/context` | Brand rules and business facts (optional), without the person's consents. Scope `review:prepare`. |
| `PUT /v1/account/reviews/{order_id}/test-markers` | The person's test markers and their "in place" ticks; our AI suggests the kinds from the code. Scope `review:prepare`. |
| `PUT /v1/account/reviews/{order_id}/checklist` | The person's own answers, or a `partial` change to some; our AI answers each question from the code. Scope `review:prepare`. |
| `POST /v1/account/reviews/{order_id}/start` | Start with `test_key` (and `credential_kind`), or `no_key`. Scope `review:run`. |
| `POST /v1/account/reviews/{order_id}/stop` | Cancel a queued or running Review: no report, no free re-run. Scope `review:run`. |
| `POST /v1/account/reviews/{order_id}/retry` | Re-run a Review that failed on SiBear's side. Scope `review:run`. |
| `POST /v1/account/reviews/{order_id}/credential` | Give a fresh test key. Scope `review:run`. |
| `GET /v1/account/reviews/{order_id}/report` | The report, and its other forms: `report.json`, `report.sarif`, `report.pdf`, `summary.pdf`, `ml-bom`, `ml-bom.cdx.json`, `threat-model`, `system-map`, `compliance`. Scope `review:read`. |

The free scan's `GET /v1/scans/{request_id}/status` and `GET /v1/results/{result_id}` (and its exports) also accept the token, with scope `scan:read`. Payment, consents and the other person-only steps answer `403 person_only`; see [Agent access](/docs/agent-access).

The step-by-step order, with examples: [For AI agents](/docs/agents) for the free scan, [Run a paid Review](/docs/paid-review) for the Review.

## Errors

Every error has the same body:

```json
{"error": {"code": "validation_failed", "message": "...", "fields": [{"field": "...", "code": "...", "message": "..."}], "request_id": "..."}}
```

`code` is stable and meant for programs; `message` is for people; `fields` lists each field that was wrong, with its own code; `request_id` identifies the request if you contact support. Codes are listed in [Limits and errors](/docs/limits-and-errors).

## Rate limits

Every limit is listed in [Limits and errors](/docs/limits-and-errors#rate-limits). Every `429` has a `Retry-After` header in seconds.
