Skip to content
Connect an agent
Diagrams

Read diagram

Read the source back out of a Plotwork SVG.

POST/v1/diagrams/read

TL;DR

QuestionAnswer
What does it do?Read the source back out of a Plotwork SVG.
Which tool does the same?read_diagram
What does it take?A JSON body of type ReadDiagramInput.
What does it return?Status 200 with a body of type ReadDiagramResponse.
What can go wrong?400 the body failed schema validation, or sent both of svg and url or neither; 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

Send the text of a Plotwork SVG or the link of a hosted one (cdn.plotwork.dev only). Returns the exact source the picture was drawn from, its kind, the stored diagram id, and a check of the source. A picture made without embedSource has no source: the answer says so (status no-source) and returns its title, outline, and labels. Problems with the text or the link are answers, not errors.

Request body

The body has the type ReadDiagramInput.

FieldTypeRequiredDescription
svgstringnoThe text of a Plotwork SVG: the content of an .svg file in the repository. Send this or url, not both. at least 1 character; at most 1000000 characters.
urlstringnoThe link of a hosted Plotwork picture, https://cdn.plotwork.dev/d/ (opens in a new tab)<22 characters>.svg. Only Plotwork's own picture hosts are fetched. Send this or svg, not both. at least 1 character; at most 200 characters.

Responses

StatusMeaningBody
200The source, or why there is none.ReadDiagramResponse
400The body failed schema validation, or sent both of svg and url or neither.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 ReadDiagramResponse.

FieldTypeRequiredDescription
status"read" | "no-source" | "damaged" | "not-a-picture" | "refused" | "unreachable"yesread: the source was found. no-source: the picture carries none. damaged: it carries one that cannot be read back. not-a-picture: the text is not an SVG. refused: the link is not one this tool fetches. unreachable: the link could not be fetched.
hasSourcebooleanyesTrue when source is set.
sourcestring | nullyesThe exact source the picture was drawn from, ready to edit and send to draw_diagram; null when there is none.
kindstring | nullyesThe diagram kind of the source, or null.
idstring | nullyesThe id of the stored diagram when the picture was published (data-plotwork-id), or null.
from"text" | "url"yesWhere the picture came from: the text that was sent, or the link that was fetched.
validationobject | nullyesThe check of the source, or null when there is none. It parses the source; draw_diagram also lays it out and returns warnings.
validation.validbooleanyesTrue when the source has no errors.
validation.errorsDiagnostic[]yesEvery error, each with line, column, and a hint; empty when valid.
validation.errors[].code"E100" | "E101" | "E110" | "E111" | "E120" | "E121" | "E122" | "E123" | "E124" | "E125" | "E130" | "E131" | "E132" | "E133" | "E134" | "E135" | "E136" | "E137" | "E138" | "E139" | "E140" | "W200" | "W201" | "W202" | "W203" | "W204" | "W205" | "W206" | "W207" | "W500" | "M100" | "M101" | "M102" | "M103" | "M104" | "M110" | "M200" | "M201" | "M202" | "M203" | "M204" | "M205" | "M206" | "M207" | "M208" | "M209" | "M210" | "M211" | "M212" | "M213" | "M214" | "M215" | "M216" | "M217" | "M218" | "E300" | "E301" | "E302" | "E303" | "E304" | "W300" | "W301" | "W302" | "W303" | "M120" | "M220" | "M221" | "M222" | "E340" | "E341" | "E342" | "E343" | "E344" | "E345" | "W320" | "W321" | "W322" | "W323" | "M240" | "M241" | "M242" | "E360" | "E361" | "E362" | "E363" | "E364" | "E365" | "E366" | "E367" | "W330" | "W331" | "W332" | "W333" | "W334" | "M250" | "M251" | "E400" | "E401" | "E402" | "E403" | "W350" | "W351" | "W352" | "W353" | "M270" | "M271" | "E420" | "E421" | "E422" | "E423" | "E424" | "W360" | "W361" | "W362" | "W363" | "W364" | "M180" | "M280" | "M281" | "M282" | "E320" | "E321" | "E322" | "E323" | "E324" | "E325" | "E326" | "E327" | "E328" | "E329" | "E330" | "W310" | "W311" | "W312" | "W313" | "W314" | "M130" | "M131" | "M132" | "M230" | "M231" | "M232" | "M233" | "M234" | "M235" | "M236" | "M237" | "M238" | "E380" | "E381" | "E382" | "E383" | "W340" | "W341" | "W342" | "W343" | "M260" | "I100" | "I101" | "I102" | "I103" | "I104" | "I105" | "I200" | "I201" | "I202" | "I203" | "I204" | "I206" | "R100" | "R101" | "R200" | "R201" | "R202" | "R203" | "R204" | "R205" | "R206" | "R207" | "S100" | "S200" | "S101" | "S102" | "S103" | "S104" | "S201" | "S202" | "S203"yesStable code to branch on; E-codes are errors, W-codes are warnings.
validation.errors[].severity"error" | "warning"yesErrors stop rendering; warnings never do.
validation.errors[].messagestringyesWhat is wrong, in one sentence.
validation.errors[].lineintegeryes1-based line in the submitted source. minimum 1.
validation.errors[].columnintegeryes1-based column in that line. minimum 1.
validation.errors[].lengthintegeryesNumber of characters the problem covers. minimum 1.
validation.errors[].hintstring | nullyesA concrete suggestion for fixing it, or null.
validation.summarystring | nullyesOne-line description of the diagram, or null when invalid.
pictureobject | nullyesWhat the picture says about itself, or null when the text is not an SVG.
picture.titlestring | nullyesThe diagram title, or null.
picture.summarystring | nullyesThe one-line summary the picture carries, or null.
picture.themestring | nullyesThe color scheme it was drawn in, or null.
picture.sizeobject | nullyesIts size in px, or null.
picture.size.widthintegeryesWidth in px. minimum 1.
picture.size.heightintegeryesHeight in px. minimum 1.
picture.outlinestring[]yesThe plain-language outline the picture carries, one entry for each line. Empty when the source was read: the source says more.
picture.labelsstring[]yesThe text painted on the picture, each distinct label once, in painted order. Empty when the source was read.
messagestringyesWhat happened, in one sentence.
nextstringyesThe next step in one sentence.

See also

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