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 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.
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 link to it, which expires after 1 hour by default; see `urlSettings`.
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".
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).
urlSettings object 2 fieldsaccess string required"public" returns a permanent link. "token" returns a link that expires after `ttl`. Teams and organizations can turn off public links.
publictoken
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.
pngjpegdrawio
url string URL of the stored export.
{
"format": "png",
"url": "string"
}