PHPackages                             convertkit/convertkitapi - 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. convertkit/convertkitapi

ActiveLibrary[API Development](/categories/api)

convertkit/convertkitapi
========================

Kit PHP SDK for the Kit API

2.4(2mo ago)2167.1k↓17.5%24[1 PRs](https://github.com/Kit/ConvertKitSDK-PHP/pulls)1GPLv3PHPPHP &gt;=8.0CI passing

Since Jul 23Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/Kit/ConvertKitSDK-PHP)[ Packagist](https://packagist.org/packages/convertkit/convertkitapi)[ Docs](https://developers.kit.com/welcome)[ RSS](/packages/convertkit-convertkitapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (18)Used By (1)

Kit SDK PHP
===========

[](#kit-sdk-php)

The Kit PHP SDK provides convinient access to the Kit API from applications written in the PHP language.

It includes a pre-defined set of methods for interacting with the API.

Version Guidance
----------------

[](#version-guidance)

SDK VersionAPI VersionAPI AuthenticationPHP Version1.xv3API Key and Secret7.4+2.xv4OAuth8.0+2.2+v4API Key8.0+Refer to [this guide](MIGRATION.md) for changes when upgrading to the v2 SDK.

Composer
--------

[](#composer)

You can install this PHP SDK via [Composer](http://getcomposer.org/). Run the following command:

```
composer require convertkit/convertkitapi
```

To use the PHP SDK, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once 'vendor/autoload.php';
```

Dependencies
------------

[](#dependencies)

The PHP SDK require the following extensions in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer
- [`json`](https://secure.php.net/manual/en/book.json.php)
- [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)

If you use Composer, these dependencies should be handled automatically.

Getting Started
---------------

[](#getting-started)

### 2.x (v4 API, OAuth, PHP 8.0+)

[](#2x-v4-api-oauth-php-80)

First, register your OAuth application in the `OAuth Applications` section at [https://app.kit.com/account\_settings/advanced\_settings](https://app.kit.com/account_settings/advanced_settings).

Using the supplied Client ID and secret, redirect the user to Kit to grant your application access to their Kit account.

```
// Require the autoloader (if you're using a PHP framework, this may already be done for you).
require_once 'vendor/autoload.php';

// Initialize the API class.
$api = new \ConvertKit_API\ConvertKit_API(
    clientID: '',
    clientSecret: ''
);

// Redirect to begin the OAuth process.
header('Location: '.$api->get_oauth_url(''));
```

Once the user grants your application access to their Kit account, they'll be redirected to your Redirect URI with an authorization code. For example:

`your-redirect-uri?code=`

At this point, your application needs to exchange the authorization code for an access token and refresh token.

```
$result = $api->get_access_token(
    authCode: '',
    redirectURI: ''
);
```

`$result` is an array comprising of:

- `access_token`: The access token, used to make authenticated requests to the API
- `refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired
- `created_at`: When the access token was created
- `expires_in`: The number of seconds from `created_at` that the access token will expire

Once you have an access token, re-initialize the API class with it:

```
// Initialize the API class.
$api = new \ConvertKit_API\ConvertKit_API(
    clientID: '',
    clientSecret: '',
    accessToken: ''
);
```

To refresh an access token:

```
$result = $api->refresh_token(
    refreshToken: '',
    redirectURI: ''
);
```

`$result` is an array comprising of:

- `access_token`: The access token, used to make authenticated requests to the API
- `refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired
- `created_at`: When the access token was created
- `expires_in`: The number of seconds from `created_at` that the access token will expire

Once you have refreshed the access token i.e. obtained a new access token, re-initialize the API class with it:

```
// Initialize the API class.
$api = new \ConvertKit_API\ConvertKit_API(
    clientID: '',
    clientSecret: '',
    accessToken: ''
);
```

API requests may then be performed:

```
$result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit.com');
```

To determine whether a new entity / relationship was created, or an existing entity / relationship updated, inspect the HTTP code of the last request:

```
$result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit.com');
$code = $api->getResponseInterface()->getStatusCode(); // 200 OK if e.g. a subscriber already added to the specified form, 201 Created if the subscriber added to the specified form for the first time.
```

The PSR-7 response can be fetched and further inspected, if required - for example, to check if a header exists:

```
$result = $api->add_subscriber_to_form(12345, 'joe.bloggs@kit.com');
$api->getResponseInterface()->hasHeader('Content-Length'); // Check if the last API request included a `Content-Length` header
```

### 2.2+ (v4 API, API Key, PHP 8.0+)

[](#22-v4-api-api-key-php-80)

Get your Kit API Key and API Secret [here](https://app.kit.com/account_settings/developer_settings) and set it somewhere in your application.

```
// Require the autoloader (if you're using a PHP framework, this may already be done for you).
require_once 'vendor/autoload.php';

// Initialize the API class.
$api = new \ConvertKit_API\ConvertKit_API(
    apiKey: ''
);
```

### 1.x (v3 API, API Key and Secret, PHP 7.4+)

[](#1x-v3-api-api-key-and-secret-php-74)

Get your Kit API Key and API Secret [here](https://app.kit.com/account_settings/developer_settings) and set it somewhere in your application.

```
// Require the autoloader (if you're using a PHP framework, this may already be done for you).
require_once 'vendor/autoload.php';

// Initialize the API class.
$api = new \ConvertKit_API\ConvertKit_API('', '');
```

Handling Errors
---------------

[](#handling-errors)

The Kit PHP SDK uses Guzzle for all HTTP API requests. Errors will be thrown as Guzzle's `ClientException` (for 4xx errors), or `ServerException` (for 5xx errors).

```
try {
    $forms = $api->add_subscriber_to_form('invalid-form-id');
} catch (GuzzleHttp\Exception\ClientException $e) {
    // Handle 4xx client errors.
    die($e->getMessage());
} catch (GuzzleHttp\Exception\ServerException $e) {
    // Handle 5xx server errors.
    die($e->getMessage());
}
```

For a more detailed error message, it's possible to fetch the API's response when a `ClientException` is thrown:

```
// Errors will be thrown as Guzzle's ClientException or ServerException.
try {
    $forms = $api->form_subscribe('invalid-form-id');
} catch (GuzzleHttp\Exception\ClientException $e) {
    // Handle 4xx client errors.
    // For ClientException, it's possible to inspect the API's JSON response
    // to output an error or handle it accordingly.
    $error = json_decode($e->getResponse()->getBody()->getContents());
    die($error->message); // e.g. "Entity not found".
} catch (GuzzleHttp\Exception\ServerException $e) {
    // Handle 5xx server errors.
    die($e->getMessage());
}
```

Documentation
-------------

[](#documentation)

See the [PHP SDK docs](./docs/classes/ConvertKit_API/ConvertKit_API.md)

Contributing
------------

[](#contributing)

See our [contributor guide](CONTRIBUTING.md) for setting up your development environment, testing and submitting a PR.

For Kit, refer to the [deployment guide](DEPLOYMENT.md) on how to publish a new release.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity42

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 95.9% 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 ~228 days

Recently: every ~172 days

Total

10

Last Release

72d ago

Major Versions

0.1 → 1.02023-03-23

1.3 → 2.02024-04-17

PHP version history (3 changes)0.1PHP &gt;=5.5

1.0PHP &gt;=7.4

2.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fbbdfe5fda6c7a2f1092042599d5eac50abb256532608fc8d3f6ea2d3a66f294?d=identicon)[tnorthcutt](/maintainers/tnorthcutt)

---

Top Contributors

[![n7studios](https://avatars.githubusercontent.com/u/1462305?v=4)](https://github.com/n7studios "n7studios (494 commits)")[![growdev](https://avatars.githubusercontent.com/u/290886?v=4)](https://github.com/growdev "growdev (5 commits)")[![tnorthcutt](https://avatars.githubusercontent.com/u/796639?v=4)](https://github.com/tnorthcutt "tnorthcutt (5 commits)")[![fideloper](https://avatars.githubusercontent.com/u/467411?v=4)](https://github.com/fideloper "fideloper (4 commits)")[![jhull](https://avatars.githubusercontent.com/u/27031243?v=4)](https://github.com/jhull "jhull (2 commits)")[![intellow](https://avatars.githubusercontent.com/u/40676515?v=4)](https://github.com/intellow "intellow (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![iamcaptaincode](https://avatars.githubusercontent.com/u/9145531?v=4)](https://github.com/iamcaptaincode "iamcaptaincode (1 commits)")[![bogusred](https://avatars.githubusercontent.com/u/8145300?v=4)](https://github.com/bogusred "bogusred (1 commits)")[![jeroenvanrensen](https://avatars.githubusercontent.com/u/46967616?v=4)](https://github.com/jeroenvanrensen "jeroenvanrensen (1 commits)")

---

Tags

apitagsFormskitemailssequencessubscribersConvertKitbroadcasts

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/convertkit-convertkitapi/health.svg)

```
[![Health](https://phpackages.com/badges/convertkit-convertkitapi/health.svg)](https://phpackages.com/packages/convertkit-convertkitapi)
```

###  Alternatives

[openai-php/laravel

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

3.7k7.6M74](/packages/openai-php-laravel)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

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