Skip to content

Let agents start and poll scans over HTTP - #68

Merged
maaland merged 1 commit into
mainfrom
feat/scan-api-37
Oct 12, 2026
Merged

maaland merged 1 commit into
mainfrom
feat/scan-api-37

Conversation

@maaland

@maaland maaland commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Closes #37

Covers both "Done when" lines of #37 (updated: documented in the README until the agents page, #39, exists): start, reuse of a fresh scan, poll until done and each error case are tested.

What changes

  • POST /api/scans with Authorization: Bearer <key> and { "domain": "…", "force"?: true }:
    • Same requestScan rules as the website: one running scan per domain, finished scans under 24 h are reused unless force.
    • 202 while running (with Retry-After: 3), 200 when finished. The body is the /s/<domain>.json shape plus reused and poll.
    • New scans spend the key's allowance (10 a day). Every request is logged against the key: exactly one usage row, as a new scan or a reuse.
  • GET /api/scans/:id: status, and the report once finished. No key needed, since reading is free like the report pages. Cached like the JSON twin (2 s while running).
  • Errors as JSON { error, message }:
    • 400 for invalid_json or invalid_domain.
    • 401 for invalid_key, with WWW-Authenticate.
    • 404 for not_found.
    • 429 for rate_limited, with resetAt and Retry-After.
  • CORS: Access-Control-Allow-Origin: * and an OPTIONS preflight that allows Authorization, so browser-based agents can call it.
  • lib/start-workflow.ts: the website's scan form and the API now start scans through the same helper.
  • README: a short "HTTP API" section (get a key, start, poll, error table, revoke).

Checked

  • Unit tests:
    • Start (202, poll, Retry-After, one new-scan spend).
    • A fresh finished scan is reused (200, reused: true, nothing spent); force starts a new one and spends.
    • Every request is logged.
    • 10 new scans, then 429 with reset; existing scans are still fetchable.
    • 400 cases; 401 for missing, malformed, unknown and revoked keys.
    • Poll 202, then 200 with the report; 404.
  • Production build against a throwaway database: create a key, reuse drippa.ai (200 with the report), start example.invalid (202, Retry-After), poll (202), the 400/401/404 cases, and the OPTIONS preflight. A scan running to completion wasn't checked locally, because the background run can't share the single-connection test database. The unit tests cover polling through to "done".
  • pnpm lint, pnpm typecheck, pnpm test pass.

Note

The README uses https://stackprobe.tech, which is team-only until we open it. It describes how the API will work once public.

🤖 Generated with Claude Code

POST /api/scans with an API key starts a scan, or returns the running
or recent one, by the same rules as the website: 202 while it runs, 200
when finished, with a poll URL. New scans spend the key's 10 a day;
every request is logged against the key. GET /api/scans/:id returns the
status and, once finished, the report; reading needs no key. Bodies are
the same shape as /s/<domain>.json. Clear JSON errors: 400, 401, 404,
429 with Retry-After. CORS allowed, preflight answered.

The README documents it, until the agents page (#39) exists.

Closes #37

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
stackprobe Ready Ready Preview Oct 12, 2026 7:33pm UTC

Request Review

@drippa-ai

drippa-ai Bot commented Oct 12, 2026

Copy link
Copy Markdown

Drippa Sign-Off: HTTP API for agents to start and poll scans

✅ Delivers ticket #37 — 5 of 5 outcomes

Open in Drippa

What was promised

  • ✅ HTTP scan API #37 An agent with a key can start a scan for a domain and gets back the scan id, its status and the address to poll.
  • ✅ HTTP scan API #37 Asking again for a domain scanned in the last day returns that scan without spending the key's allowance, unless a fresh scan is forced.
  • ✅ HTTP scan API #37 Anyone can poll a scan without a key and gets the report once it is finished.
  • ✅ HTTP scan API #37 Clear JSON errors for a bad domain, a missing or invalid key, and a key over its daily limit.
  • ✅ HTTP scan API #37 The API is described in the README with how to get a key, start, poll and what each error means.

Not in this change: The agents page, its Markdown version, the llms.txt file and the new header, footer and home page links from #39.

Proof
Not tested in the browser: behaviour change with no page to click.

Steps based on ticket #37, the pull request description and the code change.

Test it yourself (3 steps)

Behaviour change with no page to click.

  1. HTTP scan API #37 In the browser, open the scan status address for a scan id that does not exist, /api/scans/nope.
    → A JSON message saying there is no scan with that id, with error not_found.
  2. HTTP scan API #37 Open /api/scans directly in the browser address bar.
    → No scan starts; starting a scan only works when a request is sent with a key, which the browser bar does not do.
  3. Go to the home page, enter a domain in the scan form and start a scan.
    → The scan starts and its report page opens as before.
Details

Agents and scripts can now start a scan with a self-serve key, or get back the running or recent scan for that domain, and then poll for the result without a key. Errors come back as plain JSON: bad domain or body, missing or invalid key, unknown scan, and hitting the daily limit. The website's scan form now starts scans through the same shared step as the API, and the README gains an HTTP API section.

Test coverage: ✅ Well covered — Tests cover starting, reusing a fresh scan, forcing a new one, usage logging, the daily limit, every error case and polling until done.

🔍 Checked: tickets #37 and #39, 7 of 7 changed files read, plus the shared key error helpers elsewhere in the app


Updated by Drippa • 2026-10-12 19:34 UTC

Comment @drippa-ai review for a fresh review.

@drippa-ai drippa-ai Bot mentioned this pull request Oct 12, 2026
@maaland
maaland merged commit 0f869b9 into main Oct 12, 2026
7 checks passed
@maaland
maaland deleted the feat/scan-api-37 branch October 12, 2026 19:36

This branch was successfully deployed

1 active deployment
Preview — 104310a6 Deployed Oct 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTP scan API

1 participant