Docs
Schedule demo Open app

Export a diagram

POST https://app.eraser.io/api/export/diagram

Export a diagram that is already stored in an Eraser file, in the formats of the app's Export menu: PNG, JPEG or SVG images, or draw.io, Visio, PowerPoint, BPMN or PDF files. Google Slides export is only in the app.

By default the export is the response body, with the format's Content-Type and a <diagramId>.<extension> download name, and nothing is stored. Pass returnAs: "url" to store the export instead and get back { format, url }. The link expires after 1 hour by default; see urlSettings.

The file must belong to the token's team (for an organization token, to any team in its organization) and must not be archived or private.

Formats

format Plan Diagram types File Content-Type
png (default) Any Any .png image/png
jpeg Any Any .jpeg image/jpeg
svg Any Any .svg image/svg+xml
bpmn Any BPMN .bpmn application/xml
drawio Paid Any .drawio application/xml
visio Paid Cloud architecture, flowchart, freeform, BPMN .vsdx application/vnd.ms-visio.drawing
powerpoint Paid Any .pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
pdf Paid Any .pdf application/pdf
  • A paid format on a free plan returns 402. visio and bpmn return 400 for other diagram types, naming the diagram's type.
  • imageQuality applies to PNG and JPEG; background to PNG, JPEG and SVG.
  • pdf prints the one diagram the way Export → PDF prints a selection in the app. A PDF of the whole canvas exports only from the app.

Example requests

Save the diagram to a PNG file:

curl --location 'https://app.eraser.io/api/export/diagram' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--output diagram.png \
--data '{
    "fileId": "abc123",
    "diagramId": "def456"
}'

Save the diagram as SVG with a solid background:

curl --location 'https://app.eraser.io/api/export/diagram' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--output diagram.svg \
--data '{
    "fileId": "abc123",
    "diagramId": "def456",
    "format": "svg",
    "background": true
}'

Export as draw.io on a dark background:

curl --location 'https://app.eraser.io/api/export/diagram' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--output diagram.drawio \
--data '{
    "fileId": "abc123",
    "diagramId": "def456",
    "format": "drawio",
    "theme": "dark"
}'

Store the export and get a link back:

curl --location 'https://app.eraser.io/api/export/diagram' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
    "fileId": "abc123",
    "diagramId": "def456",
    "imageQuality": 3,
    "returnAs": "url"
}'

Example response

With returnAs: "url":

{
  "format": "png",
  "url": "https://IMAGE-SITE-URL/IMAGE-NAME.png"
}

Request body

fileId string required

ID of the file that holds the diagram.

diagramId string required

ID of the diagram to export. List the diagrams in a file with `GET /api/files/{fileId}/diagrams`.

format string

Export format. Defaults to "png". "drawio", "visio", "powerpoint" and "pdf" need a paid plan. "visio" supports cloud architecture, flowchart, freeform and BPMN diagrams; "bpmn" supports BPMN diagrams only.

  • png
  • jpeg
  • svg
  • drawio
  • visio
  • powerpoint
  • bpmn
  • pdf
returnAs string

"file" (default) returns the export as the response body, named `<diagramId>.<extension>`, and stores nothing. "url" stores the export and returns a link to it, which expires after 1 hour by default; see `urlSettings`.

  • file
  • url
theme string

Select "light" or "dark" theme. Defaults to "light". Ignored when `format` is "pdf".

  • light
  • dark
imageQuality integer

Image quality/resolution multiplier. Use 1 (low), 2 (medium), or 3 (high). Defaults to 2. Applies to "png" and "jpeg" only.

  • 1
  • 2
  • 3
background boolean

Select transparent (false) or solid (true) background. Defaults to false. Applies to "png", "jpeg" and "svg" only.

urlSettings object 2 fields

Controls the link returned when `returnAs` is "url". By default it is an expiring link (1 hour, unless your team or organization sets another default).

access string required

"public" returns a permanent link. "token" returns a link that expires after `ttl`. Teams and organizations can turn off public links.

  • public
  • token
ttl integer | string

Only with `access: "token"`. Seconds (e.g. 3600) or a duration such as "6h", "5d" or "2w", up to 365d.

Responses

200 – The exported diagram

format string

The format the diagram was exported in.

  • png
  • jpeg
  • svg
  • drawio
  • visio
  • powerpoint
  • bpmn
  • pdf
url string

URL of the stored export.

200 response
{
  "format": "png",
  "url": "string"
}

400 – The request is missing required parameters, validation failed, or the format does not support the diagram's type (`visio`, `bpmn`)

402 – The format needs a paid plan (`drawio`, `visio`, `powerpoint`, `pdf`)

403 – Unauthorized

404 – The file or diagram was not found, or the diagram has no renderable elements

500 – Eraser was unable to generate a result

503 – Service temporarily unavailable. This may be the result of too many requests.