Export a diagram
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 requiredID of the file that holds the diagram.
diagramId string requiredID of the diagram to export. List the diagrams in a file with `GET /api/files/{fileId}/diagrams`.
format string Export format. Defaults to "png".
pngjpegdrawio
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.
fileurl
theme string Select "light" or "dark" theme. Defaults to "light".
lightdark
imageQuality integer Image quality/resolution multiplier. Use 1 (low), 2 (medium), or 3 (high). Defaults to 2. Ignored when `format` is "drawio".
123
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.
pngjpegdrawio
url string Public URL of the stored export.
{
"format": "png",
"url": "string"
}