---
title: "Update Diagram"
method: PUT
path: "/api/diagrams/{diagram_id}"
tags: ["Diagrams"]
---

# Update Diagram

`PUT /api/diagrams/{diagram_id}`

Update a specific diagram by ID.

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

Args:
    diagram_id: ID of the diagram to update
    update_request: Fields to update (only provided fields will be updated)
    db: Database session
    current_user: Authenticated user

Returns:
    DiagramResponse with updated diagram data

Raises:
    404: If diagram not found or doesn't belong to user

## Path parameters

- `diagram_id` integer, required

## Request body

- DiagramUpdateRequest — Request model for updating an existing diagram.
  - `title` string, nullable — Diagram title
  - `description` string, nullable — Original user description
  - `mermaid_code` string, nullable — Generated Mermaid syntax
  - `diagram_type` 'flowchart' | 'sequence' | 'mindmap', nullable — Type of diagram (flowchart, sequence, or mindmap)
  - `diagram_json` object, nullable — Complete diagram state: nodes, edges, layoutDirection, positions, customizations

## Response `200`

Successful Response

- DiagramResponse — Response model for diagram data.
  - `id` integer, required — Diagram ID
  - `user_id` integer, required — User ID who created the diagram
  - `title` string, required — Diagram title
  - `description` string, nullable — Original user description
  - `mermaid_code` string, required — Mermaid diagram syntax
  - `diagram_type` string — Type of diagram (flowchart, sequence, or mindmap)
  - `diagram_json` object, required — Complete diagram state: nodes, edges, layoutDirection, positions, customizations
  - `created_at` string, required — Creation timestamp (ISO format)
  - `updated_at` string, required — Last update timestamp (ISO format)

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/makeaviz/apis/text-to-diagram-api.md) · [All operations](https://skmtc.net/makeaviz/apis/text-to-diagram-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/makeaviz/text-to-diagram-api/revisions/b7c00f8d19a5/schema)
