Skip to content
Connect an agent

Diagrams

Embed diagram

Write a snippet that shows a picture with the viewer.

POST/v1/diagrams/embed

TL;DR

QuestionAnswer
What does it do?Write a snippet that shows a picture with the viewer.
Which tool does the same?embed_diagram
What does it take?A JSON body of type EmbedDiagramInput.
What does it return?Status 200 with a body of type EmbedDiagramResponse.
What can go wrong?400 the body failed schema validation; 401 the API key is missing or not valid; 403 the account is on the Free plan, which does not include the REST drawing and checking routes (plan.rest_not_included); 413 the body is larger than the size cap; 429 too many requests. Every failure uses the one error envelope.

What it does

Takes a hosted link (/d/, a stable link /l/, or an organisation embed link /o/), the text of a Plotwork SVG a site serves, or both, and answers with the line that installs @plotwork.official/viewer and an HTML or React snippet that shows the picture. live is kept for a stable or organisation embed link, and pin adds the SHA-256 fingerprint of the SVG text; a choice that cannot apply is left out and said in notes. A link that is not a hosted picture is a 200 answer with ok false and a hint. Nothing is fetched or laid out.

Request body

The body has the type EmbedDiagramInput.

FieldTypeRequiredDescription
urlstringnoA hosted picture (/d/), stable link (/l/) or organisation embed link (/o/) on cdn.plotwork.dev. Never fetched. at least 1 character; at most 200 characters.
svgstringnoThe text of a Plotwork SVG; needed to pin. at least 1 character; at most 1000000 characters.
pathstringnoWhere the page serves svg from, when there is no url. at least 1 character; at most 500 characters.
format"html" | "react"nohtml for any page, react for React. default "html".
livebooleannoFollow new versions: /l/ and /o/ links only. default false.
pinbooleannoShow only exactly this picture: needs svg. default false.
labelstringnoWhat the diagram shows, for a screen reader. at most 200 characters.

Responses

StatusMeaningBody
200The snippet, the install line, the fingerprint and the notes.EmbedDiagramResponse
400The body failed schema validation.ErrorResponse
401The API key is missing or not valid.ErrorResponse
403The account is on the Free plan, which does not include the REST drawing and checking routes (plan.rest_not_included).ErrorResponse
413The body is larger than the size cap.ErrorResponse
429Too many requests.ErrorResponse

Response body

A 200 answer has the type EmbedDiagramResponse.

FieldTypeRequiredDescription
okbooleanyesFalse when the url is not a hosted picture or the svg is not an SVG; message and hint say why.
snippetstring | nullyesThe code to paste into the page or component, or null when ok is false.
installstringyesThe command that installs the viewer.
srcstring | nullyesThe address the snippet loads the picture from.
linkKind"picture" | "stable" | "organisation" | nullyespicture (/d/), stable (/l/), organisation (/o/), or null for a file the page serves.
fingerprintstring | nullyessha256- of the svg text, whether or not the snippet pins it; null without svg.
livebooleanyesTrue when the snippet carries live.
pinnedbooleanyesTrue when the snippet carries fingerprint.
notesstring[]yesEach choice left out and why, and what to know about the link.
messagestringyesWhat happened, in one sentence.
hintstring | nullyesWhat to send instead, when ok is false.

See also

DocWhy
API referenceEvery endpoint, and the error envelope
SchemasEvery request and response type
embed_diagramThe same operation as an MCP tool
Tool referenceThe operations as callable tools