PHPackages                             zaius/zaius-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. zaius/zaius-php-sdk

ActiveLibrary[API Development](/categories/api)

zaius/zaius-php-sdk
===================

The Zaius SDK for PHP. Validated for use in zaius-magento-2, users in custom environments are encouraged to test and validate thoroughly (and note any issues via the GitHub issue tracker).

1.0.2(1y ago)567.2k↓39.3%2[2 issues](https://github.com/ZaiusInc/zaius-php-sdk/issues)[1 PRs](https://github.com/ZaiusInc/zaius-php-sdk/pulls)3MITPHPPHP &gt;=5.5CI failing

Since Feb 20Pushed 2mo ago8 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (16)Used By (3)

Zaius SDK for PHP
=================

[](#zaius-sdk-for-php)

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

[](#getting-started)

The Zaius SDK provides a programmatic interface for the Zaius API as documented at  .

To get started, include the library in your project:

```
composer require zaius/zaius_sdk
```

You can get an instance of the Zaius client using:

```
$zaiusClient = new \ZaiusSDK\ZaiusClient($apiKey);
```

The API key can be obtained from your Zaius account at [https://app.zaius.com/app#/api\_management](https://app.zaius.com/app#/api_management) . Click on the "Private" tab and use the private API key.

Available methods
-----------------

[](#available-methods)

### Customer management

[](#customer-management)

#### Create/update a customer

[](#createupdate-a-customer)

The method takes in a single array with the customer object or an array of customer objects

Example:

```
$profile = array();
$profile['email'] = 'test3@example.com';
$ret = $zaiusClient->postCustomer($profile);
```

#### Get a customer

[](#get-a-customer)

This method takes in a filter array with the following possible keys:

- email
- vuid
- customer\_id

Note that you need to pass only one of the above. Also, the API supports only exact matches for each field.

Example:

```
$filter = ['email'=>'clay@example.com'];
$profile = $zaiusClient->getCustomer($filter);
```

### Events

[](#events)

#### Post an event

[](#post-an-event)

Posts an event. The event array object method must have the following keys:

- type - the type of the event (i.e. product)
- action - the event's action (i.e. add\_to\_cart)
- identifiers - an array with the identifiers. Valid keys are vuid and email
- data - an array with the event-specific data. The full list of the supported values is available at

You can pass an array of events for bulk upload.

Example:

```
$event = array();
$event['type'] = 'test';
$event['action'] = 'test';
$event['identifiers'] = ['vuid'=>'test'];
$event['data'] = ['a'=>'b'];
$ret = $zaiusClient->postEvent($event);
```

### List management

[](#list-management)

#### Create a list

[](#create-a-list)

Creates a list with the given name.

Example:

```
$list = array();
$list['name'] = uniqid();

$zaiusClient->createList($list);
```

#### Get all lists

[](#get-all-lists)

Returns all lists.

Example:

```
$lists = $zaiusClient->getLists();
```

#### Update a list

[](#update-a-list)

Updates a list's name. The method expects the following parameters:

- $listId - the ID of the list to change (get it with a getLists() call)
- $newName - the new name for the list

Example:

```
$zaiusClient->changeListName('madison_island_newsletter','Renamed list');
```

### Subscription management

[](#subscription-management)

#### Get subscriptions

[](#get-subscriptions)

Gets subscriptions based on a filter. The lists of accepted filters is available at  .

Example:

```
$filters = ['email'=>'janesmith@example.com'];
$subscriptions = $zaiusClient->getSubscriptions($filters);
```

#### Update subscription

[](#update-subscription)

Updates a subscription. The subscription array can have three keys:

- list\_id (optional) - the list for which to update the subscription
- email - the email to update the subscription for
- subscribed - true/false - whether to subscribe or unsubscribe the user

The method also supports passing an array of subscriptions for bulk updates.

Example:

```
$subscription = array();
$subscription['list_id'] = 'zaius_all';
$subscription['email'] = 'janesmith@example.com';
$subscription['subscribed'] = true;

$ret = $zaiusClient->updateSubscription($subscription);
```

#### Update channel opt-in

[](#update-channel-opt-in)

Updates a subscription. Parameters:

- optedIn - true/false
- email - email address

Example:

```
$zaiusClient->updateChannelOptIn(false,'janesmith@example.com');
```

### Exports

[](#exports)

#### Export all objects

[](#export-all-objects)

Exports all objects. Parameters:

- objects - array with objects type to export, i.e. array('orders','products'). Leave empty to export all object types
- format - one of csv, parquet. Defaults to csv
- delimiter - one of comma,tab, pipe. Defaults to comma.

Example:

```
$zaiusClient->exportAllObjects()
```

#### Export filtered objects

[](#export-filtered-objects)

Export objects given a filter.

Parameters:

- filter - an array with the filter as described at
- format - one of csv, parquet. Defaults to csv
- delimiter - one of comma,tab, pipe. Defaults to comma.

Example:

```
$zaiusClient->exportObjectsWithFilters(array('object'=>'events'));
```

#### Get the export status

[](#get-the-export-status)

Gets the status of an export. Parameters:

- exportId - the export id

Example:

```
$zaiusClient->getExportStatus(1223233);
```

### Schema API

[](#schema-api)

#### Get all available objects

[](#get-all-available-objects)

Returns an array with all available objects schemas.

Example:

```
$zaiusClient->getObjects()
```

#### Get object schema

[](#get-object-schema)

Returns the schema for the specified object.

Parameters:

- objectType - a valid object type. Get all object types with the getObjects() method

Example:

```
 $zaiusClient->getObject('products')
```

#### Create a new object type

[](#create-a-new-object-type)

Creates a new object type. Parameters:

- object (unique) id
- object name
- alias
- field definition array
- relation definition array

Example:

```
$fields =  [
    [
        'name' => 'object_id',
        "display_name"=> "New Object Identifier",
        "type"=> "string",
        "primary"=> true
    ],
    [
        "name"=> "another_field",
        "display_name"=> "Another Fields",
        "type"=> "string"
    ],
    [
        "name"=> "child_id",
        "display_name"=> "Child Identifier",
        "type"=> "number"
    ]
];

$relations = [
];

$zaiusClient->createObjectSchema('test_objects', 'Test Object', 'test_object', $fields, $relations);

```

#### Get an object's fields

[](#get-an-objects-fields)

Gets the fields for an object. Parameters:

- object id

Example:

```
$zaiusClient->getObjectFields('products');
```

#### Create a new field for an object

[](#create-a-new-field-for-an-object)

Creates a new field for an object. Parameters:

- object id
- field id
- field type
- field name
- field description

Example:

```
$zaiusClient->createObjectField('products','test_field','string','Test field','Test description');
```

#### Get all object's relations

[](#get-all-objects-relations)

Gets all relations for an object. Parameters:

- object id

Example:

```
$zaiusClient->getRelations('products')
```

### Posting objects

[](#posting-objects)

#### Post a product

[](#post-a-product)

```
$product = array();
$product['name'] = "Test product";
$product['sku'] = 'test-sku';
$product['product_id'] = 32;

$ret = $zaiusClient->postProduct($product);
```

This method also supports passing an array of products for bulk updates.

#### Post a customer

[](#post-a-customer)

```
$profile = array();
$profile['email'] = 'test3@example.com';
$ret = $zaiusClient->postCustomer($profile);
```

This method also supports passing an array of customers for bulk updates.

#### Post an order

[](#post-an-order)

```
$order = array();
$order['name'] = "Test customer";
$order['order_id'] = '11111';
$order['total'] = 32;
$order['items'] = [[
    "product_id"=>"765",
    "sku"=>"zm64",
    "quantity"=>"1",
    "subtotal"=>"59.95"
]];

$ret = $zaiusClient->postOrder($order);
```

This method also supports passing an array of orders for bulk updates.

#### Posting custom objects

[](#posting-custom-objects)

Creates (or updates) an object. Parameters:

- object id
- array with the object data. Must include all required fields per the object's schema.

This method supports passing an array of objects for bulk updates.

Example:

```
$zaiusClient->postObject('products',['product_id'=>33,'name'=>'test product']);
```

### Bulk upload objects to S3

[](#bulk-upload-objects-to-s3)

The S3 client can be obtained from the Zaius Client:

```
$zaiusClient = new \ZaiusSDK\ZaiusClient($apiKey);
$s3Client = $zaiusClient->getS3Client(ZAIUS_TRACKER_ID,ZAIUS_S3_KEY_ID,ZAIUS_S3_SECRET);
```

To get the needed keys, check

#### Events

[](#events-1)

```
$event1 = array();
$event1['type'] = 'product';
$event1['action'] = 'addtocart';
$event1['identifiers'] = ['customer_id'=>99];
$event1['data'] = ['hostname'=>'127.0.0.1','page'=>'Bar'];

$event2 = array();
$event2['type'] = 'product';
$event2['action'] = 'addtocart';
$event2['identifiers'] = ['customer_id'=>99];
$event2['data'] = ['hostname'=>'127.0.0.1','page'=>'Foo'];

$events = [$event1,$event2];

$s3Client->uploadEvents($events);
```

#### Products

[](#products)

```
$product1 = array();
$product1['product_id'] = 1;
$product1['sku'] = '1234';
$product1['name'] = "Planet of the Apes";
$product1['category'] = 'Books';

$product2 = array();
$product2['product_id'] = 2;
$product2['sku'] = '4321';
$product2['name'] = "Escape from Planet of the Apes";
$product2['category']  = 'Movies';

$products = [
    $product1,$product2
];

$s3Client->uploadProducts($products);
```

#### Customers

[](#customers)

```
$customer1 = array();
$customer1['customer_id'] = 1100;
$customer1['email'] = "floyd22@example.com";
$customer1['first_name'] = "Floyd";
$customer1['last_name'] = 'Dogg';
$customer1['foo'] = 'bar';

$customer2 = array();
$customer2['customer_id'] = 1200;
$customer2['email'] = "johnny22@example.com";
$customer2['first_name'] = "Johnny";
$customer2['last_name'] = 'Zaius';
$customer2['foo']='bar';

$customers = [
    $customer1,$customer2
];

$s3Client->uploadCustomers($customers);
```

#### Orders

[](#orders)

```
$orderData = [];
$order1 = array();
$order1['order_id'] = '1009';
$order1['items']=[[
    "product_id"=>"765",
    "sku"=>"zm64",
    "quantity"=>"1",
    "subtotal"=>"59.95"
]];
$order1['subtotal'] = 6.99;
$order1['tax'] = 0;
$order1['shipping'] = 25.75;
$order1['total'] = 32.74;
$order1['email'] = 'floyd@zaius.com';
$order1['first_name'] = 'Floyd';
$order1['last_name'] = 'Dogg';
$order1['phone'] = '123456780';

$orderData['order'] = $order1;
$orderData['identifiers'] = ['ts'=>1460392935,'ip'=>'192.168.1.1','email'=>'floyd@zaius.com','action'=>'purchase'];

$orders = [$orderData];

$s3Client->uploadOrders($orders);
```

Supported object types
----------------------

[](#supported-object-types)

All Zaius methods expect arrays in a specific format. Besides the keys listed for each object, any other key/value pair is accepted and will be sent as a custom field, if it was defined via the Zaius dashboard/schema API

To see the full list of available fields, access [https://app.zaius.com/app#/custom\_fields](https://app.zaius.com/app#/custom_fields) after logging in into your Zaius account.

### Customers

[](#customers-1)

KeyTypeOther detailsemailstringgenderstringnamestringfirst\_namestringlast\_namestringphonestringtimezonestringThe timezone of the user in the following format: [https://en.wikipedia.org/wiki/List\_of\_tz\_database\_time\_zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)street1stringstreet2stringcitystringstatestringzipstringcountrystringimage\_urlstringcustomer\_idstringExample:

```
$customer = array();
$customer['email'] = 'test3@example.com';
```

### Events

[](#events-2)

KeyTypeOther detailstypestringactionstringidentifiers.emailstringidentifiers.vuidstringdata.tsintegerTimestamp of the event in unix time (epoch time). Automatically set to now if not present.data.product\_idstringdata.categorystringdata.channelstringdata.uastringUser agentdata.ipstringdata.titlestringdata.hostnamestringdata.pagestringdata.sourcestringdata.mediumstringdata.campaignstringdata.contentstringdata.keywordsstringdata.languagestringdata.character\_setstringdata.days\_since\_last\_visitintegerdata.landingbooldata.referrerstringdata.search\_termstringdata.filter\_fieldstringdata.filter\_valuestringdata.sort\_directionstringdata.sort\_fieldstringExample:

```
$event = array();
$event['type'] = 'test';
$event['action'] = 'test';
$event['identifiers'] = ['vuid'=>'test'];
$event['data'] = ['a'=>'b'];
```

### Products

[](#products-1)

KeyTypeOther detailsbrandstringcategory\_idintegerdescriptionstringimage\_urlstringis\_in\_stockboolnamestringparent\_product\_idintegerpricenumberproduct\_idstringqtyintegerskustringspecial\_pricenumberspecial\_price\_from\_datetimestampspecial\_price\_to\_datetimestampupcstringExample:

```
$product = array();
$product['name'] = "Test product";
$product['sku'] = 'test-sku';
$product['product_id'] = 32;
```

### Orders

[](#orders-1)

KeyTypeOther detailsbill\_addressstringcoupon\_codestringfirst\_namestringlast\_namestringnamestringdiscountnumberemailstringorder\_idstringphonestringship\_addressstringshippingnumberstatustextsubtotalnumbertaxnumbertotalnumberuser\_idstringitems.product\_idstringitems.skustringitems.quantityintegeritems.subtotalnumberExample:

```
$order = array();
$order['name'] = "Test customer";
$order['order_id'] = '11111';
$order['total'] = 32;
$order['items'] = [[
    "product_id"=>"765",
    "sku"=>"zm64",
    "quantity"=>"1",
    "subtotal"=>"59.95"
]];
```

Generic API calls
-----------------

[](#generic-api-calls)

While the SDK covers all specific operations, it is possible to initiate a general call to the API by using the call() method. Three parameters are expected:

- $parameters - an array of parameters. For get calls, they will be sent as url parameters. For post / put calls, they will be sent as post fields
- $method - a valid http method name, i.e. post or get
- $url - the full endpoint url

The method returns the raw API response. Note that most of the time, this will be a json encoded string.

The method throws a ZaiusException in case the response code is any other than 20x or 404. A 404 response code returns a null body and represents the fact that no entry was found for the provided query.

Example:

```
$zaiusClient = $this->getZaiusClient(ZAIUS_PRIVATE_API_KEY);
$filter = ['email'=>'clay@example.com'];
$profile = json_decode($zaiusClient->call($filter,'get',ZaiusClient::API_URL_V3.'/profiles'),true);
```

Batch processing
----------------

[](#batch-processing)

While the Zaius API is fast, it is possible to completely decouple it by using batch processing. We are making use of DJJob,  as a general queueing mechanism.

### Setup

[](#setup)

Initialize the mysql database:

```
mysql my_database setQueueDatabaseCredentials([
    'driver' => 'mysql',
    'host' => '127.0.0.1',
    'dbname' => 'my_database',
    'user' => 'my_user',
    'password' => 'my_password',
]);
```

### Push events to the queue

[](#push-events-to-the-queue)

All posting methods have a queue bool parameter that you can set to push to the queue instead of processing instantly:

```
$profile = array();
$profile['email'] = 'test3@example.com';
$ret = $zaiusClient->postCustomer($profile,true);

$product = array();
$product['name'] = "Test product";
$product['sku'] = 'test-sku';
$product['product_id'] = 32;
$ret = $zaiusClient->postProduct($product,true);
```

The returned value from the post calls will be the mysql insert id of the pushed object.

You can later process the queue with:

```
$worker = new \ZaiusSDK\Zaius\Worker();
$worker->processAll();
```

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance55

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 81.3% 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 ~395 days

Recently: every ~493 days

Total

6

Last Release

667d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24590110?v=4)[Charlie Brensinger](/maintainers/cBrenDev)[@cBrenDev](https://github.com/cBrenDev)

![](https://www.gravatar.com/avatar/6222b0fed0d7e27fa5ff53ce20bbf1c7c9110e203571608b95b410d505c8721a?d=identicon)[lkreisberg@zaius.com](/maintainers/lkreisberg@zaius.com)

---

Top Contributors

[![travish](https://avatars.githubusercontent.com/u/169255?v=4)](https://github.com/travish "travish (13 commits)")[![manuelnt11](https://avatars.githubusercontent.com/u/7607637?v=4)](https://github.com/manuelnt11 "manuelnt11 (2 commits)")[![NateSwanson7](https://avatars.githubusercontent.com/u/31102449?v=4)](https://github.com/NateSwanson7 "NateSwanson7 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zaius-zaius-php-sdk/health.svg)

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

###  Alternatives

[sociallydev/spaces-api

Library for accessing Digital Ocean spaces

218428.6k](/packages/sociallydev-spaces-api)[thephalcons/amazon-webservices-bundle

A Symfony2 Bundle for interfacing with Amazon Web Services (AWS)

110224.7k](/packages/thephalcons-amazon-webservices-bundle)[keboola/storage-api-client

Keboola Storage API PHP Client

10387.5k25](/packages/keboola-storage-api-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1344.8k1](/packages/jasara-php-amzn-selling-partner-api)[cion/laravel-text-to-speech

This package creates a shared API to easily use Text to Speech functionalities amongst different TTS providers.

4228.3k](/packages/cion-laravel-text-to-speech)[larareko/aws-rekognition

A Laravel package for the AWS Rekognition

2013.1k](/packages/larareko-aws-rekognition)

PHPackages © 2026

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