diagrams

Validate diagram code

Runs Mermaid's parser over the diagram code; nothing is rendered, so it is cheap enough for every iteration of a generation loop. The response is 200 whether the code is valid or not: valid, the detected diagram type, and on failure the standard error structure carrying the parser message with line and column where the parser provides them. An invalid diagram is the answer asked for, not a failure of the call, so a caller treating 4xx as failure never mistakes an answer for one. Parsing always runs at security level parseOnly. Costs 1 API credit (call class basic).

post/v1/validate

Request

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

Request body

codestring required

Diagram code

Response

The validation result, valid or not

validboolean required
diagramTypestring

The detected diagram type, when detectable

Changes

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