| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
This endpoint creates a diagram from user-provided Eraser DSL (diagram-as-code).
Note: This endpoint does not use AI, it simply generates a diagram from the Eraser DSL (diagram-as-code) provided by the user. To learn more about the Eraser DSL, see our docs. If you are looking for the AI diagram endpoint, see here .
The diagram code must be placed in the code field of each element, with all line breaks and special characters properly escaped. The simplest way to prepare your Eraser DSL code is to open your browser's JavaScript console and run JSON.stringify(YOUR-ERASER-DSL).replaceAll('\\n', '\n'), then use the escaped output in your request.
curl --location 'https://app.eraser.io/api/render/elements' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
"theme": "dark",
"background": true,
"elements": [
{
"type": "diagram",
"diagramType": "sequence-diagram",
"code": "Client [icon: monitor, color: gray]\nServer [icon: server, color: blue]\nService [icon: tool, color: green]\n\nClient > Server: Data request\nactivate Server\nServer <> Service: Service request\n\nloop [label: until success, color: green] {\n Service > Service: Check availability\n}\n\nServer - Service: Data processing\nServer --> Client: Data response\ndeactivate Server"
}
]
}'
To render a freeform diagram, set diagramType to freeform-diagram and pass a freeformElements array instead of code:
curl --location 'https://app.eraser.io/api/render/elements' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer $YOUR-TOKEN-HERE' \
--data '{
"theme": "dark",
"elements": [
{
"type": "diagram",
"diagramType": "freeform-diagram",
"freeformElements": [
{ "id": "a", "tag": "Shape", "x": 0, "y": 0, "texts": [{ "text": "User Service" }] },
{ "id": "b", "tag": "Shape", "x": 300, "y": 0, "texts": [{ "text": "Payment Service" }] },
{ "id": "r1", "tag": "Relationship", "from": "a", "to": "b", "label": "calls" }
]
}
]
}'
An example response is:
{
"imageUrl": "https://IMAGE-SITE-URL/IMAGE-NAME.png",
"createEraserFileUrl": "https://ERASER-URL-TO-OPEN-DIAGRAM-IN-EDITOR"
}
Full documentation of the endpoint below:
400The request is missing the 'elements' parameter or validation failed
403Unauthorized
500Eraser was unable to generate a result
503Service temporarily unavailable. This may be the result of too many requests.