---
title: "Connections"
description: "<p>Create and manage connections to external data sources.</p>"
url: "https://www.contentstack.com/docs/developers/apis/lytics-api/connections"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-05"
---

# Connections

Create and manage connections to external data sources.

## Get connections

### Get connections

**GET** `/v2/connection`

Get a list of all connections for the account

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "account_id": "string",
      "aid": 0,
      "auth_ids": [
        "string"
      ],
      "author_id": "string",
      "config": {
        "bucket": "string",
        "connection_url": "string",
        "database": "string",
        "dataset": "string",
        "file": "string",
        "project": "string",
        "ssl_mode": "string"
      },
      "connection_config_id": "string",
      "connection_config_slug": "string",
      "created": "string",
      "deleted": "string",
      "description": "string",
      "id": "string",
      "label": "string",
      "provider_id": "string",
      "provider_slug": "string",
      "updated": "string",
      "updated_by_user_id": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Create connection

### Create connection

**POST** `/v2/connection`

Create a connection

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "aid": 0,
    "auth_ids": [
      "string"
    ],
    "author_id": "string",
    "config": {
      "bucket": "string",
      "connection_url": "string",
      "database": "string",
      "dataset": "string",
      "file": "string",
      "project": "string",
      "ssl_mode": "string"
    },
    "connection_config_id": "string",
    "connection_config_slug": "string",
    "created": "string",
    "deleted": "string",
    "description": "string",
    "id": "string",
    "label": "string",
    "provider_id": "string",
    "provider_slug": "string",
    "updated": "string",
    "updated_by_user_id": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Get connection

### Get connection

**GET** `/v2/connection/{id}`

Get a connection by ID

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "aid": 0,
    "auth_ids": [
      "string"
    ],
    "author_id": "string",
    "config": {
      "bucket": "string",
      "connection_url": "string",
      "database": "string",
      "dataset": "string",
      "file": "string",
      "project": "string",
      "ssl_mode": "string"
    },
    "connection_config_id": "string",
    "connection_config_slug": "string",
    "created": "string",
    "deleted": "string",
    "description": "string",
    "id": "string",
    "label": "string",
    "provider_id": "string",
    "provider_slug": "string",
    "updated": "string",
    "updated_by_user_id": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Update connection

### Update connection

**PUT** `/v2/connection/{id}`

Update a connection

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "account_id": "string",
    "aid": 0,
    "auth_ids": [
      "string"
    ],
    "author_id": "string",
    "config": {
      "bucket": "string",
      "connection_url": "string",
      "database": "string",
      "dataset": "string",
      "file": "string",
      "project": "string",
      "ssl_mode": "string"
    },
    "connection_config_id": "string",
    "connection_config_slug": "string",
    "created": "string",
    "deleted": "string",
    "description": "string",
    "id": "string",
    "label": "string",
    "provider_id": "string",
    "provider_slug": "string",
    "updated": "string",
    "updated_by_user_id": "string"
  },
  "request_id": "string",
  "status": 0
}
```

## Delete connection

### Delete connection

**DELETE** `/v2/connection/{id}`

Delete a connection

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {},
  "request_id": "string",
  "status": 0
}
```

## Count the rows a query returns

### Count the rows a query returns

**POST** `/v2/connection/{id}/count`

Count the rows a query against an external data source returns, without fetching them. The query is checked the same way as a scan; counting stops after a minute.

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "row_count": 0
  },
  "request_id": "string",
  "status": 0
}
```

## Query an external data source

### Query an external data source

**POST** `/v2/connection/{id}/scan`

Query an external data source to get sample result set for members of a Cloud Connect model.

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.
- **limit** (optional)
  maximum num of rows to return per call, default = 20, max = 100

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": {
    "columns": [
      {
        "column_datatype": "string",
        "column_name": "string"
      }
    ],
    "row_count": 0,
    "rows": null
  },
  "request_id": "string",
  "status": 0
}
```

## Get the tables for a connection

### Get the tables for a connection

**GET** `/v2/connection/{id}/schema`

Returns all the table names for the given connection

#### URL Parameters

- **id** (required)
  The connection ID

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "error": "string",
      "fully_qualified_name": "string",
      "num_columns": 0,
      "table_name": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```

## Get the schema for a table on the connection

### Get the schema for a table on the connection

**GET** `/v2/connection/{id}/schema/{table}`

Returns all the columns for a table on the given connection

#### URL Parameters

- **id** (required)
  The connection ID
- **table** (required)
  The table name

#### Query Parameters

- **account_id** (optional)
  The account ID. Defaults to the user's default account.

#### Headers

- **Authorization** (optional)

#### Sample Response

```json
{
  "_meta": {},
  "data": [
    {
      "column_datatype": "string",
      "column_name": "string"
    }
  ],
  "request_id": "string",
  "status": 0
}
```