v1

latestOpenAPI 3.1.02026-07-13121824.2 KB
Mermaid

Edit Existing Mermaid Diagram

Edit an existing Mermaid flowchart using AI based on natural language instructions.

AUTHENTICATION REQUIRED - Must include valid JWT token in Authorization header.

If context contains savedDiagramId, fetches the latest Mermaid code from database to ensure manual user edits (from auto-save) are included in the AI edit.

Args: edit_request: DiagramEditRequest containing current Mermaid code, edit instruction, and optional context request: FastAPI Request object (required for rate limiting) current_user: Authenticated user (injected by Auth0 middleware) db: Database session

Returns: MermaidResponse with edited Mermaid syntax code and updated title

Rate limit: Configurable via RATE_LIMIT_PER_MINUTE env var (default: 10/minute)

post/api/edit-mermaid

Request body

savedDiagramIdinteger required

ID of the saved diagram to edit (backend fetches latest version from database)

editInstructionstring required

Natural language instruction for what to change (5-1000 characters)

contextobject nullable

Optional context with title, description for better editing

Example request

{
  "savedDiagramId": 123,
  "editInstruction": "Add error handling",
  "context": {
    "description": "Original description of the diagram",
    "title": "User Login Flow"
  }
}

Response

Successful Response

mermaidCodestring required

Generated Mermaid diagram syntax

titlestring required

Diagram title extracted from description

diagram_type'flowchart' | 'sequence' | 'mindmap'

Type of diagram generated

savedDiagramIdinteger nullable

ID of the auto-saved diagram (if save was successful)

diagram_jsonobject nullable

Current diagram state from database (for edit operations, used in visual diff)

Example response

{
  "mermaidCode": "flowchart TB\n  start([Start])\n  finish([End])\n  start --> finish",
  "savedDiagramId": 123,
  "title": "User login flow with authentication..."
}