# API reference

Use the API when you want scans from your own code. Send your key as `Authorization: Bearer YOUR_API_KEY`. Create keys in your [dashboard](https://hackbait.com/developers/dashboard).

## Endpoints

- `POST /v1/scan` with `url` and `type` (`surface` or `vuln`). A Surface Scan answers right away; a Vulnerability Scan answers 202 with a job id.
- `GET /v1/jobs/JOB_ID` for the status of a Vulnerability Scan.
- `GET /v1/me` for your credits, key limits and prices.
- `GET /v1/reports` for past scans (filters: `site`, `type`, `page`, `page_size`).
- `POST /v1/sites/verify`, `/v1/sites/verify/email` and `/v1/sites/verify/check` to prove you own a site. See [Prove you own a site](https://hackbait.com/docs/ownership).

## A Surface Scan

The result has the site, the grade, how many checks ran, the issues (each with plain wording and fix steps), a private report link and your credits left.

```
{
  "site": "example.com",
  "grade": "B",
  "checks_run": 29,
  "issues": [
    { "title": "...", "plain": "...", "fix_steps": ["..."] }
  ],
  "report_url": "https://hackbait.com/r/...",
  "credits_left": "$..."
}
```

**Example request (curl)**

```
curl https://hackbait.com/v1/scan \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"url": "example.com", "type": "surface"}'
```

If the site's firewall or bot protection blocked our scanner, the grade is null, `blocked` is true, and the result names the firewall and may include a scanner address to allow. That scan's credit is not returned.

```
{
  "site": "example.com",
  "grade": null,
  "blocked": true,
  "firewall": "...",
  "message": "...",
  "scanner_ip": "..."
}
```

## A Vulnerability Scan

Only for sites you have verified. It returns a job id; poll the job or set a webhook, and you are emailed when it finishes.

```
POST /v1/scan  {"url": "example.com", "type": "vuln"}
-> 202 {"job_id": "...", "status": "queued"}

GET /v1/jobs/JOB_ID
-> {"status": "running"}   later: {"status": "done", "report_url": "https://hackbait.com/r/..."}
```

## Errors

Errors are JSON with `error` and `message`. Common ones: `bad_request` (400), `site_not_verified` (403), `out_of_credits` (402, with a link to buy credits), `rate_limited` (429), `free_scan_cap` (429), `key_paused` (423).

## Costs

- A Surface Scan costs $0.15 from prepaid credits.
- A Vulnerability Scan costs $20 (sold in packs: 5 for $100).
- A new verified email starts with $1 of free credit. Any one site gets at most 3 free scans in total; paid use is not capped by that free limit.
- The smallest credit purchase is $20. You can turn on auto top-up in the dashboard.

These amounts come from the same settings as the [Developers page](https://hackbait.com/developers). Consumer prices for the Fix-it Guide, Deep Scan and Monitor Plus are on [Pricing](https://hackbait.com/pricing).
