Togoder security

API reference

Scan from your own code

Call one endpoint with your lockfile and the API key of a monthly plan. Only files nobody has scanned before count toward your plan; if every file was scanned before, the scan is free and needs no key.

How scanning works

  1. POST your lockfile or manifest to /api/paid-scan with your API key.
  2. The server downloads every package and hashes each file. Files whose exact content was scanned before are free; the rest count toward your plan's tokens.
  3. The server scans the new files and returns results.

If every file was scanned before, the results come back without a key and cost nothing. New files without an active plan or enough prepaid balance return 402 Payment Required with an error message. A package version whose files changed since its last scan is re-scanned for the changed files only.

Prepaid balance

An account without a plan can pay from a prepaid balance: send your API key and the scan's price comes off the balance before it runs. It costs the quote's balancePriceUsd (GET /api/quotes/:id), and a scan that fails gives it back. A plan's scans never use the balance, and a plan over its token limit gets 429.

Without enough balance the response is 402 with error, balanceUsd (what the account has), priceUsd (what this scan costs from the balance) and topupUrl.

Top-ups happen on the account page, not over the API: sign in, enter at least $20 and pay on Polar's checkout, where VAT or sales tax is added where it applies. The balance needs an account and never expires, and unused balance is refundable from the account page.

Command line and CI

The easiest client is togoder-scan, an open-source (MIT) CLI on npm. It finds the lockfile, waits for the scan, applies .npm-scanner-ignore, exits non-zero on findings and can write SARIF for GitHub code scanning. It uploads only the lockfile and the ignore list, never your code.

npx togoder-scan estimate         # what needs scanning, and the price
npx togoder-scan login            # save an API key (or set NPM_SCANNER_KEY)
npx togoder-scan --fail-on high   # scan; exit 1 on high or critical findings
npx togoder-scan --sarif -o results.sarif

A GitHub Actions workflow is in the README and in Scan your lockfile in CI. The rest of this page is the HTTP API the CLI uses.

Findings & ignore lists

The response has results (per package: riskLevel, effectiveRiskLevel, ignoredCount, issues), a flat issues list and a summary (packagesScanned, packagesFailed, totalIssues, highSeverityCount, ignoredCount).

Every finding has a stable findingId like NPS-3F9A0C1B2D4E: a hash of the package name, the file's SHA-256, the finding type and line. It stays the same across rescans and across versions that ship the same file.

Send an ignore field with /api/paid-scan (form field, or a string or array in JSON) to set reviewed findings aside. One entry per line, # starts a comment that comes back as the reason:

# .npm-scanner-ignore
NPS-3F9A0C1B2D4E           # reviewed: documented telemetry
NPS-0811DA3A5FA0@2.1.0     # only in this version
left-pad@1.3.0             # every finding of this version
@acme/internal-tool        # every finding of this package
curl -X POST https://security.togoder.click/api/paid-scan   -H "Authorization: Bearer $NPM_SCANNER_KEY"   -F "file=@package-lock.json" -F "ignore=<.npm-scanner-ignore"

Matched findings get ignored: true, ignoredBy and ignoreReason; they don't count in totalIssues or highSeverityCount, and effectiveRiskLevel drops to the worst remaining finding. Ignoring only changes your response; stored results are untouched. A malformed list returns 400.

Monthly plans & API keys

Sign in with GitHub or Google (the first sign-in creates your account), pick a plan and create an API key on the same page. Plans: Starter $69/month for 100M LLM tokens per 30 days, Team $199 for 350M, Business $499 for 1B and Scale $3,999 for 10B (pricing). Payment is by card, Apple Pay or Google Pay, handled by Polar. Access starts as soon as the payment is confirmed and renews monthly; change plan or cancel any time from the account page. Send the key with /api/paid-scan and the scan runs on your plan:

curl -X POST https://security.togoder.click/api/paid-scan \
  -H "Authorization: Bearer $NPM_SCANNER_KEY" \
  -F "file=@package-lock.json"

X-API-Key: <key> works too. Your plan's tokens are counted from what the model actually processed over the last 30 days; files scanned before are free. Over the limit, scans return 429. Without access, it pays from your prepaid balance if that covers the scan. Without access, a scan with new files returns 402 with an error message; files scanned before stay free. An unknown or revoked key returns 401. The endpoints below take an API key, or the sign-in cookie when called from this site.

GET/api/account

Access end date, plan, token limit (monthlyTokenLimit, and subscription.tokenLimit after a plan change this period), subscription status and management links, claim code and LLM token usage over the last 30 days.

GET/api/keys

List the account's keys (prefix only; full keys are never shown again).

POST/api/keys

Create a key. JSON body {"name": "CI"}. The response holds the key once. Up to 20 active keys.

DELETE/api/keys/:id

Revoke a key. An account with a sign-in can revoke all its keys; an older key-only account keeps its last one.

Sign-in & billing

These are what the account page uses. Upgrades are charged the prorated difference right away, and the extra tokens are prorated for the rest of the billing period; downgrades charge nothing now and keep the higher limit until renewal. Requests made with the sign-in cookie must come from this site.

GET/auth/:provider

Sign in with github or google; ?next=/path is where to return. Signed in, it links the provider to your account. POST /auth/logout signs out.

GET/api/me

Whether this browser is signed in, with the account and its GitHub / Google logins. DELETE /api/me/logins/:provider unlinks one (never the last); POST /api/account/link-key claims an account made with an API key before sign-in existed.

GET/api/plans

Plans on offer with their token limits and prices, your current plan, and which checkout provider is in use.

POST/api/billing/checkout

Signed-in browser only: JSON body {"plan": "team"} returns the url of a hosted Polar checkout to send the customer to.

POST/api/billing/change-plan

Switch plan: JSON body {"plan": "team"}. ?preview=1 returns the charge due now, the next renewal and the token limit without changing anything.

POST/api/billing/cancel

Cancel at the end of the paid period ({"immediately": true} ends access now, without a refund). POST /api/billing/resume-cancel undoes a scheduled cancel.

POST/api/billing/portal

A signed-in link into Polar's customer portal for invoices and the payment method.

Free endpoints

Read cached data or see what needs scanning. These never run a scan.

GET/api/package/:name/:version

Cached scan results for one package.

GET/api/package/:name/ranges

Every version of a package grouped into ranges by verdict (flagged, warning, clean, failed, not_scanned), with ecosystem-native and semver constraints and the flagged files traced across versions. Also GET /api/package-ranges?name=. Names may be scoped or prefixed (pypi:requests); ?registry=0 skips the registry lookup, ?prereleases=exclude drops prereleases.

GET/api/packages

Every scanned package version with overall stats. Query q, risk (safe…critical or issues), limit (max 200), offset. Findings of one: GET /api/packages/:id/issues.

POST/api/analyze

Which packages in a lockfile are cached and which need scanning.

POST/api/upload

Parse a lockfile, or resolve a package entered by name (ecosystem, packageName, packageVersion) with its dependency tree, and list the dependencies (htmx partial).

POST/api/estimate-cost

Download packages and count tokens for a quote (htmx partial). Answers right away with a partial that polls GET /api/estimate-cost/jobs/:id until the quote is ready.

Guarantees

  • Server-side counting. Plan usage comes from what the model actually processed. Clients cannot set it.
  • Checked before work. Access and the plan's token limit are checked before any scan of new files runs.
  • Failures are explicit. Packages that couldn't be analyzed come back as failed, never as safe.