diagrams

Render diagram code to svg, png or pdf

Renders the diagram code with Mermaid. By default the response body is the rendered bytes with the format's content type, for writing straight to disk; when the Accept header names application/json the body is an envelope with the same bytes as base64 and the metadata the headers carry, for an LLM tool call. Every answer that reached the Mermaid config, rendered or failed, carries x-mermaid-version and x-render-cache (hit when the render cache served it, miss when it was consulted, bypass when cache is false or the cache is disabled for the key); a rendered one x-diagram-type too. A request refused before that, for its key, a limit, or a body too large, not JSON or not the schema, carries neither. Invalid diagram code is 400 with the error object validate returns, position included, so one handler covers both endpoints; the effective config is not echoed. Costs 1 API credit (call class basic).

post/v1/render

Request

  • Base URL: https://api.mermaid.ai
  • URL: https://api.mermaid.ai/v1/render
  • Auth: HTTP bearer

Request body

codestring required

Diagram code

format'svg' | 'png' | 'pdf' required

Output format

cacheboolean

false: this render is neither served from nor stored in the render cache; the cache is also off for a key when a super admin disabled it, whatever this says

Response

The rendered diagram: the bytes with the content type of the format, or the JSON envelope when the request accepts application/json.

format'svg' | 'png' | 'pdf' required
contentTypestring required

Content type of the decoded content

contentstring base64 required

The rendered bytes, base64

diagramTypestring required

The detected diagram type

mermaidVersionstring required

The Mermaid version that rendered it

requestIdstring required

The request id, as in the x-request-id header

cacheStatus'hit' | 'miss' | 'bypass' required

Whether the render cache served it, as in x-render-cache

Changes

No recorded changes to this operation across all 1 revision of this API.