# ConvertKit (Kit)

Kit (formerly ConvertKit) is an email marketing platform designed for creators, bloggers, and small businesses. It provides tools for managing subscribers, creating email sequences, building forms and landing pages, and sending broadcast emails. The Sling Kit connector extracts data from the Kit API v4, supporting subscribers, tags, forms, sequences, broadcasts, custom fields, segments, and webhooks.

{% hint style="success" %}
**CLI Pro Required**: APIs require a [CLI Pro token](https://docs.slingdata.io/sling-cli/cli-pro) or [Platform Plan](https://docs.slingdata.io/sling-platform/platform).
{% endhint %}

## Setup

The following credentials and inputs are accepted:

**Secrets:**

* `api_key` **(required)** -> Your Kit V4 API key

**Inputs:**

* `anchor_date` (optional) -> Starting date for first sync (ISO 8601 format, e.g., `2024-01-01T00:00:00Z`). Defaults to 1 year ago.

### Getting Your API Key

1. Log in to your [Kit account](https://app.kit.com/)
2. Click on **Settings** in the left sidebar
3. Navigate to **Developer settings** (or go directly to <https://app.kit.com/account_settings/developer_settings>)
4. Under **V4 API Keys**, copy your API key (it looks like: `kit_abc123def456...`)

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set CONVERTKIT type=api spec=convertkit secrets='{ api_key: "kit_your_api_key_here" }'
```

{% endcode %}

### Environment Variable

See [here](https://docs.slingdata.io/sling-cli/environment#dot-env-file-.env.sling) to learn more about the `.env.sling` file.

{% code overflow="wrap" %}

```bash
export CONVERTKIT='{ type: api, spec: convertkit, secrets: { api_key: "kit_your_api_key_here" } }'
```

{% endcode %}

### Sling Env File YAML

See [here](https://docs.slingdata.io/sling-cli/environment#sling-env-file-env.yaml) to learn more about the sling `env.yaml` file.

```yaml
connections:
  CONVERTKIT:
    type: api
    spec: convertkit
    secrets:
      api_key: "kit_your_api_key_here"
```

## Replication

Here's an example replication configuration to sync Kit data to a PostgreSQL database:

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: convertkit.{stream_name}

streams:
  subscribers:
    mode: incremental
    primary_key: [id]
    update_key: created_at
  tags:
    primary_key: [id]
  forms:
    primary_key: [id]
  sequences:
    primary_key: [id]
  broadcasts:
    primary_key: [id]
  custom_fields:
    primary_key: [id]
  segments:
    primary_key: [id]
  webhooks:
    primary_key: [id]
```

**Incremental sync example:**

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: incremental
  object: convertkit.{stream_name}

streams:
  subscribers:
    primary_key: [id]
    update_key: created_at
```

**Full refresh example:**

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: convertkit.{stream_name}

streams:
  tags:
  forms:
  sequences:
  broadcasts:
  custom_fields:
  segments:
  webhooks:
```

## Endpoints

### Subscriber Management

| Endpoint        | Description                                                | Incremental |
| --------------- | ---------------------------------------------------------- | ----------- |
| `subscribers`   | All subscribers with email, name, state, and custom fields | Yes         |
| `tags`          | Tags used to categorize subscribers                        | No          |
| `custom_fields` | Custom field definitions                                   | No          |
| `segments`      | Subscriber segments                                        | No          |

### Content & Campaigns

| Endpoint     | Description                                    | Incremental |
| ------------ | ---------------------------------------------- | ----------- |
| `forms`      | Forms and landing pages                        | No          |
| `sequences`  | Email automation sequences                     | No          |
| `broadcasts` | Broadcast emails (drafts, scheduled, and sent) | No          |

### Configuration

| Endpoint   | Description           | Incremental |
| ---------- | --------------------- | ----------- |
| `webhooks` | Webhook subscriptions | No          |

To discover available endpoints:

```bash
sling conns discover CONVERTKIT
```

## Incremental Sync

The Kit connector supports time-based incremental sync for the following endpoint:

* **subscribers** - Syncs new/modified subscribers by `created_at`

### How it works

* **First run:** Fetches all subscribers from the anchor date (defaults to 1 year ago, configurable via the `anchor_date` input)
* **Subsequent runs:** Only fetches subscribers created or modified after the last sync timestamp

### Custom Anchor Date

To specify a custom starting point for the first sync:

```yaml
connections:
  CONVERTKIT:
    type: api
    spec: convertkit
    secrets:
      api_key: "kit_your_api_key_here"
    inputs:
      anchor_date: "2024-01-01T00:00:00Z"
```

## Rate Limiting

The Kit API v4 has a rate limit of 120 requests per 60 seconds. The connector automatically:

* Uses conservative rate limiting (2 requests/second)
* Retries with exponential backoff on 429 (rate limit) responses
* Retries on 5xx server errors

## Common Use Cases

### Sync All Subscriber Data

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: subscribers.{stream_name}

streams:
  subscribers:
    mode: incremental
    primary_key: [id]
    update_key: created_at
  tags:
  custom_fields:
  segments:
```

### Sync Campaign and Content Data

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: campaigns.{stream_name}

streams:
  broadcasts:
  sequences:
  forms:
```

### Sync All Kit Data

```yaml
source: CONVERTKIT
target: MY_POSTGRES

defaults:
  mode: full-refresh
  object: convertkit.{stream_name}

streams:
  '*':
```

If you are facing issues connecting, please reach out to us at <support@slingdata.io>, on [discord](https://discord.gg/q5xtaSNDvp) or open a Github Issue [here](https://github.com/slingdata-io/sling-cli/issues).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/connections/api-connections/convertkit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
