Skip to main content

Endpoint

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

Request Format

FieldTypeRequiredDescription
sessionIdstringYesFrom /api/idea response.
answersstring[]YesAnswers to clarifying_questions (order preserved).
ideastringNoFallback if workflow context was lost; used to recreate context.

Example

{
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "answers": [
    "Web and mobile, web first",
    "Real-time sync with offline support"
  ]
}

Response Format

Success (200)

FieldTypeDescription
status"success"
stage"intent_analysis"
refined_requirementsobjecttitle, description, features[], target_audience, technical_requirements[].
next_stage"platform_selection"

Example

{
  "status": "success",
  "stage": "intent_analysis",
  "refined_requirements": {
    "title": "Remote Team Task Manager",
    "description": "Kanban and time tracking for distributed teams with real-time sync.",
    "features": ["kanban", "time tracking", "real-time sync", "offline support"],
    "target_audience": "Remote and hybrid teams",
    "technical_requirements": ["Web (React/Next.js) first", "Mobile later", "Real-time backend"]
  },
  "next_stage": "platform_selection"
}

Error (4xx / 5xx)

FieldDescription
status"error"
stage"intent_analysis"
errorMessage.

Error Codes

HTTPCause
400sessionId missing; answers missing, not array, or empty; context not found and no idea to recover.
405Method not POST.
500refineIntent (OpenRouter) or DB/write failure.

Implementation Notes

  • Uses getWorkflowContextDB (then getWorkflowContext) to load context. If missing and idea is provided, creates/updates context with idea and then continues.
  • Calls refineIntent(idea, answers, sessionId) from lib/openai.ts (IntentAnalyzer).
  • Persists: answers, refinedRequirements, currentStage: 'intent_analysis'.