# ActiveCampaign

ActiveCampaign is an email marketing, marketing automation, and CRM platform designed for businesses of all sizes. It provides tools for managing contacts, email campaigns, automations, deals, and customer engagement. The Sling ActiveCampaign connector extracts data from the ActiveCampaign API v3, supporting contacts, deals, campaigns, automations, lists, tags, accounts, and more.

{% 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 are accepted:

**Secrets:**

* `api_key` **(required)** -> Your ActiveCampaign API key
* `base_url` **(required)** -> Your ActiveCampaign API URL (e.g. `https://youraccountname.api-us1.com`)

**Inputs (optional):**

* `anchor_date` (optional) -> Starting date for first incremental 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 [ActiveCampaign account](https://www.activecampaign.com/login)
2. Click **Settings** (gear icon) in the left sidebar
3. Go to **Developer**
4. Copy the **API URL** (this is your `base_url`)
5. Copy the **API Key** (this is your `api_key`)

{% hint style="warning" %}
**Important:** The API URL is account-specific and region-specific (e.g. `https://youraccountname.api-us1.com`). Make sure to copy the exact URL from your Developer settings page.
{% endhint %}

### Using `sling conns`

{% code overflow="wrap" %}

```bash
sling conns set ACTIVECAMPAIGN type=api spec=activecampaign secrets='{ api_key: "your_api_key_here", base_url: "https://youraccountname.api-us1.com" }'
```

{% 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 ACTIVECAMPAIGN='{ type: api, spec: activecampaign, secrets: { api_key: "your_api_key_here", base_url: "https://youraccountname.api-us1.com" } }'
```

{% 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:
  ACTIVECAMPAIGN:
    type: api
    spec: activecampaign
    secrets:
      api_key: "your_api_key_here"
      base_url: "https://youraccountname.api-us1.com"
```

## Replication

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

```yaml
source: ACTIVECAMPAIGN
target: MY_POSTGRES

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

streams:
  # Core data with incremental sync
  contacts:
    mode: incremental
  deals:
    mode: incremental

  # Campaign and automation data
  campaigns:
  automations:

  # Audience data
  lists:
  tags:
  contact_tags:

  # CRM data
  deal_pipelines:
  deal_stages:
  accounts:
  notes:
  tasks:

  # Reference data
  users:
  forms:
  custom_fields:
```

## Endpoints

### Contact Management

| Endpoint        | Description                                               | Incremental |
| --------------- | --------------------------------------------------------- | ----------- |
| `contacts`      | All contacts with email, name, phone, and metadata        | Yes         |
| `lists`         | Contact lists / audiences                                 | No          |
| `tags`          | Tags for organizing contacts                              | No          |
| `contact_tags`  | Contact-tag associations (which contacts have which tags) | No          |
| `custom_fields` | Custom contact field definitions                          | No          |
| `forms`         | Subscription forms                                        | No          |

### CRM / Deals

| Endpoint         | Description                                              | Incremental |
| ---------------- | -------------------------------------------------------- | ----------- |
| `deals`          | All deals with value, stage, and contact associations    | Yes         |
| `deal_pipelines` | Deal pipelines (groups)                                  | No          |
| `deal_stages`    | Deal stages for each pipeline (child of deal\_pipelines) | No          |
| `accounts`       | Organizations / companies                                | No          |
| `notes`          | Notes on contacts and deals                              | No          |
| `tasks`          | Deal tasks and follow-ups                                | No          |

### Marketing

| Endpoint      | Description                     | Incremental |
| ------------- | ------------------------------- | ----------- |
| `campaigns`   | Email campaigns with send stats | No          |
| `automations` | Automation workflows            | No          |

### Account

| Endpoint | Description                         | Incremental |
| -------- | ----------------------------------- | ----------- |
| `users`  | Users in the ActiveCampaign account | No          |

To discover available endpoints:

```bash
sling conns discover ACTIVECAMPAIGN
```

## Parent-Child Endpoints

The `deal_stages` endpoint is a child of `deal_pipelines`. When both are included in a replication, Sling automatically runs `deal_pipelines` first to collect pipeline IDs, then iterates through each pipeline to fetch its stages.

## Incremental Sync

The ActiveCampaign connector supports time-based incremental sync for the following endpoints:

* **contacts** - Syncs contacts updated after the last sync using the `udate` field and `filters[updated_after]` parameter
* **deals** - Syncs deals updated after the last sync using the `mdate` field and `filters[updated_after]` parameter

### How it works

* **First run:** Fetches records updated since `anchor_date` (defaults to 1 year ago)
* **Subsequent runs:** Only fetches records modified after the last sync timestamp
* Configure the lookback window with the `anchor_date` input parameter

## Rate Limiting

The ActiveCampaign API enforces a rate limit of **5 requests per second** per account.

The connector automatically:

* Uses conservative rate limiting (4 requests/second)
* Limits concurrency to 3 parallel requests
* Retries with exponential backoff on 429 (rate limit) responses (up to 5 attempts)

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