Docs
Schedule demo Open app

Create a diagram in a file

POST https://app.eraser.io/api/files/{fileId}/diagrams

Example request

curl --location 'https://app.eraser.io/api/files/abc123/diagrams' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "diagramType": "flowchart-diagram",
    "code": "Start > End"
}'

Example response

{
  "id": "diag2",
  "diagramUrl": "https://app.eraser.io/workspace/abc123?diagram=diag2&layout=canvas",
  "diagramType": "flowchart-diagram",
  "code": "Start > End",
  "updatedAt": "2025-07-15T09:30:00.000Z"
}

Path parameters

fileId string requiredpath

ID of the file to add the diagram to

Request body

diagramType string required

Type of diagram to create

  • sequence-diagram
  • entity-relationship-diagram
  • cloud-architecture-diagram
  • flowchart-diagram
  • bpmn-diagram
code string

Eraser DSL code for the diagram. If omitted, creates an empty diagram.

Responses

200 – The created diagram

id string required

Unique identifier for the diagram

diagramUrl string required

URL to view the diagram in the Eraser canvas

diagramType string required

Type of the diagram

  • sequence-diagram
  • entity-relationship-diagram
  • cloud-architecture-diagram
  • flowchart-diagram
  • bpmn-diagram
code string required

Eraser DSL code for the diagram

updatedAt string required

ISO 8601 timestamp of when the diagram was last updated

200 response
{
  "id": "string",
  "diagramUrl": "https://app.eraser.io/workspace/abc123?diagram=def456&layout=canvas",
  "diagramType": "sequence-diagram",
  "code": "string",
  "updatedAt": "2026-01-01T00:00:00Z"
}

400 – Invalid file ID or missing diagramType

401 – Missing or invalid bearer token

403 – Unauthorized

404 – File not found (or file is private, archived, a template, or belongs to a different team)

500 – Internal server error