> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supermetrics.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create data source connection

> Creates a data source connection for a Hub transfer. This endpoint establishes a connection
between a data source and a destination for use in data warehouse transfers.

**Returns:** Connection object with connection ID and optional OAuth URLs.

**Important Notes:**
- Requires scope `dwh_transfers_write`
- Your account must have `dwh.transfer.edit` permission. See [roles and permissions](https://docs.supermetrics.com/docs/about-supermetrics-teams-and-user-roles#user-roles).
- Connection credentials are encrypted and stored securely
- Some data sources may require OAuth authentication (check `login_url` in response)
- The connection must be created before setting up transfers


## OpenAPI

````json POST /teams/{team_id}/data-source-connections
{
  "openapi": "3.0.3",
  "info": {
    "title": "Management API Reference",
    "version": "2.0.0",
    "description": "API Documentation for the Supermetrics Management API. For more information, visit https://supermetrics.com.",
    "termsOfService": "https://supermetrics.com/terms-of-service",
    "contact": {
      "name": "Supermetrics Suppot",
      "email": "support@supermetrics.com",
      "url": "https://supermetrics.com/support"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "x-api-id": "sm-management-api",
    "x-audience": "public"
  },
  "servers": [
    {
      "url": "https://api.supermetrics.com/v2",
      "description": "Global production public Supermetrics Management API base path.",
      "x-internal": "false"
    }
  ],
  "tags": [
    {
      "name": "API Keys",
      "description": "Manage API keys to access Supermetrics API"
    },
    {
      "name": "Data Source Logins",
      "description": "Access your data source authentications"
    },
    {
      "name": "Data Source Login Links",
      "description": "Create single-use data source login links"
    },
    {
      "name": "Saved Queries",
      "description": "Manage queries saved in Query Manager"
    },
    {
      "name": "Table Groups",
      "description": "Manage your team's table groups"
    },
    {
      "name": "Team Lists",
      "description": "Manage centralized team lists for your queries"
    },
    {
      "name": "Team Settings",
      "description": "Configure general settings for your team"
    },
    {
      "name": "Data Transfers",
      "description": "Create, configure, and manage Data Warehouse transfers"
    },
    {
      "name": "Transfer Runs",
      "description": "Monitor execution history of Data Warehouse transfers"
    },
    {
      "name": "Data Backfills",
      "description": "Manage historical data backfills for your Data Warehouse transfers"
    },
    {
      "name": "Data Destinations",
      "description": "Create, configure, and manage Data Warehouse destinations"
    },
    {
      "name": "Data Source Connections",
      "description": "Create and manage data source connections for Data Warehouse transfers"
    },
    {
      "name": "Data Blending",
      "description": "Create and manage Data Blending"
    },
    {
      "name": "Custom Fields",
      "description": "Create and manage Custom Fields"
    }
  ],
  "externalDocs": {
    "description": "Find out more about Supermetrics Management API",
    "url": "https://docs.supermetrics.com/apidocs/management-api"
  },
  "paths": {
    "/teams/{team_id}/data-source-connections": {
      "servers": [
        {
          "url": "https://dts-api.supermetrics.com/v1",
          "description": "Data Source Connections API"
        }
      ],
      "post": {
        "summary": "Create data source connection",
        "description": "Creates a data source connection for a Hub transfer. This endpoint establishes a connection\nbetween a data source and a destination for use in data warehouse transfers.\n\n**Returns:** Connection object with connection ID and optional OAuth URLs.\n\n**Important Notes:**\n- Requires scope `dwh_transfers_write`\n- Your account must have `dwh.transfer.edit` permission. See [roles and permissions](https://docs.supermetrics.com/docs/about-supermetrics-teams-and-user-roles#user-roles).\n- Connection credentials are encrypted and stored securely\n- Some data sources may require OAuth authentication (check `login_url` in response)\n- The connection must be created before setting up transfers\n",
        "operationId": "createDataSourceConnection",
        "tags": [
          "Data Source Connections"
        ],
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/DwhTeamIdPathParam"
          }
        ],
        "requestBody": {
          "required": "true",
          "description": "Connection configuration specifying data source and destination",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDataSourceConnectionRequest"
              },
              "example": {
                "data_source_id": "ADM",
                "destination_type": "DWH_SNOWFLAKE"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connection created successfully",
            "headers": {
              "Access-Control-Allow-Origin": {
                "$ref": "#/components/headers/Access-Control-Allow-Origin"
              },
              "Location": {
                "description": "URI of the created connection resource",
                "schema": {
                  "type": "string",
                  "format": "uri",
                  "maxLength": "2048",
                  "pattern": "^https?://[\\s\\S]+$",
                  "example": "https://dts-api.supermetrics.com/v1/teams/12345/data-source-connections/019461A0-0000-7000-8000-000000000000"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DataSourceConnectionResponse"
                },
                "examples": {
                  "success": {
                    "summary": "Successful connection creation",
                    "value": {
                      "meta": {
                        "request_id": "019461A0-0000-7000-8000-000000000000"
                      },
                      "data": {
                        "connection_id": "019461A0-0000-7000-8000-000000000001",
                        "login_url": null,
                        "connect_url": null
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/DwhBadRequest"
          },
          "401": {
            "$ref": "#/components/responses/DwhUnauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "422": {
            "$ref": "#/components/responses/UnprocessableEntity"
          },
          "429": {
            "$ref": "#/components/responses/DwhTooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/DwhInternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "DwhTeamIdPathParam": {
        "name": "team_id",
        "in": "path",
        "required": "true",
        "description": "Unique identifier of the team",
        "example": "12345",
        "schema": {
          "type": "integer",
          "format": "int64",
          "minimum": "1",
          "maximum": "9223372036854776000"
        }
      }
    },
    "schemas": {
      "CreateDataSourceConnectionRequest": {
        "type": "object",
        "required": [
          "data_source_id",
          "destination_type"
        ],
        "properties": {
          "data_source_id": {
            "type": "string",
            "maxLength": "50",
            "pattern": "^[A-Z0-9_]+$",
            "description": "Data source identifier (e.g., \"GA\" for Google Analytics, \"ADM\" for Adobe Analytics Metrics)",
            "example": "ADM"
          },
          "destination_type": {
            "type": "string",
            "maxLength": "50",
            "pattern": "^[A-Z0-9_]+$",
            "description": "Destination type identifier (e.g., \"SQL_BQ\" for BigQuery, \"DWH_SNOWFLAKE\" for Snowflake)",
            "example": "DWH_SNOWFLAKE"
          },
          "api_key": {
            "type": "string",
            "maxLength": "255",
            "pattern": "^[\\s\\S]+$",
            "description": "API Key for authentication (optional if provided in Authorization header).\nThis is a reserved framework parameter and will be automatically handled.\n",
            "example": "sk_your_api_key_here"
          }
        },
        "additionalProperties": "false"
      },
      "DataSourceConnectionResponse": {
        "type": "object",
        "required": [
          "meta",
          "data"
        ],
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/ResponseMeta"
          },
          "data": {
            "$ref": "#/components/schemas/DataSourceConnection"
          }
        }
      },
      "ResponseMeta": {
        "type": "object",
        "properties": {
          "request_id": {
            "type": "string",
            "maxLength": "50",
            "pattern": "^[A-Za-z0-9_-]+$",
            "description": "API request ID"
          }
        }
      },
      "DataSourceConnection": {
        "type": "object",
        "required": [
          "connection_id"
        ],
        "properties": {
          "connection_id": {
            "type": "string",
            "format": "uuid",
            "maxLength": "36",
            "pattern": "^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$",
            "description": "Unique identifier for the created connection",
            "example": "019461A0-0000-7000-8000-000000000001"
          },
          "login_url": {
            "type": "string",
            "format": "uri",
            "maxLength": "2048",
            "nullable": "true",
            "description": "URL for OAuth login flow (used when data source requires user authentication).\nIn the current V1 implementation, this is always null.\n",
            "example": null
          },
          "connect_url": {
            "type": "string",
            "format": "uri",
            "maxLength": "2048",
            "nullable": "true",
            "description": "URL for connection flow (used when additional authentication steps are required).\nIn the current V1 implementation, this is always null.\n",
            "example": null
          }
        },
        "additionalProperties": "false"
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "meta": {
            "$ref": "#/components/schemas/ResponseMeta"
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "maxLength": "100",
            "description": "Error code"
          },
          "message": {
            "type": "string",
            "maxLength": "255",
            "description": "Error message"
          },
          "description": {
            "type": "string",
            "maxLength": "255",
            "description": "Error description"
          }
        }
      }
    },
    "headers": {
      "Access-Control-Allow-Origin": {
        "description": "CORS header",
        "schema": {
          "type": "string",
          "maxLength": "255",
          "enum": [
            "*"
          ],
          "example": "*"
        }
      },
      "Content-Type": {
        "description": "HTTP response content type",
        "schema": {
          "type": "string",
          "maxLength": "255",
          "enum": [
            "application/json"
          ],
          "example": "application/json"
        }
      },
      "X-RateLimit-Limit": {
        "description": "Request limit per hour",
        "schema": {
          "type": "integer",
          "format": "int32",
          "minimum": "1",
          "maximum": "10000",
          "example": "100"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Remaining requests in current window",
        "schema": {
          "type": "integer",
          "format": "int32",
          "minimum": "0",
          "maximum": "10000",
          "example": "49"
        }
      }
    },
    "responses": {
      "DwhBadRequest": {
        "description": "Bad Request - The request was invalid or cannot be served.",
        "headers": {
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "meta": {
                "request_id": "01892A4D-7586-7000-8000-000000000000"
              },
              "error": {
                "code": "INVALID_PARAMETER",
                "message": "Invalid Parameter",
                "description": "The request contains invalid or malformed parameters."
              }
            }
          }
        }
      },
      "DwhUnauthorized": {
        "description": "Unauthorized - Authentication is required and has failed or has not been provided.",
        "headers": {
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "meta": {
                "request_id": "019461A0-0000-7000-8000-000000000000"
              },
              "error": {
                "code": "API_KEY_INVALID",
                "message": "Invalid API key",
                "description": "Provided API key was invalid."
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden - The request is understood, but access is not allowed",
        "headers": {
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "meta": {
                "request_id": "01892A4D-7586-7000-8000-000000000000"
              },
              "error": {
                "code": "ACCESS_DENIED",
                "message": "Access Denied",
                "description": "You do not have permission to perform this operation."
              }
            }
          }
        }
      },
      "UnprocessableEntity": {
        "description": "Unprocessable Entity - request validation failed",
        "headers": {
          "Content-Type": {
            "$ref": "#/components/headers/Content-Type"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            }
          }
        }
      },
      "DwhTooManyRequests": {
        "description": "Too Many Requests - Rate limit exceeded.",
        "headers": {
          "Retry-After": {
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": "1",
              "maximum": "3600"
            },
            "description": "Number of seconds to wait before making another request"
          },
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "meta": {
                "request_id": "019461A0-0000-7000-8000-000000000000"
              },
              "error": {
                "code": "API_ROW_QUOTA_EXCEEDED",
                "message": "Row quota exceeded",
                "description": "You have exceeded your row-quota limit of rows for this month. Please log into Supermetrics Hub at https://hub.supermetrics.com/ and upgrade your plan, or contact our Supermetrics support team."
              }
            }
          }
        }
      },
      "DwhInternalServerError": {
        "description": "Internal Server Error - An error occurred on the server.",
        "headers": {
          "Access-Control-Allow-Origin": {
            "$ref": "#/components/headers/Access-Control-Allow-Origin"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorResponse"
            },
            "example": {
              "meta": {
                "request_id": "01892A4D-7586-7000-8000-000000000000"
              },
              "error": {
                "code": "INTERNAL_SERVER_ERROR",
                "message": "Internal Server Error",
                "description": "An unexpected error occurred. Please try again later or contact support."
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Include the token in the Authorization header:\n`Authorization: Bearer <your-token>`\n"
      }
    }
  }
}
````

