# TML

> For the complete documentation index, see [llms.txt](https://developers.thoughtspot.com/docs/llms.txt)

Source: https://developers.thoughtspot.com/docs/tml

# TML

ThoughtSpot Modeling Language (TML) is a scriptable format developed by ThoughtSpot for exporting, modifying, and migrating metadata objects such as Models, Views, Tables, Liveboards, and Answers. TML files allow you to manage and version control these objects outside the ThoughtSpot UI, supporting workflows like bulk changes, migration between environments, and programmatic edits via REST API. Users can use [TML](https://docs.thoughtspot.com/cloud/latest/tml) to model data and build analytics content in the test environment in a flat-file format, and then import and deploy it in their environments.

## Structure of a TML file

To work with TML files for Models, views, SQL views, tables, Answers, Liveboards, and Monitor alerts in ThoughtSpot, you can download these objects as a flat file in `.TML` format, modify, and subsequently upload the TMLs either to the same or a different cluster.

The TML syntax varies per object type. However, all TMLs follow a general pattern that allows programmatic edits. ThoughtSpot offers a lot of flexibility within its set of [data objects]({{navprefix}}/{{intro-thoughtspot-objects}}), and there is no particular hierarchy to TML files, but rather just some rules.

See the following pages for the detailed syntax of TML files for each object type:  

-   [TML for Answers](https://docs.thoughtspot.com/cloud/latest/tml-answers)  
    
-   [TML for Collections](https://docs.thoughtspot.com/cloud/latest/tml-collections)  
    
-   [TML for Connections](https://docs.thoughtspot.com/cloud/latest/tml-connections)  
    
-   [TML for Joins](https://docs.thoughtspot.com/cloud/latest/tml-joins)  
    
-   [TML for Liveboards](https://docs.thoughtspot.com/cloud/latest/tml-liveboards)  
    
-   [TML for Monitor Alerts](https://docs.thoughtspot.com/cloud/latest/tml-alerts)  
    
-   [TML for SQL Views](https://docs.thoughtspot.com/cloud/latest/tml-sql-views)  
    
-   [TML for Tables](https://docs.thoughtspot.com/cloud/latest/tml-tables)  
    
-   [TML for Views](https://docs.thoughtspot.com/cloud/latest/tml-views)  
    
-   [TML for Models](https://docs.thoughtspot.com/cloud/latest/tml-models)  
    

For TML modification tips and recommendations, see [TML modification]({{navprefix}}/{{modify-tml}}).

## TML import and export via REST API

The TML API endpoints allow you to programmatically export, validate, and import scriptable TML files. You can use these API endpoints to automate the change management and deployment processes between your development and production environments. With TML API, you can easily migrate your ThoughtSpot content from one environment to another by automating the entire change management process and thereby reducing the risk of human error.

-   [Import TML]({{navprefix}}/{{tml-import}})
    
-   [Export TML]({{navprefix}}/{{tml-export}})
    

## TML modification

Visit this page for detailed information on [TML modification]({{navprefix}}/{{modify-tml}}).

## Limitations of working with TML files

There are certain limitations to the changes you can apply by editing a ThoughtSpot object through TML. Visit [Limitations of working with TML files](https://docs.thoughtspot.com/cloud/latest/tml#_limitations_of_working_with_tml_files) for detailed information.

### YAML reimport in REST API v2 Playground

If you are using the REST API Playground to import TML in YAML format, note that copying YAML content directly in the input field will likely result in the `Invalid YAML/JSON syntax in file` error. When you copy the YAML output from the export TML API response in the Playground, the copied content is wrapped in quotation marks and include escaped newline characters (`\n`). When you paste this content directly in the `metadata_tml` input field, the API Playground double-escapes characters or removes necessary newline (`\n`) characters. Due to improper formatting, the YAML input becomes invalid for import, resulting in the `Invalid YAML/JSON syntax in file` error.

To work around this issue, follow these steps:

1.  After you [export TML]({{navprefix}}/restV2-playground?apiResourceId=http%2Fapi-endpoints%2Fmetadata%2Fexport-metadata-tml) in the Playground, use the `copy to clipboard` option to copy the YAML output from the API response as shown in this video.
    
    Your browser does not support the video tag.
    
    The output copied from the API response is enclosed in quotation marks (`"`). For example, `"guid: a162289a-c1ab-427e-9985-8fb5f7c7e539\nliveboard:\n name: Liveboard 1\n"`.
    
2.  Paste the YAML output copied from the export TML API response into a text editor.
    
3.  Remove the quotation marks, update the TML, and ensure that the YAML is properly formatted:  
    `guid: a162289a-c1ab-427e-9985-8fb5f7c7e539\nliveboard:\n name: Liveboard 1\n`
    
4.  When [importing TML in the Playground]({{navprefix}}/restV2-playground?apiResourceId=http%2Fapi-endpoints%2Fmetadata%2Fimport-metadata-tml), do not paste the YAML directly into the `metadata_tmls` input field. Instead, use the JSON editor to add the YAML.
    
5.  To open the JSON editor, click **View JSON**.  
    In the JSON preview, you’ll see the following code:
    
    ```JSON
    {
      "metadata_tmls": [
        "metadata_tmls3",
        "metadata_tmls5",
      ],
      "import_policy": "PARTIAL",
      "create_new": false,
      "all_orgs_context": false
    }
    ```
    
6.  Remove the text in the `metadata_tmls` array and paste your YAML content inside the array. If you are importing more than one TML, use a comma after pasting a TML YAML and then add YAML for the otehr TML.
    
    ```JSON
    {
      "metadata_tmls": [
        "guid: a162289a-c1ab-427e-9985-8fb5f7c7e539\nliveboard:\n  name: Liveboard 1\n"
      ],
      "import_policy": "PARTIAL",
      "create_new": false,
      "all_orgs_context": false
    }
    ```
    
    You may see double-escaped characters in JSON preview. For example, `\\n` instead `\n`. However, these will not be imported in the actual payload.
    
7.  To submit the request, click **Try it Out**.
    
    In the following video, you can see that pasting YAML directly in the `metadata_tmls` form field results in an error due to additional quotation marks and improper formatting. Using the JSON editor, you can paste the YAML inside the array and import TML successfully.
    
    Your browser does not support the video tag.
    

## Deployment and version control of TML objects

For information about version control and TML deployment, see the following pages:

-   [Git integration and version control]({{navprefix}}/{{version_control}})
    
-   [TML files from development to testing and production environments]({{navprefix}}/{{development-and-deployment}})