Create a diagram in a file

Creates a new diagram element on the file's canvas.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

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 Params
string
required

ID of the file to add the diagram to

Body Params
string
enum
required

Type of diagram to create

Allowed:
string

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

Responses

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

Language
Credentials
Bearer
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json