{"id":25328667,"url":"https://github.com/kit/convertkitsdk-php","last_synced_at":"2026-03-09T11:02:45.705Z","repository":{"id":47158908,"uuid":"67739356","full_name":"Kit/ConvertKitSDK-PHP","owner":"Kit","description":"Kit official PHP SDK","archived":false,"fork":false,"pushed_at":"2026-03-03T11:33:43.000Z","size":942,"stargazers_count":21,"open_issues_count":5,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-03T12:53:10.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Kit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-09-08T20:50:37.000Z","updated_at":"2025-10-23T18:33:28.000Z","dependencies_parsed_at":"2024-03-18T15:36:41.923Z","dependency_job_id":"fbdbc8ca-796e-4b1e-9a2d-7e45652a4597","html_url":"https://github.com/Kit/ConvertKitSDK-PHP","commit_stats":{"total_commits":126,"total_committers":10,"mean_commits":12.6,"dds":"0.13492063492063489","last_synced_commit":"2d317ea7931f355944d5a811a0be39147b8eb380"},"previous_names":["kit/convertkitsdk-php","convertkit/convertkitsdk-php"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/Kit/ConvertKitSDK-PHP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kit%2FConvertKitSDK-PHP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kit%2FConvertKitSDK-PHP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kit%2FConvertKitSDK-PHP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kit%2FConvertKitSDK-PHP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kit","download_url":"https://codeload.github.com/Kit/ConvertKitSDK-PHP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kit%2FConvertKitSDK-PHP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30291835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-14T02:56:33.730Z","updated_at":"2026-03-09T11:02:45.695Z","avatar_url":"https://github.com/Kit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kit SDK PHP\n\nThe Kit PHP SDK provides convinient access to the Kit API from applications written in the PHP language.\n\nIt includes a pre-defined set of methods for interacting with the API.\n\n## Version Guidance\n\n| SDK Version | API Version | API Authentication | PHP Version  |\n|-------------|-------------|--------------------|--------------|\n| 1.x         | v3          | API Key and Secret | 7.4+         |\n| 2.x         | v4          | OAuth              | 8.0+         |\n| 2.2+        | v4          | API Key            | 8.0+         |\n\nRefer to [this guide](MIGRATION.md) for changes when upgrading to the v2 SDK.\n\n## Composer\n\nYou can install this PHP SDK via [Composer](http://getcomposer.org/). Run the following command:\n\n```bash\ncomposer require convertkit/convertkitapi\n```\n\nTo use the PHP SDK, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):\n\n```php\nrequire_once 'vendor/autoload.php';\n```\n\n## Dependencies\n\nThe PHP SDK require the following extensions in order to work properly:\n\n-   [`curl`](https://secure.php.net/manual/en/book.curl.php), although you can use your own non-cURL client if you prefer\n-   [`json`](https://secure.php.net/manual/en/book.json.php)\n-   [`mbstring`](https://secure.php.net/manual/en/book.mbstring.php) (Multibyte String)\n\nIf you use Composer, these dependencies should be handled automatically.\n\n## Getting Started\n\n### 2.x (v4 API, OAuth, PHP 8.0+)\n\nFirst, register your OAuth application in the `OAuth Applications` section at https://app.kit.com/account_settings/advanced_settings.\n\nUsing the supplied Client ID and secret, redirect the user to Kit to grant your application access to their Kit account.\n\n```php\n// Require the autoloader (if you're using a PHP framework, this may already be done for you).\nrequire_once 'vendor/autoload.php';\n\n// Initialize the API class.\n$api = new \\ConvertKit_API\\ConvertKit_API(\n    clientID: '\u003cyour_oauth_client_id\u003e',\n    clientSecret: '\u003cyour_oauth_client_secret\u003e'\n);\n\n// Redirect to begin the OAuth process.\nheader('Location: '.$api-\u003eget_oauth_url('\u003cyour_redirect_uri\u003e'));\n```\n\nOnce the user grants your application access to their Kit account, they'll be redirected to your Redirect URI with an authorization code. For example:\n\n`your-redirect-uri?code=\u003cauth_code\u003e`\n\nAt this point, your application needs to exchange the authorization code for an access token and refresh token.\n\n```php\n$result = $api-\u003eget_access_token(\n    authCode: '\u003cauth_code\u003e',\n    redirectURI: '\u003cyour_redirect_uri\u003e'\n);\n```\n\n`$result` is an array comprising of:\n- `access_token`: The access token, used to make authenticated requests to the API\n- `refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired\n- `created_at`: When the access token was created\n- `expires_in`: The number of seconds from `created_at` that the access token will expire\n\nOnce you have an access token, re-initialize the API class with it:\n\n```php\n// Initialize the API class.\n$api = new \\ConvertKit_API\\ConvertKit_API(\n    clientID: '\u003cyour_oauth_client_id\u003e',\n    clientSecret: '\u003cyour_oauth_client_secret\u003e',\n    accessToken: '\u003cyour_access_token\u003e'\n);\n```\n\nTo refresh an access token:\n\n```php\n$result = $api-\u003erefresh_token(\n    refreshToken: '\u003cyour_refresh_token\u003e',\n    redirectURI: '\u003cyour_redirect_uri\u003e'\n);\n```\n\n`$result` is an array comprising of:\n- `access_token`: The access token, used to make authenticated requests to the API\n- `refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired\n- `created_at`: When the access token was created\n- `expires_in`: The number of seconds from `created_at` that the access token will expire\n\nOnce you have refreshed the access token i.e. obtained a new access token, re-initialize the API class with it:\n\n```php\n// Initialize the API class.\n$api = new \\ConvertKit_API\\ConvertKit_API(\n    clientID: '\u003cyour_oauth_client_id\u003e',\n    clientSecret: '\u003cyour_oauth_client_secret\u003e',\n    accessToken: '\u003cyour_new_access_token\u003e'\n);\n```\n\nAPI requests may then be performed:\n\n```php\n$result = $api-\u003eadd_subscriber_to_form(12345, 'joe.bloggs@kit.com');\n```\n\nTo determine whether a new entity / relationship was created, or an existing entity / relationship updated, inspect the HTTP code of the last request:\n\n```php\n$result = $api-\u003eadd_subscriber_to_form(12345, 'joe.bloggs@kit.com');\n$code = $api-\u003egetResponseInterface()-\u003egetStatusCode(); // 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.\n```\n\nThe PSR-7 response can be fetched and further inspected, if required - for example, to check if a header exists:\n\n```php\n$result = $api-\u003eadd_subscriber_to_form(12345, 'joe.bloggs@kit.com');\n$api-\u003egetResponseInterface()-\u003ehasHeader('Content-Length'); // Check if the last API request included a `Content-Length` header\n```\n\n### 2.2+ (v4 API, API Key, PHP 8.0+)\n\nGet your Kit API Key and API Secret [here](https://app.kit.com/account_settings/developer_settings) and set it somewhere in your application.\n\n```php\n// Require the autoloader (if you're using a PHP framework, this may already be done for you).\nrequire_once 'vendor/autoload.php';\n\n// Initialize the API class.\n$api = new \\ConvertKit_API\\ConvertKit_API(\n    apiKey: '\u003cyour_v4_api_key\u003e'\n);\n```\n\n### 1.x (v3 API, API Key and Secret, PHP 7.4+)\n\nGet your Kit API Key and API Secret [here](https://app.kit.com/account_settings/developer_settings) and set it somewhere in your application.\n\n```php\n// Require the autoloader (if you're using a PHP framework, this may already be done for you).\nrequire_once 'vendor/autoload.php';\n\n// Initialize the API class.\n$api = new \\ConvertKit_API\\ConvertKit_API('\u003cyour_public_api_key\u003e', '\u003cyour_secret_api_key\u003e');\n```\n\n## Handling Errors\n\nThe Kit PHP SDK uses Guzzle for all HTTP API requests.  Errors will be thrown as Guzzle's `ClientException` (for 4xx errors),\nor `ServerException` (for 5xx errors).\n\n```php\ntry {\n    $forms = $api-\u003eadd_subscriber_to_form('invalid-form-id');\n} catch (GuzzleHttp\\Exception\\ClientException $e) {\n    // Handle 4xx client errors.\n    die($e-\u003egetMessage());\n} catch (GuzzleHttp\\Exception\\ServerException $e) {\n    // Handle 5xx server errors.\n    die($e-\u003egetMessage());\n}\n```\n\nFor a more detailed error message, it's possible to fetch the API's response when a `ClientException` is thrown:\n\n```php\n// Errors will be thrown as Guzzle's ClientException or ServerException.\ntry {\n    $forms = $api-\u003eform_subscribe('invalid-form-id');\n} catch (GuzzleHttp\\Exception\\ClientException $e) {\n    // Handle 4xx client errors.\n    // For ClientException, it's possible to inspect the API's JSON response\n    // to output an error or handle it accordingly.\n    $error = json_decode($e-\u003egetResponse()-\u003egetBody()-\u003egetContents());\n    die($error-\u003emessage); // e.g. \"Entity not found\".\n} catch (GuzzleHttp\\Exception\\ServerException $e) {\n    // Handle 5xx server errors.\n    die($e-\u003egetMessage());\n}\n```\n\n## Documentation\n\nSee the [PHP SDK docs](./docs/classes/ConvertKit_API/ConvertKit_API.md)\n\n## Contributing\n\nSee our [contributor guide](CONTRIBUTING.md) for setting up your development environment, testing and submitting a PR.\n\nFor Kit, refer to the [deployment guide](DEPLOYMENT.md) on how to publish a new release.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkit%2Fconvertkitsdk-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkit%2Fconvertkitsdk-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkit%2Fconvertkitsdk-php/lists"}