> ## 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 tldraw snapshot to hierarchical XML

> Converts a tldraw `StoreSnapshot` into an XML document that encodes the diagram hierarchy. Parent-child relationships are derived from tldraw's native `parentId` system: shapes inside a `data-shape` or `frame` container appear as nested child elements in the XML.

Every non-arrow element also carries its geometry (`x`/`y` parent-local coordinates plus `w`/`h`) so spatially-laid-out diagrams (e.g. flowcharts) keep their positions, not just nested ones.

Shape mapping:
- `data-shape` → `<entity id name type x y w h>` (entity-backed node)
- `frame` → `<group name x y w h>`
- geo shapes → `<shape type label x y w h>`
- arrows → omitted from tree, captured in `<connections>` with their own label (e.g. a flowchart `Yes`/`No` branch)

The snapshot is the object returned by `editor.store.getStoreSnapshot()` or by the `/convert/drawio-to-tldraw` endpoint.



## OpenAPI

````yaml /openapi/customer-api.json post /convert/tldraw-to-xml
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/tldraw-to-xml:
    post:
      tags:
        - Convert
      summary: Convert a tldraw snapshot to hierarchical XML
      description: >-
        Converts a tldraw `StoreSnapshot` into an XML document that encodes the
        diagram hierarchy. Parent-child relationships are derived from tldraw's
        native `parentId` system: shapes inside a `data-shape` or `frame`
        container appear as nested child elements in the XML.


        Every non-arrow element also carries its geometry (`x`/`y` parent-local
        coordinates plus `w`/`h`) so spatially-laid-out diagrams (e.g.
        flowcharts) keep their positions, not just nested ones.


        Shape mapping:

        - `data-shape` → `<entity id name type x y w h>` (entity-backed node)

        - `frame` → `<group name x y w h>`

        - geo shapes → `<shape type label x y w h>`

        - arrows → omitted from tree, captured in `<connections>` with their own
        label (e.g. a flowchart `Yes`/`No` branch)


        The snapshot is the object returned by `editor.store.getStoreSnapshot()`
        or by the `/convert/drawio-to-tldraw` endpoint.
      operationId: ConvertController_tldrawToXml
      parameters:
        - description: Workspace identifier
          in: header
          name: customer
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TldrawSnapshotToXmlDto'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  xml:
                    type: string
                type: object
          description: Hierarchical XML string representing the diagram structure
      security:
        - api-key: []
        - bearer: []
components:
  schemas:
    TldrawSnapshotToXmlDto:
      properties:
        name:
          description: >-
            Optional diagram name used as the root <diagram name="...">
            attribute.
          type: string
        snapshot:
          additionalProperties: true
          description: >-
            A tldraw StoreSnapshot JSON object (`{ store, schema }`) as returned
            by `editor.store.getStoreSnapshot()` or the
            `/convert/drawio-to-tldraw` endpoint.
          type: object
      required:
        - snapshot
      type: object
  securitySchemes:
    api-key:
      in: header
      name: X-API-Key
      type: apiKey
    bearer:
      bearerFormat: JWT
      scheme: bearer
      type: http

````