post https://app.eraser.io/api/render/elements
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 .
An example cURL request is like the below. The diagram code must be placed in the text field, 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``)
, 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",
"text": "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"
}
]
}'
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: