Docs
Schedule demo Open app

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-access
  • anyone-with-link-can-edit
  • publicly-viewable
  • publicly-editable
  • sso-readable
  • sso-editable
elements object[] 7 fields

Canvas elements to add to the file (diagrams, shapes, etc.)

type string required

Type of the element (e.g., "diagram", "rectangle", "ellipse")

diagramType string

Type of diagram. Required when `type` is "diagram".

  • sequence-diagram
  • entity-relationship-diagram
  • cloud-architecture-diagram
  • flowchart-diagram
  • bpmn-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

Responses

200 – The created file with its content

400 – Invalid request body

401 – Missing or invalid bearer token

403 – Unauthorized

500 – Internal server error