Endpoints
Method, auth, request, and response for each StackTracker HTTP route.
POST /api/ask
Public audit-page Q&A. It answers grounded only on StackTracker's tool-audit data.
- Method: POST only.
- Auth: none (public). Rate-limited to 10 requests / 60s per IP.
- Requires: server env
DEEPSEEK_API_KEY. Returns 503 if absent.
Request body:
{ "question": "string (max 300 chars)", "category": "string (optional)" }Response:
{ "answer": "string" }Errors:
| Status | Meaning |
|---|---|
| 503 | not_configured |
| 429 | rate_limited |
| 400 | bad_request |
| 502 | upstream |
POST /api/chat
Authenticated in-app analyst. Context is the signed-in user's own projects (totals, ratios, upcoming renewals).
- Method: POST only.
- Auth: required (Supabase user session). Returns 401 if not signed in. Rate-limited 10 / 60s per user.
- Requires:
DEEPSEEK_API_KEY.
Request body. The last 6 turns of history are used:
{
"question": "string (max 500 chars)",
"history": [{ "role": "user | assistant", "content": "string" }]
}Response:
{ "answer": "string" }Errors: 503, 401, 429, 400, 502.
POST /api/webhooks/revenuecat?project=<slug>
Inbound RevenueCat webhook.
- Method: POST only.
- Auth: a per-project shared secret. You must pass
?project=<slug>. The server looks up that project's stored RevenueCat secret and compares it to theAuthorization: Bearer <secret>header.
Errors:
| Status | Meaning |
|---|---|
| 400 | project missing |
| 404 | unknown project |
| 401 | secret mismatch |
Request body: a RevenueCat event. Only these event types create a revenue entry:
INITIAL_PURCHASERENEWALNON_RENEWING_PURCHASEUNCANCELLATION
Other event types are ignored.
Response on success. A revenue entry with source revenuecat is created, deduped on the event id:
{ "ok": true }Response for skipped events:
{ "ignored": "..." }GET /api/mail/callback/[provider]
Mail OAuth step-2 callback. You do not call this directly. It is the redirect target after granting access.
- Method: GET.
provider:gmailoroutlook.
It verifies the ?state against a cookie, exchanges the ?code for tokens, stores an encrypted mail connection, then redirects (302) to /settings/connections?connected=1. On failure it redirects with an ?error= value.