Endpoint
Request Format
| Field | Type | Required | Description |
|---|---|---|---|
sessionId | string | Yes | From /api/intent response. |
refinedRequirements | object | No | Fallback if context has no refinedRequirements. |
supabaseIntegration | boolean | yes | When true, Supabase is included in the blueprint where applicable. |
Example
Response Format
Success (200)
| Field | Type | Description |
|---|---|---|
status | "success" | |
stage | "platform_selection" | |
platform_options | array | Each: platform, description, cost_script, timeline_seconds, agents_required[], fit_score (and optional tech_stack). |
recommended | string | One of: Website, Web Application, Android, iOS. |
next_stage | "payment_processing" |
Example
cost_script is always UNIFIED_PRICE_SCRIPT (e.g. 10000); the handler overwrites values from selectPlatform.
Error (4xx / 5xx)
| Field | Description |
|---|---|
status | "error" |
stage | "platform_selection" |
error | Message. |
Error Codes
| HTTP | Cause |
|---|---|
| 400 | sessionId missing; workflow not found and no refinedRequirements to rebuild; refinedRequirements still missing after recovery. |
| 405 | Method not POST. |
| 500 | selectPlatform (OpenRouter) failure; DB or schema issues (e.g. supabaseIntegration when migration not run). |
Implementation Notes
- Loads context via
getWorkflowContextDBthengetWorkflowContext. IfrefinedRequirementsis missing, usesrefinedRequirementsfrom the body when provided. - Calls
selectPlatform(refinedRequirements, sessionId)fromlib/openai.ts(PlatformSelector). Normalizes each option’scost_scripttoUNIFIED_PRICE_SCRIPT. - Persists:
platformOptions(normalized),supabaseIntegration,currentStage: 'platform_selection'.platformOptionsmay not be stored in DB; in-memory is used as fallback.