---
title: "Create a source swap policy"
method: POST
path: "/v2/sourceSwapPolicies"
tags: ["Source swap policies"]
---

# Create a source swap policy

`POST /v2/sourceSwapPolicies`

## Request

- Base URL: `https://api.sigmacomputing.com`
- URL: `https://api.sigmacomputing.com/v2/sourceSwapPolicies`
- Auth: HTTP bearer

Create a source swap policy.

  **Beta**: Creating a **Connection** source swap policy is in private beta and must be enabled for your organization. This documentation is subject to the [Beta features](/docs/sigma-product-releases#beta-features) disclaimer.

  ### Usage notes
  - Retrieve the **connectionId** to use as the **fromConnectionId** by calling the [/v2/connections](/reference/list-connections) endpoint.
  - Retrieve the **userAttributeId** to use in the **swaps** object by calling the [/v2/user-attributes](/reference/list-user-attributes) endpoint.

## Request body

- union
  - SourceSwapPoliciesCreateSourceSwapPolicyRequest0
    - `type` 'connection', required
    - `name` string, required: Name of the source swap policy.
    - `fromConnectionId` string, required: ID of the connection to swap.
    - `swaps` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0Swaps, required
      - `connectionSwaps` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItems[], required: Swap paths to a different location in the same connection.
        - `to` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsTo, required: Specify how to swap each segment of a path to a table in your database, catalog, or project. `path0` is equivalent to a database, catalog, or project. `path` is equivalent to a schema or dataset, and `path2` is equivalent to a table or view.
          - `path0` union, required: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath00
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath01
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath02
              - …
          - `path1` union, required: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath10
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath11
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath12
              - …
          - `path2` union: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath20
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath21
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf0SwapsConnectionSwapsItemsToPath22
              - …
  - SourceSwapPoliciesCreateSourceSwapPolicyRequest1
    - `type` 'deployment', required
    - `name` string, required: Name of the source swap policy.
    - `fromConnectionId` string, required: ID of the connection to swap.
    - `swaps` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1Swaps, required
      - `toConnection` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsToConnection, required
        - `swapType` 'attribute', required: Specify a user attribute to use the value of the user attribute as the value to swap.
        - `userAttributeId` string, required
      - `deploymentSwaps` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItems[], required
        - `from` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFrom, required
          - `path0` union, required
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath00
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath01
              - …
          - `path1` union, required
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath10
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath11
              - …
          - `path2` union
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath20
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsFromPath21
              - …
        - `to` V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsTo, required
          - `path0` union, required: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath00
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath01
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath02
              - …
          - `path1` union, required: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath10
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath11
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath12
              - …
          - `path2` union: The rule used to update this specific path value when the swap is performed. If the specified path (when resolved) does not exist, the swap is not performed.
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath20
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath21
              - …
            - V2SourceSwapPoliciesPostRequestBodyContentApplicationJsonSchemaOneOf1SwapsDeploymentSwapsItemsToPath22
              - …

## Response `200`

Source Swap Policy Response

- SourceSwapPoliciesCreateSourceSwapPolicyResponse200: Source Swap Policy Response
  - `policyId` string, required: Unique identifier of the source swap policy.

---

[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)
