Create Generated Code
Target migration note: this endpoint is not the guinness-ai-v2 Des2Code trigger. Des2Code returns ranked code results and is triggered through
POST /v1/des2codeor MCP v2trigger-des2code; results are returned byPOST /v1/webhooks/ai-status.
Method
REST method is adopted.
HTTP Method
POST: Create generated code
Naming Convention
To unify the naming of query parameters and nodes and improve readability, snake_case is used for URIs and JSON nodes in requests.
Request and Response
Headers
Meta information is set in HTTP headers, not in the response body.
Request Headers
AuthorizationContent-TypeAcceptAccept-language
Response Headers
Content-Type
Create Generated Code
URI
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| organization_id | number | Required | Organization ID |
| project_id | number | Required | Project ID |
Request Body
The request body is JSON.
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| design_id | string | Required | Associated design ID (format: fileId_nodeId) |
| custom_prompt | string | Optional | Legacy instruction field; not consumed by the target Des2Code flow |
Response
The response is JSON (HTTP status: 201 Created).
{
"id": 1,
"projectId": 1,
"designId": "ABC123_2585:942",
"custom_prompt": "You are a frontend developer.",
"sourceCode": "",
"status": 0,
"createdAt": 1234567890000,
"updatedAt": 1234567890000,
"deletedAt": null,
"createdBy": "user-id",
"updatedBy": "user-id",
"deletedBy": null
}
Status Values
| Value | Description |
|---|---|
| 0 | Processing |
| 1 | Completed |
| 2 | Failed |
Authentication
Authentication is performed using JSON Web Tokens (JWT) issued by Amazon Cognito.
Error Handling
The status codes for error handling are as follows.
| Description | Status Code | Status Name |
|---|---|---|
| Invalid design ID or missing required fields | 400 | Bad Request |
| Missing credentials | 401 | Unauthorized |
| Insufficient permissions | 403 | Forbidden |
| Project, organization, or design not found | 404 | Not Found |
| Internal server error | 500 | Internal Server Error |
Processing Flow
- Extract organization ID and project ID from path parameters
- Extract design ID from request body
- Verify the user has write access to the project
- Verify the design exists
- If this legacy generated-code workflow is retained, dispatch only to its own queue; do not send to
guinness-ai-v2/apps/des2code - Create generated code record in the database (sourceCode: empty string, status: 0=processing)
- Return created generated code information
Detailed Flowchart
flowchart TD
Start([POST Request]) --> Route[Route Handler]
Route --> Auth[Auth & Parameter Extraction]
Auth --> Service[Service Layer]
Service --> AccessCheck[Access Check]
AccessCheck --> HasAccess{Write permission?}
HasAccess -->|No| Err404[404 Not Found]
HasAccess -->|Yes| VerifyDesign[Verify design exists]
VerifyDesign --> DesignExists{Exists?}
DesignExists -->|No| Err404
DesignExists -->|Yes| SendLegacy[Dispatch retained legacy workflow<br/>not des2code]
SendLegacy --> SQSResult{Dispatch successful?}
SQSResult -->|Failed| Err500[500 Internal Server Error]
SQSResult -->|Success| CreateDB
CreateDB[Create DB Record<br/>sourceCode=empty string<br/>status=0 processing] --> Success[201 Created]