Skip to main content

Endpoint

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

Request Format

FieldTypeRequiredDescription
sessionIdstringYesWorkflow from Idea → Intent → Platform → Payment.
transactionSignaturestringNoSolana tx signature; if provided, it is verified before execution. For Dodo, usually omitted; webhook sets dodoPaymentId.
platformstringNoFallback if context.selectedPlatform is missing (e.g. after redirect).

Example (Solana)

{
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "transactionSignature": "5VJ...abc"
}

Example (Dodo)

{
  "sessionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Response Format

Success (200)

FieldTypeDescription
status"success"
stage"execution"
execution_resultobjectSee below.
next_stage"completion"
execution_result
FieldTypeDescription
agents_executedstring[]e.g. ProductManager, FrontendDev, BackendDev, DevOpsEngineer, ToolManager.
deliverablesarray{ type, content, format, path?, agent? } per file.
total_cost_scriptnumberAmount charged.
execution_time_minutesnumberRounded from seconds.
review_passedbooleanFrom ReviewAgent; optional.
review_issuesstring[]From ReviewAgent; optional.

Example

{
  "status": "success",
  "stage": "execution",
  "execution_result": {
    "agents_executed": ["ProductManager", "FrontendDev", "BackendDev", "DevOpsEngineer", "ToolManager"],
    "deliverables": [
      { "type": "documentation", "content": "# PRD\n...", "format": "markdown", "path": "docs/PRD.md", "agent": "ProductManager" }
    ],
    "total_cost_script": 10000,
    "execution_time_minutes": 2,
    "review_passed": true,
    "review_issues": []
  },
  "next_stage": "completion"
}

Error (4xx / 5xx)

FieldDescription
status"error"
stage"execution"
errorMessage.

Status Codes / Error Causes

HTTPCause
400sessionId missing; workflow context not found and recovery failed; selectedPlatform missing; refinedRequirements missing and no idea to build minimal; transactionSignature invalid.
405Method not POST.
503One or more agents disabled via admin; error lists disabled agents.
500executeX402Workflow (OpenRouter, platform-templates), verifyTransaction, or DB/Prisma error.

Implementation Notes

  • Context: Uses getWorkflowContextDB then getWorkflowContext. If missing, can rebuild from prisma.workflow or create a minimal context when platform is provided. platformOptions and refinedRequirements are restored from DB/body/idea when possible.
  • Payment: If transactionSignature is present, verifyTransaction(transactionSignature) in lib/solana is called; on failure, 400. For Dodo, execution proceeds when dodoPaymentId / paymentMethod: 'dodo' are set (by webhook).
  • Agents: agentsToExecute comes from platformOptions for selectedPlatform, or defaults (e.g. ProductManager, FrontendDev, BackendDev; + DevOpsEngineer for Android/iOS). Each is checked with isAgentEnabled(agentName); if any are disabled, 503.
  • Execution: executeX402Workflow(selectedPlatform, refinedRequirements, sessionId, agentsToExecute, workflowContext) in lib/openai runs generatePlatformDeliverables, review, deduplication, etc. workflowContext includes idea, analysis, answers, platformOptions, selectedPlatform, paymentDetails, supabaseIntegration.
  • Side effects: Updates Workflow with executionResult and currentStage: 'execution'; updates AgentStat per agent; creates Transaction and can update User.totalSpent for Solana payments.