> For the complete documentation index, see [llms.txt](https://docs.madconnect.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.madconnect.ai/deployment-options/madconnect-apis/connections.md).

# Connections

### **Connections** <a href="#connections" id="connections"></a>

The Connections API allows management of connections. A connection is a pipe between two connectors. Data transfer is only allowed on active connections.

#### **List Connections** <a href="#list-connections" id="list-connections"></a>

```
GET /es/v2/connections
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
&q=keyword
&size=10
&offset=0
&status=active //All connections retured if empty or all
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": [
    {
      "accountId": "string",
      "createdTime": 0,
      "deleted": true,
      "dest": {
        "configured": true,
        "connectorId": "string",
        "connectorLogo": "string",
        "connectorName": "string"
      },
      "editable": true,
      "enabled": true,
      "env": "string",
      "id": "string",
      "monthlyVolume": 0,
      "name": "string",
      "src": {
        "configured": true,
        "connectorId": "string",
        "connectorLogo": "string",
        "connectorName": "string"
      },
      "status": "string",
      "totalVolume": 0,
      "updatedTime": 0,
      "usedVolume": 0
    }
  ]
}
```

**Attributes:**

| Attribute     | Description                                        | Possible Values                                         |
| ------------- | -------------------------------------------------- | ------------------------------------------------------- |
| accountId     | Unique identifier for the account                  | UUID (16-character identifier)                          |
| createdTime   | Account creation time                              | Unix timestamp (seconds)                                |
| deleted       | Indicates whether the account is deleted or not    | `true` or `false`                                       |
| dest          | Details of destination connector                   | `id,name,logo`                                          |
| configured    | Indicates whether the account is configured or not | `true` or `false`                                       |
| connectorId   | Unique identifier for the connector                | UUID (16-character identifier)                          |
| connectorLogo | Logo of the connector                              | URL (e.g., <https://example.com/logo.png>)              |
| connectorName | Name of the connector                              | String (e.g., connector name)                           |
| editable      | Indicates whether the account is editable or not   | `true` or `false`                                       |
| enabled       | Indicates whether the account is enabled or not    | `true` or `false`                                       |
| env           | Environment name of the connection                 | String (e.g., environment name)                         |
| id            | Unique identifier for the connection               | UUID (16-character identifier)                          |
| monthlyVolume | Monthly volume used by the connection              | Integer (e.g., 0, 1000, etc.)                           |
| name          | Name of the connection                             | String (e.g., connection name)                          |
| src           | Details of source connector                        | `id,name,logo`                                          |
| status        | Status of the connection                           | `In-progress,active,disabled, deleted, broken, offline` |
| totalVolume   | Total volume used by the connection                | Integer (e.g., 0, 1000, etc.)                           |
| updatedTime   | Account updation time                              | Unix timestamp (seconds)                                |
| usedVolume    | Volume used by the connection                      | Integer (e.g., 0, 1000, etc.)                           |

**Sample Curl::**

```
curl --location '<host>/es/v2/connections?accountId=a3ba4fbd9d51df11&q=&size=10&offset=0&status=' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0'
```

#### **Create a Connection** <a href="#create-a-connection" id="create-a-connection"></a>

This API allows creating connections between a source and destination connector. Only compatible connectors are allowed as source and destination.

```
POST /es/v2/connections
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
```

**Request Body:**

```
{
  "destConfigurationId": "string",
  "destConnectionConfig": {
    
  },
  "destConnectorId": "string",
  "name": "string",
  "srcConfigurationId": "string",
  "srcConnectionConfig": {
    
  },
  "srcConnectorId": "string"
}
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": {}
}
```

**Attributes:**

| Attribute            | Description                                         | Possible Values                |
| -------------------- | --------------------------------------------------- | ------------------------------ |
| destConfigurationId  | Unique identifier for the destination configuration | UUID (16-character identifier) |
| destConnectionConfig | Details of destination connector                    | `Different for each connector` |
| destConnectorId      | Unique identifier for the destination connector     | UUID (16-character identifier) |
| name                 | Name of the connection                              | String (e.g., connection name) |
| srcConfigurationId   | Unique identifier for the source configuration      | UUID (16-character identifier  |
| srcConnectionConfig  | Details of source connector                         | `Different for each connector` |
| srcConnectorId       | Unique identifier for the source connector          | UUID (16-character identifier) |

**Sample Curl::**

```
curl --location '<host>/es/v2/connections?accountId=a3ba4fbd9d51df11' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0' \
--data '{
  "destConfigurationId": null,
  "destConnectionConfig": {
    "advertiserId": "12345",
    "audienceSource": "USER_PROVIDED_ONLY"
  },
  "destConnectorId": "13a4e0ca00af0011",
  "name": "Sample Connection",
  "srcConfigurationId": null,
  "srcConnectionConfig": {
    "bucketURI": "s3://snowflake-native-app-test/connectors/sample-csv"
  },
  "srcConnectorId": "STWkG5hhS3EvG511"
}'
```

#### **Update Connection** <a href="#update-connection" id="update-connection"></a>

This API allows updating a connection configuration like connection name and connector parameters. The source and destination connectors cannot be changed and one has to create a new connection for changing source and/or destination.

```
PUT /es/v2/connections/<connection_id>
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
```

**Request Body:**

```
{
  "name": "string",
  "destConnectionConfig": {
    
  },
  "srcConnectionConfig": {
    
  }
}
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": {}
}
```

**Attributes:**

| Attribute            | Description                          | Possible Values                |
| -------------------- | ------------------------------------ | ------------------------------ |
| id                   | Unique identifier for the connection | UUID (16-character identifier) |
| name                 | Name of the connection               | String (e.g., connection name) |
| destConnectionConfig | Details of destination connector     | `Different for each connector` |
| srcConnectionConfig  | Details of source connector          | `Different for each connector` |

**Sample Curl::**

```
curl --location --request PUT '<host>/es/v2/connections/849b79953b98fe11?accountId=a3ba4fbd9d51df11' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0' \
--data '{
  "name": "Sample Connection",
  "srcConnectionConfig": {
    "bucketURI": "s3://snowflake-native-app-test/connectors/sample-csv"
  },
  "destConnectionConfig": {
    "advertiserId": "123456",
    "audienceSource": "USER_PROVIDED_ONLY"
  }
}'
```

#### **Update Connection Status** <a href="#update-connection-status" id="update-connection-status"></a>

This API allows updating the status of connection,

* Activate a connection
* Enable / Disable a connection

```
PUT /es/v2/connections/<connection_id>/status/<status> // [activate|enable|disable]
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": {}
}
```

**Sample Curl::**

```
curl --location --request PUT '<host>/es/v2/connections/849b79953b98fe11/status/activate?accountId=a3ba4fbd9d51df11' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0'
```

#### **Delete Connection** <a href="#delete-connection" id="delete-connection"></a>

This API allows deletion of a connection. Deleted connections are available for restoration for 30 days, after which they will be permanently removed.

```
DELETE /es/v2/connections/<connection_id>
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
```

**Request Body:**

```
NA
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": {}
}
```

**Sample Curl:**

```
curl --location --request DELETE '<host>/es/v2/connections/849b79953b98fe11?accountId=a3ba4fbd9d51df11' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0'
```

#### **Get Connection Details** <a href="#get-connection-details" id="get-connection-details"></a>

This API can be used to fetch information about a connection like name, source-destination, parameters, volume etc.

```
GET /es/v2/connections/{connection_id}
```

**Query parameters**

```
&accountId=<sub_account_id> // Required for managing connections in sub-accounts
```

**Response:**

```
{
  "statusCode": 0,
  "statusMessage": "string",
  "response": {
    "accountId": "string",
    "createdTime": 0,
    "deleted": true,
    "dest": {
      "configured": true,
      "connectorId": "string",
      "connectorLogo": "string",
      "connectorName": "string"
    },
    "editable": true,
    "enabled": true,
    "env": "string",
    "id": "string",
    "monthlyVolume": 0,
    "name": "string",
    "src": {
      "configured": true,
      "connectorId": "string",
      "connectorLogo": "string",
      "connectorName": "string"
    },
    "status": "string",
    "totalVolume": 0,
    "updatedTime": 0,
    "usedVolume": 0
  }
}
```

**Attributes:**

| Attribute     | Description                                        | Possible Values                                         |
| ------------- | -------------------------------------------------- | ------------------------------------------------------- |
| accountId     | Unique identifier for the account                  | UUID (16-character identifier)                          |
| createdTime   | Account creation time                              | Unix timestamp (seconds)                                |
| deleted       | Indicates whether the account is deleted or not    | `true` or `false`                                       |
| dest          | Details of destination connector                   | `id,name,logo`                                          |
| configured    | Indicates whether the account is configured or not | `true` or `false`                                       |
| connectorId   | Unique identifier for the connector                | UUID (16-character identifier)                          |
| connectorLogo | Logo of the connector                              | URL (e.g., <https://example.com/logo.png>)              |
| connectorName | Name of the connector                              | String (e.g., connector name)                           |
| editable      | Indicates whether the account is editable or not   | `true` or `false`                                       |
| enabled       | Indicates whether the account is enabled or not    | `true` or `false`                                       |
| env           | Environment name of the connection                 | String (e.g., environment name)                         |
| id            | Unique identifier for the connection               | UUID (16-character identifier)                          |
| monthlyVolume | Monthly volume used by the connection              | Integer (e.g., 0, 1000, etc.)                           |
| name          | Name of the connection                             | String (e.g., connection name)                          |
| src           | Details of source connector                        | `id,name,logo`                                          |
| status        | Status of the connection                           | `In-progress,active,disabled, deleted, broken, offline` |
| totalVolume   | Total volume used by the connection                | Integer (e.g., 0, 1000, etc.)                           |
| updatedTime   | Account updation time                              | Unix timestamp (seconds)                                |
| usedVolume    | Volume used by the connection                      | Integer (e.g., 0, 1000, etc.)                           |

**Sample Curl:**

```
curl --location '<host>/es/v2/connections/849b79953b98fe11?accountId=a3ba4fbd9d51df11' \
--header 'Authorization: Bearer c076dc2e-d0c2-4d4d-ab13-e4e3dd555fc0'
```
