# youraitools-api

`api.youraitools.co`: one domain in front of our pay-per-call x402 tools for AI agents. It's a Cloudflare Pages project whose Functions proxy:

| Path | Worker | Paid routes |
|---|---|---|
| `/agentgate/*` | agentgate.agentgate.workers.dev | `GET /v1/check-agent` ($0.005) |
| `/webread/*` | webread.agentgate.workers.dev | `GET /v1/read` ($0.002) |
| `/injectscan/*` | injectscan.agentgate.workers.dev | `GET/POST /v1/scan` ($0.003) |
| `/domaincheck/*` | domaincheck.agentgate.workers.dev | `GET /v1/domain` ($0.002), `GET /v1/email` ($0.001) |
| `/payguard/*` | payguard.agentgate.workers.dev | `GET /v1/address` ($0.001), `POST /v1/batch` ($0.01, up to 50) |
| `/pkgguard/*` | pkgguard.agentgate.workers.dev | `POST /v1/scan` ($0.003, up to 500 packages), `GET /v1/package` ($0.001) |
| `/x402-template/*` | x402-template.agentgate.workers.dev | `GET /download` ($19, the x402 Proxy Template zip; free preview at `/x402-template/`) |

The proxy is transparent. Method, query, body, status (including 402) and every header (`PAYMENT-REQUIRED`, `X-PAYMENT`, `PAYMENT-SIGNATURE`, `PAYMENT-RESPONSE`, `X-PAYMENT-RESPONSE`) pass through untouched, and bodies stream. Requests reach the Workers over service bindings.

Each request carries `X-Forwarded-Host: api.youraitools.co` and `X-Forwarded-Prefix: /<tool>`. A Worker honours these only when the host is in its `PROXY_HOSTS` allowlist and the prefix equals its `PROXY_PREFIX` (see `src/publicbase.js` in each tool). In that case every URL the Worker emits uses `https://api.youraitools.co/<tool>`: the x402 `resource` (v2 header and v1 body), openapi `servers`, `/.well-known/x402`, MCP/preview hints and landing links. The Worker keeps one app instance per public base, so the resource a client signs is the one verified and settled. Direct workers.dev requests are unchanged.

Domain-level documents:
- `/`: tool index (JSON, or HTML for browsers)
- `/index.json`
- `/.well-known/x402`: all paid resources
- `/openapi.json`: combined, with paths `/<tool>/...`
- `/llms.txt`, `/health`, `/robots.txt`
- `/sitemap.xml`: static, built by `npm run build` (scripts/gen_sitemap.mjs) from functions/tools.js; human HTML pages only (index, each tool landing, sample report/card pages)

```
npm run build                 # regenerate public/sitemap.xml (probes each URL; --offline to skip)
npm test                      # node --test test/
npx wrangler pages deploy --branch main
```

DNS (Route53): `CNAME api.youraitools.co -> youraitools-api.pages.dev`. Cloudflare validates over HTTP and issues the certificate automatically once the CNAME resolves.

MIT licensed.
