Skip to main content

Design Engine Sessions API

The collaborative design engine is a multi-stage AI workflow that takes a product description through requirements drafting, BOM structuring, CAD generation, and assembly composition -- with human review at each stage. Sessions are persisted in the database and stage execution is streamed via Server-Sent Events.

Overview

EndpointMethodAuthDescription
/api/design-engine/sessionsGETAuth requiredList user's sessions
/api/design-engine/sessionsPOSTAuth requiredCreate a new session
/api/design-engine/sessions/:idGETAuth requiredGet session details
/api/design-engine/sessions/:idPATCHAuth requiredUpdate session fields
/api/design-engine/sessions/:id/streamPOSTAuth requiredExecute stage actions (SSE streaming)
/api/design-engine/sessions/:id/materializeGETAuth requiredPreview materialization
/api/design-engine/sessions/:id/materializePOSTAuth requiredExecute materialization

All endpoints require authentication. Sessions are scoped to the creating user -- only the session owner can access or modify their sessions.

Session lifecycle

idle -> requirements_drafting -> requirements_review
-> bom_drafting -> bom_review
-> materialization
-> cad_generation -> cad_review
-> assembly_composition -> assembly_review
-> complete

Stages alternate between AI drafting (streamed) and human review (non-streaming confirmation). The error and paused states can occur at any point.

Session statuses

StatusDescription
activeSession is in progress
pausedSession paused by user or system
completedMaterialization executed successfully
failedAn error occurred during stage execution

POST /api/design-engine/sessions

Create a new collaborative design session.

Request Body

{
"description": "Design an electric go-kart for children ages 8-12",
"programId": "uuid",
"designId": "uuid",
"aiChatSessionId": "uuid"
}
FieldTypeRequiredDescription
descriptionstringYesProduct description / design brief
programIdUUIDYesProgram to associate the session with
designIdUUIDNoExisting design to target for materialization
aiChatSessionIdUUIDNoLink to an existing AI chat session

Response (201 Created)

{
"data": {
"session": {
"id": "session-uuid",
"title": "Electric Go-Kart",
"stage": "idle",
"status": "active",
"workspaceUrl": "/designs/collaborative/session-uuid"
}
}
}

GET /api/design-engine/sessions

List all sessions for the authenticated user.

Response

{
"data": {
"sessions": [
{
"id": "session-uuid",
"title": "Electric Go-Kart",
"stage": "bom_review",
"status": "active",
"createdAt": "2025-03-15T10:00:00.000Z",
"updatedAt": "2025-03-15T11:30:00.000Z"
}
]
}
}

GET /api/design-engine/sessions/:id

Get full session details including artifacts.

Response

{
"data": {
"session": {
"id": "session-uuid",
"userId": "user-uuid",
"title": "Electric Go-Kart",
"stage": "bom_review",
"status": "active",
"programId": "program-uuid",
"designId": "design-uuid",
"artifacts": {
"description": "Design an electric go-kart...",
"requirements": [
{
"tempId": "req-1",
"name": "Maximum speed",
"description": "Top speed shall not exceed 15 km/h",
"requirementType": "Performance",
"priority": "high",
"verificationMethod": "Test",
"rationale": "Safety standard for children's vehicles",
"confidence": 0.9,
"source": "ai"
}
],
"bom": {
"rootAssembly": {
"tempId": "asm-1",
"name": "Go-Kart Assembly",
"isNew": true,
"quantity": 1,
"children": [],
"requirementTempIds": [],
"partType": "Manufacture",
"rationale": "Top-level assembly",
"confidence": 1.0
},
"proposedParts": [],
"requirementsCoverage": {},
"uncoveredRequirements": [],
"validationIssues": []
},
"clarifications": [],
"userMessages": []
}
}
}
}

PATCH /api/design-engine/sessions/:id

Update session fields. Supports updating the description, artifacts, or stage independently.

Request Body

All fields are optional. Include only the fields you want to update.

{
"description": "Updated product description",
"artifacts": {},
"stage": "bom_drafting"
}
FieldTypeDescription
descriptionstringUpdates the description inside the session's artifacts
artifactsobjectReplaces the session's artifact JSONB (merged with existing)
stagestringMoves the session to a different stage

Response

{
"data": {
"session": {}
}
}

POST /api/design-engine/sessions/:id/stream

The primary endpoint for driving stage execution. Accepts an action and returns either a JSON response (for confirmations) or an SSE stream (for AI-driven stages).

Request Body

{
"action": "start_requirements",
"questionId": "clarification-id",
"answer": "User's answer to clarification",
"message": "Free-form user message",
"tempId": "part-temp-id",
"feedback": "Regeneration feedback"
}
FieldTypeRequiredDescription
actionstringYesThe action to perform (see table below)
questionIdstringConditionalRequired for answer_clarification
answerstringConditionalRequired for answer_clarification
messagestringConditionalRequired for send_message
tempIdstringConditionalRequired for regenerate_part
feedbackstringNoOptional feedback for regenerate_part

Actions

Streaming actions (return SSE response)

ActionDescription
start_requirementsBegin or restart requirements drafting stage
start_bomBegin or restart BOM drafting stage
start_cad_generationBegin CAD generation for BOM parts
start_assembly_compositionBegin assembly composition stage
resumeResume the current in-progress drafting stage
regenerate_partRegenerate CAD for a specific part (requires tempId)

Non-streaming actions (return JSON)

ActionResponseDescription
confirm_requirements{ session, confirmed: "requirements" }Confirm requirements and advance to BOM stage
confirm_bom{ session, confirmed: "bom" }Confirm BOM and advance to materialization
confirm_cad{ session, confirmed: "cad" }Confirm CAD output
confirm_assembly{ session, confirmed: "assembly" }Confirm assembly composition

Interactive actions (may return SSE or JSON)

ActionDescription
answer_clarificationAnswer a pending clarification question, then restart the current drafting stage as SSE
send_messageSend a free-form message; restarts drafting stage as SSE if in a drafting stage, otherwise returns { acknowledged: true }

SSE event format

Streaming responses use text/event-stream content type with the following event structure:

event: stage_event
data: {"type":"llm_text","text":"Based on the requirements..."}

event: stage_event
data: {"type":"artifact_update","artifacts":{"requirements":[...]}}

event: stage_event
data: {"type":"stage_change","stage":"requirements_review"}

event: done
data: {"finished":true}

StageEvent types

Event typeFieldsDescription
stage_changestageSession moved to a new stage
artifact_updateartifacts (partial)Updated artifacts to merge into session state
llm_texttextStreamed text from the LLM
tool_calltoolName, argsLLM invoked a tool
tool_resulttoolName, resultTool returned a result
clarification_neededquestionId, question, options?AI needs user input before continuing
stage_completestage, summaryStage finished successfully
errormessageAn error occurred
pausedreasonSession was paused
user_messageid, textEcho of a user message

Response headers

HeaderDescription
Content-Typetext/event-stream for streaming, application/json for non-streaming
Cache-Controlno-cache
Connectionkeep-alive
X-Session-IdSession UUID

GET /api/design-engine/sessions/:id/materialize

Preview what items would be created if materialization were executed. Requires a BOM to be present in the session artifacts.

Response

{
"data": {
"preview": {
"newPartsCount": 8,
"reusedPartsCount": 2,
"newRequirementsCount": 5,
"bomRelationshipsCount": 10,
"requiresEco": true,
"targetDesignId": "design-uuid",
"items": [
{
"tempId": "part-1",
"name": "Motor Mount",
"itemType": "Part",
"isNew": true
},
{
"tempId": "part-2",
"name": "Standard Bearing",
"itemType": "Part",
"isNew": false,
"existingItemNumber": "P-1042"
}
]
}
}
}

POST /api/design-engine/sessions/:id/materialize

Execute materialization -- creates actual PLM items (parts, requirements, BOM relationships) from the session's draft artifacts. Creates an ECO if the target design is post-release.

Can only be executed once per session. After successful materialization the session status changes to completed.

Response

{
"data": {
"result": {
"designId": "design-uuid",
"ecoId": "eco-uuid",
"ecoNumber": "ECO-0042",
"createdItems": [
{
"tempId": "part-1",
"itemId": "item-uuid",
"itemNumber": "P-1050",
"itemType": "Part",
"name": "Motor Mount"
}
],
"bomRelationshipsCreated": 10
}
}
}

Errors

StatusCondition
404Session not found
403User is not the session owner
422No BOM artifacts to materialize, or session already completed

Session artifacts schema

The artifacts JSONB column stores the full design state:

interface DesignArtifacts {
description: string
requirements: RequirementDraft[]
bom: BomDraft | null
clarifications: ClarificationEntry[]
userMessages: UserMessage[]
pendingClarificationId?: string
materializationResult?: MaterializationResult
cadGenerationState?: CadGenerationState
}

RequirementDraft

FieldTypeDescription
tempIdstringTemporary ID (not a database UUID)
namestringShort requirement name
descriptionstringFull requirement text
requirementTypeenumFunctional, Performance, Interface, Constraint, Other
priorityenumlow, medium, high, critical
verificationMethodenumAnalysis, Inspection, Test, Demonstration
rationalestringWhy this requirement exists
confidencenumberAI confidence score (0-1)
sourceenumai or user

BomNodeDraft

FieldTypeDescription
tempIdstringTemporary ID
namestringPart name
isNewbooleanWhether this is a new part or an existing one
existingItemIdstringIf reusing an existing part, its item ID
quantitynumberQuantity in parent assembly
childrenBomNodeDraft[]Child nodes in the BOM tree
requirementTempIdsstring[]Linked requirement temp IDs
partTypeenumManufacture, Purchase, Software, Phantom
materialstringMaterial specification
rationalestringDesign rationale
confidencenumberAI confidence score (0-1)
cadGenerationobjectCAD generation status and output references
assemblyCompositionobjectAssembly composition status