Skip to content
Connect an agent
Diagrams

Import source

Turn a file of another format into a diagram.

POST/v1/import

TL;DR

QuestionAnswer
What does it do?Turn a file of another format into a diagram.
Which tool does the same?import_source
What does it take?A JSON body of type ImportSourceInput.
What does it return?Status 200 with a body of type ImportSourceResponse.
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 the text of a file and its format: SQL DDL, Prisma, or Drizzle becomes a schema; an OpenAPI 3 document becomes a matrix of who may call each endpoint, or one operation as a sequence; Terraform, Bicep, an ARM template, Pulumi, CloudFormation, the AWS CDK, Docker Compose, Kubernetes manifests, Helm, Kustomize, a Backstage catalog, AsyncAPI documents, or a GitHub Actions, GitLab CI/CD, or Azure Pipelines pipeline becomes a flow with icons and frames; a Structurizr workspace becomes a C4 diagram of one view; CSV or JSON data becomes the chart its shape suits; tree output or a list of paths becomes a tree; a git log becomes a git graph or a timeline. Answers with the Plotwork source, a diagnostic for everything left out with its line and column in the file, the validation, and an outline. A file that cannot be read is a normal 200 result with ok false. It runs no code and fetches nothing, and the text is not stored.

Request body

The body has the type ImportSourceInput.

FieldTypeRequiredDescription
format"sql" | "prisma" | "drizzle" | "openapi" | "terraform" | "terraform-plan" | "bicep" | "arm" | "pulumi" | "cloudformation" | "cdk" | "compose" | "kubernetes" | "helm" | "kustomize" | "backstage" | "structurizr" | "asyncapi" | "github-actions" | "gitlab-ci" | "azure-pipelines" | "csv" | "json" | "tree" | "git-log"yesWhat the text is; get_diagram_syntax with topic import-formats describes each.
textstringnoThe file content, as text. Send text or files, not both.
filesobject[]noThe files of a folder, for a format that spans files; the others read the first.
files[].pathstringyesThe file path, such as infra/network.tf; diagnostics name it. at least 1 character; at most 300 characters.
files[].textstringyesThe file content, as text.
titlestringnoThe diagram title; taken from the file when left out. at most 200 characters.
partsPageintegernoWhich page of parts to return when a split import has more than 24 diagrams: 1 (default) is the first 24. minimum 1; maximum 100000.
optionsobjectnodefault {}.
options.view"endpoints" | "map" | "sequence" | "git" | "timeline" | "context" | "container" | "component"noThe picture of a format drawn several ways.
options.operationIdstringnoopenapi sequence: the operation. at most 200 characters.
options.chart"auto" | "xychart" | "pie" | "sankey" | "treemap" | "matrix"nocsv, json: the chart; auto picks.
options.tablesstring[]noTables to draw, by name or prefix*.
options.pathsstring[]noopenapi: path prefixes to read.
options.tagsstring[]noopenapi: tags to read.
options.varFilesstring[]noVariables files to apply.
options.groupBy"module" | "network" | "file" | "owner"noHow things are framed; module is the default.
options.rootstringnoThe root, stack, or template of several to draw. at most 300 characters.

Responses

StatusMeaningBody
200The imported source, its diagnostics, its check, and its outline.ImportSourceResponse
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 ImportSourceResponse.

FieldTypeRequiredDescription
okbooleanyesTrue when source is valid Plotwork source. False means nothing was imported and source is empty: read diagnostics.
kindstring | nullyesThe kind of diagram the file became, or null when nothing was imported.
formatstringyesThe format the text was read as.
sourcestringyesThe Plotwork source, or an empty string when nothing could be imported.
diagnosticsDiagnostic[]yesEverything left out, changed, or wrong, with a hint. Codes start with I and point into the text you sent: I1xx errors stopped the import, I2xx warnings did not.
diagnostics[].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.
diagnostics[].severity"error" | "warning"yesErrors stop rendering; warnings never do.
diagnostics[].messagestringyesWhat is wrong, in one sentence.
diagnostics[].lineintegeryes1-based line in the submitted source. minimum 1.
diagnostics[].columnintegeryes1-based column in that line. minimum 1.
diagnostics[].lengthintegeryesNumber of characters the problem covers. minimum 1.
diagnostics[].hintstring | nullyesA concrete suggestion for fixing it, or null.
statsobjectyes
stats.itemsintegeryesBoxes, tables, rows, slices, places, entries, or commits written.
stats.linksintegeryesArrows, relations, messages, flows, or merges written.
stats.groupsintegeryesFrames, sections, or folders written.
stats.droppedintegeryesThings in the file left out by a cap or because the picture has no place for them; each is in diagnostics.
coverageobject | nullyesHow much of the file the picture shows; null when nothing was imported. When complete is false, the picture is not the whole file: say so.
coverage.nounstringyesWhat was counted, such as resources, services, tables, or endpoints.
coverage.totalintegeryesEverything of that kind in the file.
coverage.drawnintegeryesDrawn as a box, frame, table, row, or entry of its own.
coverage.summarisedintegeryesNot drawn on their own but counted on the box they belong to, such as "3 role assignments".
coverage.omittedintegeryesNot in the picture at all; the diagnostics say which and why.
coverage.completebooleanyesTrue when nothing was omitted.
coverage.linestringyesThe coverage in one sentence, such as "Drawn 12 of 85 resources; 60 are counted on the boxes they belong to and 13 are left out.".
validationobject | nullyesThe Plotwork validator run on source; null when nothing was imported.
validation.validbooleanyesTrue when the source has no Plotwork errors. It always is when ok is true.
validation.errorsDiagnostic[]yesPlotwork errors. Lines and columns point into source.
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.warningsDiagnostic[]yesPlotwork quality warnings, with the exact fix in each hint. Lines and columns point into source.
validation.warnings[].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.warnings[].severity"error" | "warning"yesErrors stop rendering; warnings never do.
validation.warnings[].messagestringyesWhat is wrong, in one sentence.
validation.warnings[].lineintegeryes1-based line in the submitted source. minimum 1.
validation.warnings[].columnintegeryes1-based column in that line. minimum 1.
validation.warnings[].lengthintegeryesNumber of characters the problem covers. minimum 1.
validation.warnings[].hintstring | nullyesA concrete suggestion for fixing it, or null.
validation.summarystring | nullyesOne-line description of the diagram, usable as alt text.
validation.sizeobject | nullyesNatural size of the laid-out diagram.
validation.size.widthintegeryesWidth in px. minimum 1.
validation.size.heightintegeryesHeight in px. minimum 1.
partsobject[]yesWhen the file is too big for one readable picture, the diagrams it was split into, in order, at most 24 a page; source is the first diagram of all. Show or draw each of them. Empty when the import is one diagram.
parts[].titlestringyesWhat this diagram shows, such as one resource group or one tag of an API.
parts[].kindstringyesThe kind of diagram.
parts[].sourcestringyesThe Plotwork source of this diagram; draw it with draw_diagram.
parts[].itemsintegeryesThe boxes, rows, or entries it draws.
parts[].validbooleanyesTrue when the source has no Plotwork errors.
parts[].warningsDiagnostic[]yesPlotwork quality warnings of this diagram. Lines and columns point into its source.
parts[].warnings[].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.
parts[].warnings[].severity"error" | "warning"yesErrors stop rendering; warnings never do.
parts[].warnings[].messagestringyesWhat is wrong, in one sentence.
parts[].warnings[].lineintegeryes1-based line in the submitted source. minimum 1.
parts[].warnings[].columnintegeryes1-based column in that line. minimum 1.
parts[].warnings[].lengthintegeryesNumber of characters the problem covers. minimum 1.
parts[].warnings[].hintstring | nullyesA concrete suggestion for fixing it, or null.
partsTotalintegeryesHow many diagrams the import was split into in all; 0 when it is one diagram.
partsPageintegeryesThe page of parts this answer holds, from 1.
partsPagesintegeryesHow many pages of parts there are; call again with partsPage for the next one.
outlinestring[]yesThe diagram as plain text, to check it says what the file says; empty when nothing was imported.
outlineTruncatedbooleanyesTrue when the outline was cut short at its summary length.
viewUrlstringnoA link that shows a valid diagram in a browser; give it to the person who wants to look. The source is in the part after #, never sent to a server, but anyone with the link can read it. Absent when too long; next says so.
pngUrlstringnoThe viewUrl with &download=png: opening it in a browser saves the diagram as a PNG for Slack, email, or a wiki. The PNG is drawn in the person's browser, not on a server, so it is a link to open, not an image address to embed. Absent when too long.
svgUrlstringnoThe viewUrl with &download=svg: a person opens it to download the SVG. Not a file address for curl; use saveCommand. Absent when too long.
saveCommandstringnoRun in a shell to save the SVG into the repository: the CLI decodes the link locally, fetches nothing, and embeds the source. Set --out to the path; add --theme dark for dark. Absent when too long.
nextstringyesThe next step in one sentence.

See also

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