PHPackages                             relyz/active-campaign-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. relyz/active-campaign-sdk

ActiveLibrary[API Development](/categories/api)

relyz/active-campaign-sdk
=========================

PHP SDK for the ActiveCampaign API v3

v1.1.0(2mo ago)01MITPHPPHP ^8.1CI passing

Since Mar 26Pushed 2mo agoCompare

[ Source](https://github.com/relyz-ag/active-campaign-php-sdk)[ Packagist](https://packagist.org/packages/relyz/active-campaign-sdk)[ Docs](https://github.com/relyz-ag/active-campaign-php-sdk)[ RSS](/packages/relyz-active-campaign-sdk/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (12)Versions (4)Used By (0)

ActiveCampaign PHP SDK
======================

[](#activecampaign-php-sdk)

PHP wrapper for the [ActiveCampaign API v3](https://developers.activecampaign.com/reference). Returns typed models, retries on rate limits, and handles pagination.

**This is an unofficial SDK.** Built and maintained by [relyz AG](https://relyz.ch).

> **Note:** This SDK targets ActiveCampaign API v3 exclusively. The API version prefix (`/api/3/`) is not configurable.

Requirements
------------

[](#requirements)

- PHP 8.1+
- Guzzle 7.0+

Installation
------------

[](#installation)

```
composer require relyz/active-campaign-sdk
```

Usage
-----

[](#usage)

```
$ac = new ActiveCampaign\Client(
    url: 'https://youraccountname.api-us1.com',
    apiKey: 'your-api-key',
);
```

Or set the `ACTIVE_CAMPAIGN_API_URL` and `ACTIVE_CAMPAIGN_API_KEY` environment variables (via `.env`, Docker, `export`, etc.) and omit the arguments:

```
$ac = new ActiveCampaign\Client();
```

### Create a contact

[](#create-a-contact)

```
$contact = $ac->contacts()->create(
    email: 'jane@example.com',
    firstName: 'Jane',
    lastName: 'Doe',
);

// $contact is a typed Contact model
echo $contact->id;
```

For most methods there are simplified versions (like the one above) that should cover most use cases. In case some parameters are missing from the simplified version, there is always a \*Raw method available, to which you can just pass an array with all the parameters that the API endpoints accepts.

```
$contact = $ac->contacts()->createRaw([
    'email' => 'jane@example.com',
    'firstName' => 'Jane',
    'lastName' => 'Doe',
]);
```

Error Handling
--------------

[](#error-handling)

The SDK throws typed exceptions for different HTTP error scenarios:

```
use ActiveCampaign\Exceptions\AuthenticationException;
use ActiveCampaign\Exceptions\NotFoundException;
use ActiveCampaign\Exceptions\ValidationException;
use ActiveCampaign\Exceptions\RateLimitException;
use ActiveCampaign\Exceptions\ActiveCampaignException;

try {
    $contact = $ac->contacts()->get(999);
} catch (NotFoundException $e) {
    // 404 — resource not found
    echo $e->getMessage();
    print_r($e->getResponseBody()); // parsed JSON from API
} catch (ValidationException $e) {
    // 422 — validation failed
    print_r($e->getResponseBody()['errors'] ?? []);
} catch (AuthenticationException $e) {
    // 401/403 — invalid or missing API key
} catch (RateLimitException $e) {
    // 429 — rate limit exceeded (after retries exhausted)
} catch (ActiveCampaignException $e) {
    // All other API errors (5xx, etc.)
}
```

All exceptions extend `ActiveCampaignException`, which extends `RuntimeException`. Every exception provides `getResponseBody()` returning the parsed API response as an array.

Pagination
----------

[](#pagination)

### Basic Listing

[](#basic-listing)

```
$result = $ac->contacts()->list(['limit' => 50, 'offset' => 0]);

foreach ($result->data as $contact) {
    echo $contact->email;
}

echo $result->meta->total;  // Total records available
```

### Lazy Pagination

[](#lazy-pagination)

Use `paginate()` for automatic lazy-loading across all pages:

```
foreach ($ac->contacts()->paginate(limit: 100) as $contact) {
    echo $contact->email; // Fetches next page automatically
}
```

Rate Limiting
-------------

[](#rate-limiting)

The SDK automatically retries requests that receive a `429 Too Many Requests` response, respecting the `Retry-After` header. By default, it retries up to 3 times using `sleep()`.

To customize retry behavior (e.g., for non-blocking strategies or logging):

```
$ac = new Client(
    maxRetries: 5,
);
```

For advanced control, provide a custom retry callback via the HTTP client:

```
use ActiveCampaign\Http\Client as HttpClient;

$httpClient = new HttpClient(
    retryDelay: function (int $retryAfter, int $attempt): void {
        usleep($retryAfter * 1_000_000);
    },
);
```

Custom HTTP Client
------------------

[](#custom-http-client)

The SDK accepts any PSR-18 compatible HTTP client:

```
use ActiveCampaign\Client;

$ac = new Client(
    httpClient: $yourPsr18Client,
);
```

By default, the SDK uses Guzzle 7.

Environment Variables
---------------------

[](#environment-variables)

The SDK reads these environment variables as fallbacks when constructor arguments are not provided:

VariableDescription`ACTIVE_CAMPAIGN_API_URL`Your ActiveCampaign API URL`ACTIVE_CAMPAIGN_API_KEY`Your ActiveCampaign API key```
// Uses environment variables automatically
$ac = new Client();
```

Available Resources
-------------------

[](#available-resources)

Each resource is a method on the client object.

**Core:** `contacts()`, `deals()`, `tags()`, `lists()`, `accounts()`, `automations()`, `campaigns()`, `webhooks()`, `customFields()`, `notes()`, `forms()`, `segments()`, `users()`, `addresses()`

**Deals:** `pipelines()`, `dealStages()`, `dealCustomFields()`, `dealCustomFieldValues()`, `dealRoles()`, `dealTasks()`, `dealTaskTypes()`, `dealTaskOutcomes()`

**Accounts:** `accountContacts()`, `accountCustomFields()`, `accountCustomFieldValues()`

**Contact fields:** `fieldValues()`, `fieldOptions()`

**Communication:** `messages()`, `scores()`

**Admin:** `groups()`, `calendarFeeds()`, `brandings()`, `savedResponses()`, `templates()`, `settings()`

**E-Commerce:** `connections()`, `ecomCustomers()`, `ecomOrders()`, `ecomOrderProducts()`

**Tracking:** `eventTracking()`, `siteTracking()`

**Custom Objects:** `customObjectSchemas()`, `customObjectRecords($schemaId)`

Bugs
----

[](#bugs)

Report issues at [GitHub Issues](https://github.com/relyz-ag/active-campaign-php-sdk/issues).

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance85

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~11 days

Total

2

Last Release

79d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/940c609d8c1fd923dd9a51377304177346edce25f4b2182f37647b4571758536?d=identicon)[relyz](/maintainers/relyz)

---

Top Contributors

[![jonathanwinter123](https://avatars.githubusercontent.com/u/20531661?v=4)](https://github.com/jonathanwinter123 "jonathanwinter123 (1 commits)")

---

Tags

phpapisdkcrmemail marketingMarketing Automationactivecampaignactive campaign

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/relyz-active-campaign-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/relyz-active-campaign-sdk/health.svg)](https://phpackages.com/packages/relyz-active-campaign-sdk)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k26.1M294](/packages/openai-php-client)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35729.6k2](/packages/telnyx-telnyx-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k371.6k6](/packages/theodo-group-llphant)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
