> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowengineering.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Convert a diagram XML document to a tldraw snapshot

> Accepts **either** format and auto-detects which one was sent:

- **draw.io** — raw `<mxGraphModel>`, inline `<mxfile>`, or compressed `<mxfile>`/.drawio. Mapping is best-effort: shapes without a tldraw equivalent fall back to rectangles, and colors are quantized to the closest of tldraw's 13 default colors. Only the first page is converted. Arrow waypoints and external images are dropped.
- **Flow's own `<diagram>` XML** — the output of `/convert/tldraw-to-xml`. `<entity>` becomes a data-shape card, `<group>` a frame, `<shape>` a geo shape, and `<connection>` a bound arrow. Connection endpoints resolve by id, falling back to the exported name for files produced before shapes carried ids; connections whose endpoints can't be resolved are dropped.

Returns a tldraw StoreSnapshot JSON that can be loaded directly into the diagram editor via `loadSnapshot(editor.store, snapshot)`.



## OpenAPI

````yaml /openapi/customer-api.json post /convert/drawio-to-tldraw
openapi: 3.0.0
info:
  contact: {}
  description: >-
    Flow customer API reference. Start with the [quickstart](/api/quickstart)
    and [authentication guide](/api/authentication).
  title: Customer API
  version: 1.0.0
servers:
  - description: Flow API
    url: https://backend.branch.flowengineering.com
security: []
tags:
  - name: Automations
  - name: Branches
  - name: Comments
  - name: Convert
  - name: Data Model
  - name: Diagrams
  - name: Entities
  - name: Files
  - name: Import
  - name: Notifications
  - name: Projects
  - name: ReqIF
  - name: ReqIF Import
  - name: Shared Access Grants
  - name: User Groups
  - name: Users
paths:
  /convert/drawio-to-tldraw:
    post:
      tags:
        - Convert
      summary: Convert a diagram XML document to a tldraw snapshot
      description: >-
        Accepts **either** format and auto-detects which one was sent:


        - **draw.io** — raw `<mxGraphModel>`, inline `<mxfile>`, or compressed
        `<mxfile>`/.drawio. Mapping is best-effort: shapes without a tldraw
        equivalent fall back to rectangles, and colors are quantized to the
        closest of tldraw's 13 default colors. Only the first page is converted.
        Arrow waypoints and external images are dropped.

        - **Flow's own `<diagram>` XML** — the output of
        `/convert/tldraw-to-xml`. `<entity>` becomes a data-shape card,
        `<group>` a frame, `<shape>` a geo shape, and `<connection>` a bound
        arrow. Connection endpoints resolve by id, falling back to the exported
        name for files produced before shapes carried ids; connections whose
        endpoints can't be resolved are dropped.


        Returns a tldraw StoreSnapshot JSON that can be loaded directly into the
        diagram editor via `loadSnapshot(editor.store, snapshot)`.
      operationId: ConvertController_convertDrawioToTldraw
      parameters:
        - description: Workspace identifier
          in: header
          name: customer
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DrawioToTldrawDto'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  snapshot:
                    properties:
                      schema:
                        type: object
                      store:
                        additionalProperties: true
                        type: object
                    type: object
                type: object
          description: >-
            tldraw StoreSnapshot — `{ store, schema }` consumable by
            loadSnapshot
      security:
        - api-key: []
        - bearer: []
components:
  schemas:
    DrawioToTldrawDto:
      properties:
        xml:
          description: >-
            Diagram XML in either supported format — the endpoint detects which:

            - draw.io: a raw <mxGraphModel>, an <mxfile> wrapper with an inline
            <mxGraphModel>, or an <mxfile> whose <diagram> body is the draw.io
            compressed form (base64 + raw-deflate + URI-encoded XML).

            - Flow: a <diagram> document as produced by /convert/tldraw-to-xml.
          type: string
      required:
        - xml
      type: object
  securitySchemes:
    api-key:
      in: header
      name: X-API-Key
      type: apiKey
    bearer:
      bearerFormat: JWT
      scheme: bearer
      type: http

````