Skip to main content

Widget API

Overview

The SDAC widget browser calls its own origin. It does not call the ingestion worker or Mastra runtime directly. The widget server exposes health/config routes and two same-origin proxy families:

  • /api/ingestion/* forwards to ingestion-compatible SDAC routes.
  • /api/mastra/* forwards to Mastra/runtime SDAC routes.

The generated OpenAPI artifact is:

docs/openapi/widget-api.json

Regenerate and check it with:

npm run contracts:widget:generate
npm run contracts:widget:check

Replit Boundary

In Replit, run the widget locally and point it at testing APIs through APIM. Browser code should use the same-origin widget routes, usually under the hosted /widget base path:

UI needWidget/Replit routeUpstream owner
Runtime configGET /widget/api/configWidget server
Session bootstrapPOST /widget/api/ingestion/sdac/sessionsIngestion/runtime compatibility
Chat streamPOST /widget/api/ingestion/sdac/chatIngestion/runtime compatibility
FeedbackPOST /widget/api/ingestion/sdac/feedbackIngestion/runtime compatibility
ValidationPOST /widget/api/ingestion/sdac/validateIngestion/runtime compatibility
Cost lookupGET /widget/api/ingestion/sdac/costsIngestion/runtime compatibility
Workbook uploadPOST /widget/api/mastra/sdac/uploadMastra runtime
Upload pollingGET /widget/api/mastra/sdac/uploads/{jobId}/statusMastra runtime
Analysis pollingGET /widget/api/mastra/sdac/report-analysis/{reportId}/statusMastra runtime

The widget server attaches upstream credentials server-side. Do not put APIM subscription keys, ingestion worker secrets, or Mastra service credentials in browser code.

Contract Ownership

  • docs/openapi/widget-api.json owns the browser/Replit same-origin route families and auth/proxy boundary.
  • docs/openapi/ingestion-server-api.json owns direct ingestion worker/web schemas.
  • docs/openapi/runtime-routes-api.json owns direct Mastra SDAC runtime route schemas.
  • docs/internal/documentation-revival/endpoint-catalog.md and .yaml own APIM route safety, mutation class, and Replit handoff notes.

Source And Tests

AreaSourceTests
Route registrationapps/widget/server/routes.tsapps/widget/server/__tests__/routes.test.ts
Ingestion proxyapps/widget/server/ingestion-proxy.tsapps/widget/server/__tests__/routes.test.ts
Mastra proxyapps/widget/server/mastra-proxy.tsapps/widget/server/__tests__/routes.test.ts, apps/widget/server/__tests__/mastra.integration.test.ts
Client upload/session callsapps/widget/client/src/lib/ingestion-api.ts, apps/widget/client/src/lib/session-api.ts, apps/widget/client/src/lib/costs-api.tsapps/widget/client/src/lib/__tests__/**, apps/widget/tests/e2e/widget.spec.ts