PluginMind Docs

Endpoints

Every PluginMind backend endpoint is protected by structured logging, correlation IDs, and unified error envelopes. Authentication-sensitive routes require the pm_session cookie issued by /auth/google.

Base URL:

  • Local development → http://localhost:8000
  • Docker compose → http://backend:8000

Errors are returned as:

Loading code snippet…

🔁 Analysis

POST /process (session cookie required)

Run generic AI processing workflows.

Request body

Loading code snippet…
  • analysis_type accepts document, chat, seo, crypto, custom.
  • Unknown values return 422.

Response

Loading code snippet…

Typical status codes: 200, 401, 422, 429, 500.

POST /analyze (legacy, session cookie required)

Backwards-compatible crypto analysis. Request body only needs user_input.

POST /analyze-async

Create a background job. Accepts the same body as /process and returns:

Loading code snippet…

GET /analyze-async/{job_id}

Fetch job status and stored results.

Loading code snippet…

📚 Jobs & Logs

GET /jobs

Returns a summary of stored async jobs.

Loading code snippet…

DELETE /jobs/{job_id}

Removes a job from the database. Returns { "message": "Job ... deleted successfully" } or 404.

GET /query-logs

Accepts limit (default 50) and optional user_id query parameters. Response uses the QueryLogsResponse schema with truncated inputs for readability.


👤 User APIs

GET /me

Returns the SQLModel-backed user profile (creating one if necessary).

Loading code snippet…

GET /me/usage

Tracks monthly usage counters.

Loading code snippet…

GET /users/profile

JSON payload tailored for the Next.js frontend:

Loading code snippet…

❤️‍🔥 Authentication

EndpointMethodNotes
/auth/googlePOSTBody { "id_token": "..." }. Sets pm_session cookie.
/auth/logoutPOSTClears pm_session.
/auth/validateGETLegacy bearer-token helper.
/auth/meGETSame as /users/profile but exposed under /auth.

Refer to Authentication Guide for flow details.


🩺 Health & Meta

EndpointMethodDescription
/GETReturns app name, version, feature flags, and docs URL (only in debug).
/healthGET{ "status": "ok", "active_jobs": 1 } with legacy in-memory job cleanup.
/liveGETAlways { "status": "live" }. Suitable for liveness probes.
/readyGETChecks DB connectivity and environment variables. Returns 503 with structured detail if not ready.
/servicesGETCombined registry + health snapshot.
/services/healthGETRaw registry health map from analysis_service.health_check().
/versionGET{ "name": ..., "version": ..., "git_sha": ... }.

🚦 Status Codes at a Glance

CodeMeaning
200Success
201Created (not currently used)
401Missing/invalid pm_session cookie
404Resource not found (e.g., jobs)
422Validation errors (pydantic)
429Rate limit exceeded (Retry-After header supplied)
500Unhandled error (still wrapped in unified envelope)

🧑‍💻 Tips for Integrators

  • Always send requests with cookies (fetch(..., { credentials: 'include' })).
  • Pass X-Request-ID if you have a correlation ID from the frontend—otherwise middleware will generate one.
  • Use /services during boot to verify the OpenAI and Grok registrations before accepting traffic.
  • Delete stale async jobs (e.g., from tests) via DELETE /jobs/{job_id}.

Happy hacking! 🤖