PHPackages                             cx-engine/cx-app-php-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. cx-engine/cx-app-php-sdk

ActiveLibrary[API Development](/categories/api)

cx-engine/cx-app-php-sdk
========================

The Official CXEngine App API PHP Client/SDK

0107↓27.3%PHP

Since Apr 27Pushed 2mo agoCompare

[ Source](https://github.com/CX-engine/cx-app-php-sdk)[ Packagist](https://packagist.org/packages/cx-engine/cx-app-php-sdk)[ RSS](/packages/cx-engine-cx-app-php-sdk/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

CX Engine App PHP SDK
=====================

[](#cx-engine-app-php-sdk)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/6cd52eb78cefbe7e974e0f823b78db3df68a407396e5dcbdf889fbc8617dac27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63782d656e67696e652f63782d6170702d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cx-engine/cx-app-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/a2a2a958cf0921dbe78e56adde38bc2691848930a403d2b67121ec2b9f516ece/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63782d656e67696e652f63782d6170702d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cx-engine/cx-app-php-sdk)

PHP SDK for the CX Engine App API.

- [Installation](#installation)
- [Authentication](#authentication)
    - [Direct Tenant Auth](#authentication-direct)
    - [Central + Workspace Switch](#authentication-switch)
- [Usage](#usage)
    - [Resources](#usage-resources)
    - [Responses](#usage-responses)
    - [Entities](#usage-entities)
    - [Pagination](#usage-pagination)
    - [Extending the SDK](#usage-extends)

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

[](#installation)

This library requires PHP `>=8.2`.

You can install the package via composer:

```
composer require cx-engine/cx-app-php-sdk

```

Authentication
--------------

[](#authentication)

### Direct Tenant Auth

[](#direct-tenant-auth)

To connect directly to a tenant, instantiate `CxEngineConnector` with the tenant URL, email and password:

```
use CXEngine\AppSdk\CxEngineConnector;

$api = new CxEngineConnector(
    apiUrl: 'https://tenant.cx-engine.app',
    email: 'user@example.com',
    password: 'secret',
);
```

On the first request, the connector will POST `/login` with the provided credentials and store the returned Bearer token automatically.

### Central + Workspace Switch

[](#central--workspace-switch)

If you need to authenticate against the central domain first and then switch to a specific workspace, pass `$tenantId` and `$tenantApiUrl`:

```
use CXEngine\AppSdk\CxEngineConnector;

$api = new CxEngineConnector(
    apiUrl: 'https://cx-engine.app',
    email: 'user@example.com',
    password: 'secret',
    tenantId: 'workspace-uuid',
    tenantApiUrl: 'https://tenant.cx-engine.app',
);
```

The connector performs a two-step flow automatically:

1. POST `/login` on the central domain → retrieves a central Bearer token.
2. POST `/switch-to` with `workspace_id` using that token → retrieves a workspace-scoped token.
3. All subsequent requests are sent to `$tenantApiUrl` with the workspace token.

If authentication fails at any step, a `CXEngine\AppSdk\Exceptions\AuthenticationException` is thrown.

Usage
-----

[](#usage)

### Resources

[](#resources)

Resources group related API endpoints into convenient classes. Each resource is accessed via a method on the connector instance:

```
$api->routingContacts(): RoutingContactResource
$api->routingFields():   RoutingFieldResource
$api->geoRouting():      GeoRoutingResource
$api->callQueues():      CallQueueResource
$api->ctis():            CtiResource
$api->cfdTokens():       CfdTokenResource
$api->surveys():         SurveyResource
```

Example usage:

```
use CXEngine\AppSdk\CxEngineConnector;

$api = new CxEngineConnector(...);

// List all routing contacts
$response = $api->routingContacts()->index();

// List active call queues — all smart routing methods require a customer account
$response = $api->callQueues()->index('ACC0001', ['active' => true]);

// Access call queue sub-resources
$response = $api->callQueues()->timeSpans()->index('ACC0001');
$response = $api->callQueues()->groups()->index('ACC0001');
$response = $api->callQueues()->exceptions()->index('ACC0001');
$response = $api->callQueues()->holidays()->index('ACC0001');

// Sub-resources that require a parent ID — pass it to the accessor
$response = $api->ctis()->destinations($ctiId)->index('ACC0001');
$response = $api->ctis()->destinations($ctiId)->show('ACC0001', $destId);

$response = $api->routingFields()->options($fieldId)->index('ACC0001');

// GeoRouting is namespaced into models, lists, and destinations
$response = $api->geoRouting()->models()->index('ACC0001');
$response = $api->geoRouting()->lists()->index('ACC0001');
$response = $api->geoRouting()->lists()->destinations($listId)->index('ACC0001');

// Survey records
$response = $api->surveys()->records()->index('ACC0001');
```

### Responses

[](#responses)

Whether you use Requests or Resources, the response is always an instance of `Saloon\Http\Response`. It provides useful methods to check status and retrieve data:

```
// Check response status
$response->ok();
$response->failed();
$response->status();
$response->headers();

// Get response data
$response->json(); // as an array
$response->body(); // as a raw string
```

You can learn more about responses by reading the [Saloon documentation](https://docs.saloon.dev/the-basics/responses#useful-methods).

### Entities

[](#entities)

Entity classes represent the data structures of the API. They live under `CXEngine\AppSdk\Entities\SmartRoutings\*` and are simple typed value objects.

Use them when creating or updating resources:

```
use CXEngine\AppSdk\CxEngineConnector;
use CXEngine\AppSdk\Entities\SmartRoutings\RoutingContact;

$api = new CxEngineConnector(...);

// Create
$contact = new RoutingContact(
    company: 'Acme Corp',
    first_name: 'John',
    last_name: 'Doe',
    customer_id: 42,
);

$response = $api->routingContacts()->store($contact);

// Update — set the id, then call update()
$contact->id = $response->json('id');
$contact->company = 'Acme Ltd';

$api->routingContacts()->update($contact);
```

You can also serialize an entity to an array at any time:

```
$contact->toArray();             // includes null fields
$contact->toArray(filter: true); // excludes null fields
```

### Pagination

[](#pagination)

On index routes that return paginated results, you can use the connector's `paginate()` method to iterate over all pages:

```
use CXEngine\AppSdk\Requests\SmartRoutings\RoutingContacts\GetRoutingContactsRequest;

// Create a PagedPaginator instance
$paginator = $api->paginate(new GetRoutingContactsRequest(['company' => 'Acme']));

// Iterate over all items across all pages (lazy-loaded)
foreach ($paginator->items() as $item) {
    // $item is the raw array for each record
}
```

Read more about lazy pagination in the [Saloon documentation](https://docs.saloon.dev/installable-plugins/pagination#using-the-paginator).

### Extending the SDK

[](#extending-the-sdk)

You can extend the SDK by creating your own Resources and Requests, then adding them to a custom connector:

```
use CXEngine\AppSdk\CxEngineConnector;

class MyCustomConnector extends CxEngineConnector
{
    public function defaultConfig(): array
    {
        return [
            'timeout' => 120,
        ];
    }

    public function customResource(): \App\Resources\CustomResource
    {
        return new \App\Resources\CustomResource($this);
    }
}

$api = new MyCustomConnector(
    apiUrl: 'https://tenant.cx-engine.app',
    email: 'user@example.com',
    password: 'secret',
);

$api->customResource()->index();
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance58

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 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.

### Community

Maintainers

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

![](https://avatars.githubusercontent.com/u/13690804?v=4)[Cyrille Georgel](/maintainers/cygeorgel)[@cygeorgel](https://github.com/cygeorgel)

---

Top Contributors

[![bastien-teix](https://avatars.githubusercontent.com/u/25428670?v=4)](https://github.com/bastien-teix "bastien-teix (15 commits)")

### Embed Badge

![Health badge](/badges/cx-engine-cx-app-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/cx-engine-cx-app-php-sdk/health.svg)](https://phpackages.com/packages/cx-engine-cx-app-php-sdk)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)[emartech/emarsys-magento2-extension

Magento2 integration for the Emarsys Marketing Platform

14273.9k](/packages/emartech-emarsys-magento2-extension)

PHPackages © 2026

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