---
title: "Swap data model connections (Beta)"
method: POST
path: "/v2/dataModels/{dataModelId}/swapConnections"
tags: ["Data models"]
---

# Swap data model connections (Beta)

`POST /v2/dataModels/{dataModelId}/swapConnections`

## Request

- Base URL: `https://api.sigmacomputing.com`
- URL: `https://api.sigmacomputing.com/v2/dataModels/{dataModelId}/swapConnections`
- Auth: HTTP bearer

Swap the connections used by a data model. You can update custom SQL elements to query a different connection, and optionally swap warehouse tables and copy input table data.

**Beta**: This documentation describes a public beta feature and is subject to the [Beta features](/docs/sigma-product-releases#beta-features) disclaimer.

  ### Usage notes
  - Retrieve the **dataModelId** by calling the [/v2/dataModels](https://help.sigmacomputing.com/reference/list-data-models) endpoint.
  - Retrieve the **connectionId** by calling the [/v2/connections](https://help.sigmacomputing.com/reference/list-connections) endpoint.
  - To swap warehouse tables in a connection, set the `swapTables` option to `true`. Custom SQL elements and input tables follow the connection mapping whether or not `swapTables` is set.

    - Use the `paths` option to specify the connection paths to swap. The connection path is a list of strings that represents the path to the table in the cloud data warehouse. For example, `["database", "schema", "table"]`.
    - If the table schema is the same in both connections, leave the `paths` option empty to swap all warehouse tables in the connection. You can also pass a partial path to swap between databases, catalogs, or schemas.

  - Set `copyInputTableData` to `true` to copy input table rows onto the new connection. When omitted or `false`, input table connections are updated without copying row data.

## Path parameters

- `dataModelId` string, required

## Request body

- object
  - `connectionMapping` V2DataModelsDataModelIdSwapConnectionsPostRequestBodyContentApplicationJsonSchemaConnectionMappingItems[], required: Connections to swap.
    - `fromId` string, required: ID of the connection to swap from.
    - `toId` string, required: ID of the connection to swap to.
    - `swapTables` boolean: Whether to swap warehouse tables in the connection.
    - `paths` V2DataModelsDataModelIdSwapConnectionsPostRequestBodyContentApplicationJsonSchemaConnectionMappingItemsPathsItems[]
      - `fromPath` string[], required: Connection path of the form ['DATABASE', 'SCHEMA', 'TABLE']
      - `toPath` string[], required: Connection path of the form ['DATABASE', 'SCHEMA', 'TABLE']
  - `copyInputTableData` boolean: When true, copy input table rows onto the swapped connection. When false or omitted, input table connections are updated without copying row data.

## Response `200`

The response body.

- DataModelsSwapDataModelConnectionsResponse200
  - `unswappedSources` string[], required: IDs of sources in the workbook that were not swapped.
  - `unswappedConnections` string[], required: IDs of custom SQL connections in the workbook that were not swapped.

---

[API](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api.md) - [All operations](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sigmacomputing/apis/sigma-rest-api/revisions/fb6036208c49?raw)
