Create a file
POST
https://app.eraser.io/api/files Example request
curl --location 'https://app.eraser.io/api/files' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
"title": "My File",
"document": "# Hello\n\nThis is a test."
}' An example request with diagram elements:
curl --location 'https://app.eraser.io/api/files' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
"title": "Diagram File",
"elements": [
{
"type": "diagram",
"diagramType": "sequence-diagram",
"code": "A > B: Hello"
}
]
}' Example response
{
"id": "abc123",
"fileUrl": "https://app.eraser.io/workspace/abc123",
"title": "My File",
"author": "api",
"folderId": null,
"createdAt": "2025-07-15T09:30:00.000Z",
"updatedAt": "2025-07-15T09:30:00.000Z",
"linkAccess": "no-link-access",
"content": {
"elements": [],
"document": "# Hello\n\nThis is a test."
}
} Request body
title string Title of the file. Defaults to "Untitled".
folderId string ID of the folder to place the file in
document string Markdown content for the file's document. Supports diagram code blocks (e.g., ```sequence-diagram) which are converted to embedded diagrams.
linkAccess string Link access setting for the file. See https://docs.eraser.io/sharing-a-file for more information.
no-link-accessanyone-with-link-can-editpublicly-viewablepublicly-editablesso-readablesso-editable
elements object[] 7 fields Canvas elements to add to the file (diagrams, shapes, etc.)
elements object[] 7 fieldstype string requiredType of the element (e.g., "diagram", "rectangle", "ellipse")
diagramType string Type of diagram. Required when `type` is "diagram".
sequence-diagramentity-relationship-diagramcloud-architecture-diagramflowchart-diagrambpmn-diagram
code string Eraser DSL code for the diagram. Only applicable when `type` is "diagram".
x number X position on the canvas
y number Y position on the canvas
width number Width of the element
height number Height of the element