PHPackages                             cronofy/cronofy - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. cronofy/cronofy

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cronofy/cronofy
===============

SDK for Cronofy - the Scheduling Platform for Business

v1.7.4(3mo ago)21778.5k↓19.5%32[3 PRs](https://github.com/cronofy/cronofy-php/pulls)MITPHPPHP &gt;=7.1CI passing

Since Nov 10Pushed 3mo ago7 watchersCompare

[ Source](https://github.com/cronofy/cronofy-php)[ Packagist](https://packagist.org/packages/cronofy/cronofy)[ RSS](/packages/cronofy-cronofy/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (106)Used By (0)

Cronofy
=======

[](#cronofy)

[Cronofy](https://www.cronofy.com) - one API for all the calendars (Google, iCloud, Exchange, Office 365, Outlook.com) [![php CI](https://github.com/cronofy/cronofy-php/actions/workflows/ci.yml/badge.svg)](https://github.com/cronofy/cronofy-php/actions/workflows/ci.yml)

Sample Application
------------------

[](#sample-application)

To see this API wrapper in action see our sample app [here](https://github.com/cronofy/cronofy-php-sample-app)

Usage
-----

[](#usage)

> Note: if upgrading from a v0.x.x version to v1.0.0, please read the [migration guide](#migration-guides)

In order to use the Cronofy API you will need to [create a developer account](https://app.cronofy.com/sign_up/new).

From there you can [use your Calendar Sandbox](https://app.cronofy.com/oauth/sandbox)to access your own calendars, or you can [create an OAuth application](https://app.cronofy.com/oauth/applications/new)to obtain an OAuth `client_id` and `client_secret` to be able to use the full API.

Authorization
-------------

[](#authorization)

[API documentation](https://www.cronofy.com/developers/api/#authorization)

Generate a link for a user to grant access to their calendars:

```
$redirect_uri = "http://yoursite.dev/oauth2/callback";

$cronofy = new Cronofy\Cronofy(["client_id" => "CRONOFY_CLIENT_ID"]);
$params = [
  'redirect_uri' => $redirect_uri,
  'scope' => ['read_account','list_calendars','read_events','create_event','delete_event']
];
$auth = $cronofy->getAuthorizationURL($params);
```

The redirect URI is a page on your website that will handle the OAuth 2.0 callback and receive a `code` parameter. You can then use that code to retrieve an OAuth token granting access to the user's Cronofy account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET"
]);

$params = [
  'redirect_uri' => $redirect_uri,
  'code' => $code
];

$result = $cronofy->requestToken($params);

// Retrieve credentials value
$accessToken = $cronofy->accessToken;
$refreshToken = $cronofy->refreshToken;
$expiresIn = $cronofy->expiresIn;
```

You should save the response's `AccessToken` and `RefreshToken` for later use.

Note that the **exact same** redirect URI must be passed to both methods for access to be granted.

`$result` will be `true` for a successful request; otherwise, it will be an error code. Please reference [our documentation](https://docs.cronofy.com/developers/api/authorization/request-authorization/#param-error) for possible error code.

Refresh Access Token
--------------------

[](#refresh-access-token)

Refresh an access token for an account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "grant_type" => "refresh_token",
  "refresh_token" => "YOUR_REFRESH_TOKEN"
]);

$new_access_token = $cronofy->refreshToken();
```

List calendars
--------------

[](#list-calendars)

[API documentation](https://www.cronofy.com/developers/api/#calendars)

Get a list of all the user's calendars:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$calendar = $cronofy->listCalendars();
```

Read events
-----------

[](#read-events)

[API documentation](https://www.cronofy.com/developers/api/#read-events)

Get a list of all the user's events:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'tzid' => 'Etc/UTC'
];

$events = $cronofy->readEvents($params);

foreach($events->each() as $event){
  // process event
}
```

Create or update events
-----------------------

[](#create-or-update-events)

[API documentation](https://www.cronofy.com/developers/api/#upsert-event)

To create or update an event in the user's calendar:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'event_test_12345679',
  'summary' => 'test event 2',
  'description' => 'some event data here',
  'start' => '2015-12-07T09:00:00Z',
  'end' => '2015-12-08T10:00:00Z'
];
$new_event = $cronofy->upsertEvent($params);
```

Delete events
-------------

[](#delete-events)

[API documentation](https://www.cronofy.com/developers/api/#delete-event)

To delete an event from user's calendar:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'EventID'
];

$delete = $cronofy->deleteEvent($params);
```

Delete external events
----------------------

[](#delete-external-events)

To delete an external event from a user's calendar:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'calendar_id' => 'CalendarID',
  'event_uid' => 'EventUID'
];

$delete = $cronofy->deleteExternalEvent($params);
```

Elevated permissions
--------------------

[](#elevated-permissions)

To elevate a client's permissions for a user's calendar(s):

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'permissions' => [
    [
      'calendar_id' => 'CalendarID_1',
      'permission_level' => 'unrestricted'
    ],
    [
      'calendar_id' => 'CalendarID_2',
      'permission_level' => 'unrestricted'
    ]
  ],
  'redirect_uri' => 'http://yoursite.dev/elevate/callback'
];

$response = $cronofy->elevatedPermissions($params);
```

Authorize with a Service Account
--------------------------------

[](#authorize-with-a-service-account)

To authorize a user's account using a service account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'email' => $email,
  'callback_url' => $callback_url,
  'scope' => ['read_account','list_calendars','read_events','create_event','delete_event']
];

$response = $cronofy->authorizeWithServiceAccount($params);
```

Note: You will need to use a Service Account access token to perform this action.

Create a Calendar
-----------------

[](#create-a-calendar)

To create a calendar for a user's account profile:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$params = [
  'profile_id' => $account_profile_id,
  'name' => $new_calendar_name
];

$response = $cronofy->createCalendar($params);
```

Using an Alternative Data Center
--------------------------------

[](#using-an-alternative-data-center)

To use an alternative data center:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken",
  "data_center" => "DataCenter"
]);
```

List Availability Rules
-----------------------

[](#list-availability-rules)

To retrieve all availability rules saved against an account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$response = $cronofy->listAvailabilityRules();
```

Read Availability Rule
----------------------

[](#read-availability-rule)

To retrieve an availability rule:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The String that uniquely identifies the availability rule.
$rule_id = "default";

$response = $cronofy->getAvailabilityRule($rule_id);
```

Delete Availability Rule
------------------------

[](#delete-availability-rule)

To delete an availability rule for the authenticated account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The String that uniquely identifies the availability rule.
$rule_id = "default";

$response = $cronofy->deleteAvailabilityRule($rule_id);
```

Create or Update Availability Rule
----------------------------------

[](#create-or-update-availability-rule)

To create or update an availability rule for the authenticated account:

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

// The details of the event to create or update:
$params = [
    "availability_rule_id" => "default",
    "calendar_ids" => ["cal_123"],
    "tzid" => "America/Chicago",
    "weekly_periods" => [
        [
            "day" => "monday",
            "start_time" => "09:30",
            "end_time" => "12:30"
        ],
        [
            "day" => "wednesday",
            "start_time" => "09:30",
            "end_time" => "12:30"
        ]
    ]
];

$response = $cronofy->createAvailabilityRule($params);
```

Make a Batch request
--------------------

[](#make-a-batch-request)

Send multiple requests as a batch of operations via the \[Batch\]\[() endpoint.

```
$cronofy = new Cronofy\Cronofy([
  "client_id" => "CRONOFY_CLIENT_ID",
  "client_secret" => "CRONOFY_CLIENT_SECRET",
  "access_token" => "AccessToken",
  "refresh_token" => "RefreshToken"
]);

$eventData = [
  'calendar_id' => 'CalendarID',
  'event_id' => 'myapp-event-001',
  'summary' => 'Wyld Stallyns band practice',
  'start' => date("Y-m-d", strtotime('tomorrow')) . "T15:30:00Z",
  'end' => date("Y-m-d", strtotime('tomorrow')) . "T17:00:00Z",
];

$batch = Batch::create()
  ->upsertEvent($calendarId, $testEventData)
  ->deleteEvent($calendarId, $testEventId)

try {
  $result = $cronofy->executeBatch($batch);

  foreach ($result->responses() as $response) {
    // $response->status();
    // $response->headers();
    // $response->data();
    // $response->request();
  }
} catch (PartialBatchFailureException $exception) {
  $result = $exception->result();

  foreach ($result->errors() as $response) {
    // $response->status();
    // $response->headers();
    // $response->data();
    // $response->request();
  }
}
```

Running unit tests
------------------

[](#running-unit-tests)

```
make test
```

Links
-----

[](#links)

- [API documentation](https://www.cronofy.com/developers/api)
- [API mailing list](https://groups.google.com/d/forum/cronofy-api)

Migration guides
----------------

[](#migration-guides)

- `v0.X.X` -&gt; `v1.0.0`: [version `1.0.0`](https://github.com/cronofy/cronofy-php/releases/tag/v1.0.0) adds namespacing and standardizes the names of public methods to camelCase (whereas previously some methods were named with camel\_case). Where in v0.29.0 you would have written `$cronofy = new Cronofy();` and `$calendar = $cronofy->list_calendars();`, for v1.0.0 you should write `$cronofy = new Cronofy\Cronofy();` and `$calendar = $cronofy->listCalendars();`.

A feature I want is not in the SDK, how do I get it?
----------------------------------------------------

[](#a-feature-i-want-is-not-in-the-sdk-how-do-i-get-it)

We add features to this SDK as they are requested, to focus on developing the Cronofy API.

If you're comfortable contributing support for an endpoint or attribute, then we love to receive pull requests! Please create a PR mentioning the feature/API endpoint you’ve added and we’ll review it as soon as we can.

If you would like to request a feature is added by our team then please let us know by getting in touch via .

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance81

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~59 days

Recently: every ~259 days

Total

56

Last Release

102d ago

Major Versions

v0.29.0 → v1.0.02020-03-19

PHP version history (4 changes)v0.12.0PHP ^5.3.3 || ^7.0

v0.25.1PHP ^5.3.3 || ^7.1

v1.0.0PHP ^7.1

v1.5.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/10432b421a58f6fe7f0d1a00058f609a808830ade2e228d2e0dd9caba3ea2ee7?d=identicon)[gshutler](/maintainers/gshutler)

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

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

---

Top Contributors

[![Haziba](https://avatars.githubusercontent.com/u/631626?v=4)](https://github.com/Haziba "Haziba (87 commits)")[![stephenbinns](https://avatars.githubusercontent.com/u/1804518?v=4)](https://github.com/stephenbinns "stephenbinns (80 commits)")[![AdamWhittingham](https://avatars.githubusercontent.com/u/439969?v=4)](https://github.com/AdamWhittingham "AdamWhittingham (73 commits)")[![tomhazledine](https://avatars.githubusercontent.com/u/5412181?v=4)](https://github.com/tomhazledine "tomhazledine (38 commits)")[![gshutler](https://avatars.githubusercontent.com/u/81344?v=4)](https://github.com/gshutler "gshutler (18 commits)")[![kr-mykyta](https://avatars.githubusercontent.com/u/83410871?v=4)](https://github.com/kr-mykyta "kr-mykyta (17 commits)")[![mkarnicki](https://avatars.githubusercontent.com/u/2966794?v=4)](https://github.com/mkarnicki "mkarnicki (15 commits)")[![Grajo](https://avatars.githubusercontent.com/u/38582377?v=4)](https://github.com/Grajo "Grajo (12 commits)")[![adambird](https://avatars.githubusercontent.com/u/272856?v=4)](https://github.com/adambird "adambird (10 commits)")[![ColBeanz](https://avatars.githubusercontent.com/u/23498437?v=4)](https://github.com/ColBeanz "ColBeanz (8 commits)")[![ManuDoni](https://avatars.githubusercontent.com/u/10022459?v=4)](https://github.com/ManuDoni "ManuDoni (6 commits)")[![kgrab75](https://avatars.githubusercontent.com/u/6204172?v=4)](https://github.com/kgrab75 "kgrab75 (5 commits)")[![victor-cronofy](https://avatars.githubusercontent.com/u/88316115?v=4)](https://github.com/victor-cronofy "victor-cronofy (4 commits)")[![qmeister](https://avatars.githubusercontent.com/u/884784?v=4)](https://github.com/qmeister "qmeister (4 commits)")[![CronofyMatt](https://avatars.githubusercontent.com/u/116579200?v=4)](https://github.com/CronofyMatt "CronofyMatt (4 commits)")[![Nevett](https://avatars.githubusercontent.com/u/1307200?v=4)](https://github.com/Nevett "Nevett (4 commits)")[![splagemann](https://avatars.githubusercontent.com/u/4512512?v=4)](https://github.com/splagemann "splagemann (3 commits)")[![Jack97](https://avatars.githubusercontent.com/u/19285044?v=4)](https://github.com/Jack97 "Jack97 (3 commits)")[![jht89](https://avatars.githubusercontent.com/u/857322?v=4)](https://github.com/jht89 "jht89 (2 commits)")[![lekoala](https://avatars.githubusercontent.com/u/250762?v=4)](https://github.com/lekoala "lekoala (2 commits)")

---

Tags

clientAuthenticationoauthoauth2authorizationcalendarcronofy

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[cakedc/oauth2-cognito

Cognito OAuth 2.0 Client Provider for The PHP League OAuth2-Client

18597.7k](/packages/cakedc-oauth2-cognito)

PHPackages © 2026

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