# Metadata parameterization APIs

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

Source: https://developers.thoughtspot.com/docs/parameterize-metadata

# Metadata parameterization APIs

In ThoughtSpot, metadata parameterization refers to the process of assigning variables to certain properties and fields within metadata objects such as Connections and Tables. These variables can have different values assigned for each Org context, which are applied dynamically at runtime, rather than relying on hardcoded static values.

Metadata parameterization with variables allows administrators to reuse and propagate the same metadata object across various Orgs and environments within a ThoughtSpot instance while maintaining a consistent data structure of objects across Orgs.

## Before you begin

-   Ensure that [variables are available]({{navprefix}}/{{variables}}) on your instance. You can use the [variable search API]({{navprefix}}/{{variables}}#_get_details_of_variables) to get a list of variables.
    
-   Ensure that you have edit access to the Connections and Tables to which you want to assign variables.
    

## How to parameterize objects

You can update the properties of a Connection or Table to parameterize or remove parameterization by using one of the following options:

-   Use REST APIs  
    To parameterize the properties of a metadata object, send an [API request to the `/api/rest/2.0/metadata/parameterize-fields` endpoint]({{navprefix}}/{{metadata-parameterization}}#_parameterize_object_properties).  
    To remove parameterization, use the [the `/api/rest/2.0/metadata/unparameterize` API endpoint]({{navprefix}}/{{metadata-parameterization}}#_remove_parameterization).
    
-   Edit the TML representation of the object  
    You can edit the TML object directly and assign variables.  
    For example, to parameterize the properties of a Table, open the TML of the Table object in the edit mode and assign the variables to the properties as shown here:
    
    ```YAML
    table:
      name: Sales
      db: "${DATABASE}"
      schema: "${SCHEMA_VAR}"
      db_table: "${TABLE_VAR}"
    ```
    

## Parameterize object properties

To parameterize one or more properties of a metadata object, use `/api/rest/2.0/metadata/parameterize-fields` API endpoint.

> **NOTE:** The legacy endpoint /api/rest/2.0/metadata/parameterize is deprecated in 26.4.0.cl and later versions, and is replaced with the /api/rest/2.0/metadata/parameterize-fields endpoint.

### Request parameters

In your `POST` request body, include the following parameters:

 
| Parameter | Description |
| --- | --- |
| 
`metadata_type` _Optional_

 | 

_String_. Type of the metadata object. Valid values are:

-   `LOGICAL_TABLE` for tables
    
-   `CONNECTION` for connections
    
-   `CONNECTION_CONFIG` for connection configuration objects
    

Note that this attribute is _optional_ if a GUID is specified as `metadata_identifier` in the request. If you have specified the object name instead of the GUID, and multiple objects in your Org share that name, make sure to specify the metadata type.





 |
| 

`metadata_identifier`

 | 

_String_. ID or name of the metadata object.





 |
| 

`field_type`

 | 

_String_. Type of object property. Valid values are:

-   `ATTRIBUTE` for Tables
    
-   `CONNECTION_PROPERTY` for Connections
    





 |
| 

`field_name`

 | 

_Array of strings_. A JSON array of the name fields to parameterize.

For tables, use one of the following names, depending on the property that you want to parameterize:

-   `databaseName`
    
-   `schemaName`
    
-   `tableName`
    

For connection objects, specify the exact name of the field or property to parameterize. For example, `accountName`, `role`, and `warehouse`.

For connection configuration objects, you can parameterize only `impersonate_user` field.





 |
| 

`variable_identifier`

 | 

_String_. ID or name of the variable.





 |

### Example request

```cURL
curl -X POST \
  --url 'https://{ThoughtSpot-Host}/api/rest/2.0/metadata/parameterize-fields'  \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {AUTH_TOKEN}' \
  --data-raw '{
  "metadata_identifier": "eefd754f-7146-432d-9ad6-2c730264ecc8",
  "field_type": "ATTRIBUTE",
  "field_names": [
    "schemaName",
    "databaseName",
    "tableName"
  ],
  "variable_identifier": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "metadata_type": "LOGICAL_TABLE"
}'
```

If the API request is successful, ThoughtSpot returns a 204 response indicating that the variable has been successfully assigned to the specified object.

## Remove parameterization

To remove the variables assigned to a Connection or Table and restore static values, use the `/api/rest/2.0/metadata/unparameterize` API endpoint.

### Request parameters

In your `POST` request body, include the following parameters:

 
| Parameter | Description |
| --- | --- |
| 
`metadata_type` _Optional_

 | 

_String_. Type of the metadata object. Valid values are:

-   `LOGICAL_TABLE` for tables
    
-   `CONNECTION` for connections
    
-   `CONNECTION_CONFIG` for connection configuration objects
    

Note that this attribute is _optional_ if a GUID is specified as `metadata_identifier` in the request. If you have specified the object name instead of the GUID, and multiple objects in your Org share that name, make sure to specify the metadata type.





 |
| 

`metadata_identifier`

 | 

_String_. ID or name of the metadata object.





 |
| 

`field_type`

 | 

_String_. Type of object property. Valid values are:

-   `ATTRIBUTE` for Tables
    
-   `CONNECTION_PROPERTY` for Connections
    





 |
| 

`field_name`

 | 

_String_. The name of the field to parameterize.

For Table attributes, use one of the following options:

-   `databaseName`
    
-   `schemaName`
    
-   `tableName`
    

For connection objects, specify the name of the field or property for which you want to restore a static value.

For connection configuration objects, you can update only the `impersonate_user` field.





 |
| 

`value`

 | 

_String_. Value to assign to the object property. This will assign a static value and remove the variable from the object property.





 |

### Example request

```cURL
curl -X POST \
  --url 'https://{ThoughtSpot-Host}/api/rest/2.0/metadata/unparameterize'  \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {AUTH_TOKEN}' \
  --data-raw '{
  "metadata_identifier": "metadata_identifier2",
  "field_type": "ATTRIBUTE",
  "field_name": "field_name0",
  "value": "sales",
  "metadata_type": "LOGICAL_TABLE"
}'
```

If the API request is successful, ThoughtSpot returns a 204 response indicating that the variable has been successfully removed from the specified object.