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 as PNG, JPEG, or draw.io.

By default the export is the response body and nothing is stored. Pass returnAs: "url" to store the export instead and get back a public link to it. That link is unauthenticated and does not expire, so prefer the default when you only need the bytes.

The token's team must own the file, and the file must not be archived or private.

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"
}'

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 public 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".

  • png
  • jpeg
  • drawio
returnAs string

"file" (default) returns the export as the response body and stores nothing. "url" stores the export and returns a public link to it.

  • file
  • url
theme string

Select "light" or "dark" theme. Defaults to "light".

  • light
  • dark
imageQuality integer

Image quality/resolution multiplier. Use 1 (low), 2 (medium), or 3 (high). Defaults to 2. Ignored when `format` is "drawio".

  • 1
  • 2
  • 3
background boolean

Select transparent (false) or solid (true) background. Defaults to false. Ignored when `format` is "drawio".

Responses

200 – The exported diagram

format string

The format the diagram was exported in.

  • png
  • jpeg
  • drawio
url string

Public URL of the stored export.

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

400 – The request is missing required parameters or validation failed

402 – draw.io export is not enabled for this team

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.