Skip to main content

Endpoint

POST /api/platform
Content-Type: application/json

Request Format

FieldTypeRequiredDescription
sessionIdstringYesFrom /api/intent response.
refinedRequirementsobjectNoFallback if context has no refinedRequirements.
supabaseIntegrationbooleanyesWhen true, Supabase is included in the blueprint where applicable.

Example

{
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "supabaseIntegration": true
}

Response Format

Success (200)

FieldTypeDescription
status"success"
stage"platform_selection"
platform_optionsarrayEach: platform, description, cost_script, timeline_seconds, agents_required[], fit_score (and optional tech_stack).
recommendedstringOne of: Website, Web Application, Android, iOS.
next_stage"payment_processing"

Example

{
  "status": "success",
  "stage": "platform_selection",
  "platform_options": [
    {
      "platform": "Web Application",
      "description": "Fits SaaS with auth and real-time; full backend and DB.",
      "cost_script": 10000,
      "timeline_seconds": 75,
      "agents_required": ["ProductManager", "FrontendDev", "BackendDev", "DevOpsEngineer", "ToolManager"],
      "fit_score": 95
    }
  ],
  "recommended": "Web Application",
  "next_stage": "payment_processing"
}
Note: cost_script is always UNIFIED_PRICE_SCRIPT (e.g. 10000); the handler overwrites values from selectPlatform.

Error (4xx / 5xx)

FieldDescription
status"error"
stage"platform_selection"
errorMessage.

Error Codes

HTTPCause
400sessionId missing; workflow not found and no refinedRequirements to rebuild; refinedRequirements still missing after recovery.
405Method not POST.
500selectPlatform (OpenRouter) failure; DB or schema issues (e.g. supabaseIntegration when migration not run).

Implementation Notes

  • Loads context via getWorkflowContextDB then getWorkflowContext. If refinedRequirements is missing, uses refinedRequirements from the body when provided.
  • Calls selectPlatform(refinedRequirements, sessionId) from lib/openai.ts (PlatformSelector). Normalizes each option’s cost_script to UNIFIED_PRICE_SCRIPT.
  • Persists: platformOptions (normalized), supabaseIntegration, currentStage: 'platform_selection'. platformOptions may not be stored in DB; in-memory is used as fallback.