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

ActiveLibrary

supportlayer/php-sdk
====================

Official PHP SDK for the SupportLayer REST API

00PHP

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/XegenLtd/SupportLayer-PHP-SDK)[ Packagist](https://packagist.org/packages/supportlayer/php-sdk)[ RSS](/packages/supportlayer-php-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SupportLayer PHP SDK
====================

[](#supportlayer-php-sdk)

Official PHP SDK for the [SupportLayer](https://www.supportlayer.app) REST API.

Requirements
------------

[](#requirements)

- PHP 8.1 or later
- cURL extension
- JSON extension

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

[](#installation)

Install via Composer:

```
composer require supportlayer/php-sdk
```

Quick start
-----------

[](#quick-start)

```
use SupportLayer\SupportLayerClient;

$client = new SupportLayerClient('https://www.supportlayer.app', 'sl_live_YOUR_API_KEY');

// List open tickets
$response = $client->tickets->list(['status' => 'open']);

foreach ($response['data'] as $ticket) {
    echo $ticket['id'] . ': ' . $ticket['subject'] . "\n";
}
```

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

[](#authentication)

All requests require an API key. Generate one from the **API keys** page in your SupportLayer admin panel. Pass it as the second argument when creating the client:

```
$client = new SupportLayerClient('https://www.supportlayer.app', 'sl_live_...');
```

You can optionally set a custom timeout (in seconds) as the third argument:

```
$client = new SupportLayerClient('https://www.supportlayer.app', 'sl_live_...', 60);
```

Usage
-----

[](#usage)

### Tickets

[](#tickets)

```
// List tickets with filters
$tickets = $client->tickets->list([
    'status'   => 'open',       // status machine key, or "overdue"
    'assignee' => 'unassigned', // user ID, "me", or "unassigned"
    'category' => 2,            // category ID
    'product'  => 1,            // product ID
    'sla'      => 'at_risk',    // "at_risk" for tickets due within 2 hours
    'search'   => 'login',      // search subject or ticket ID
]);

// Get a single ticket
$ticket = $client->tickets->get(42);

// Create a ticket
$ticket = $client->tickets->create([
    'subject'        => 'Cannot export report',
    'body'           => 'The export button returns a 500 error in Safari.',
    'urgency_id'     => 3,
    'category_id'    => 2,
    'product_id'     => 1,
    'assignee_id'    => 12,
    'reporter_email' => 'sam@example.com',
    'tag_ids'        => [1, 3],
]);

// Update a ticket (only include fields you want to change)
$client->tickets->update(42, [
    'status_id'   => 2,
    'assignee_id' => 12,
    'product_id'  => 3,
]);

// Close a ticket
$client->tickets->close(42);

// Assign or unassign
$client->tickets->assign(42, 12);   // assign to user 12
$client->tickets->assign(42, null); // unassign

// Escalate to a target user
$client->tickets->escalate(42, 8);
```

### Messages

[](#messages)

```
// List messages on a ticket
$messages = $client->messages->list(42);

// Add a public reply
$client->messages->create(42, [
    'body' => 'This has been fixed in the latest release.',
]);

// Add an internal note
$client->messages->create(42, [
    'body'     => 'Escalating to engineering — this is a regression.',
    'internal' => true,
]);
```

### Lookups

[](#lookups)

Fetch the configuration data for your workspace. Use these to get valid IDs before creating or updating tickets.

```
$statuses  = $client->lookups->statuses();
$categories = $client->lookups->categories();
$urgencies = $client->lookups->urgencies();
$tags      = $client->lookups->tags();
$products  = $client->lookups->products();
```

### Users

[](#users)

```
// List all active users in the organization
$users = $client->users->list();

// Get a single user
$user = $client->users->get(5);
```

### End users

[](#end-users)

```
// List all end users
$endUsers = $client->endUsers->list();

// Create an end user
$endUser = $client->endUsers->create([
    'email'      => 'sam@example.com',
    'first_name' => 'Sam',
    'last_name'  => 'Kim',
]);
```

### Statistics

[](#statistics)

```
// Dashboard counters (open, my_open, unassigned, overdue, at_risk, closed_today)
$dashboard = $client->stats->dashboard();

// Reporting data (by_status, avg response time, SLA compliance, by_agent, volume)
$reporting = $client->stats->reporting();
```

Error handling
--------------

[](#error-handling)

The SDK throws typed exceptions for API errors. All exceptions extend `SupportLayer\Exception\SupportLayerException`.

```
use SupportLayer\Exception\AuthenticationException;
use SupportLayer\Exception\NotFoundException;
use SupportLayer\Exception\ValidationException;
use SupportLayer\Exception\ApiException;

try {
    $ticket = $client->tickets->get(999);
} catch (AuthenticationException $e) {
    // 401 — invalid, expired, or revoked API key
    echo 'Auth failed: ' . $e->getMessage();
} catch (NotFoundException $e) {
    // 404 — resource not found
    echo 'Not found: ' . $e->getMessage();
} catch (ValidationException $e) {
    // 422 — missing or invalid fields
    echo 'Validation error: ' . $e->getMessage();
} catch (ApiException $e) {
    // Any other API error
    echo $e->getHttpStatus() . ': ' . $e->getErrorCode() . ' — ' . $e->getMessage();
}
```

ExceptionHTTP StatusWhen`AuthenticationException`401Missing, invalid, expired, or revoked API key`NotFoundException`404Resource does not exist or is not in your organization`ValidationException`422Missing required fields or invalid data`ApiException`Any 4xx/5xxAll other API errorsResponse format
---------------

[](#response-format)

All methods return associative arrays matching the JSON structure from the API. List endpoints return `data` (array of items) and `total`. Single-resource endpoints return `data` (the object).

```
$response = $client->tickets->list(['status' => 'open']);

$response['data'];  // array of ticket objects
$response['total']; // total count

$response = $client->tickets->get(42);

$response['data'];            // the ticket object
$response['data']['id'];      // 42
$response['data']['subject']; // "Cannot export report"
$response['data']['product']; // {"id": 1, "name": "Dashboard", "slug": "dashboard"} or null
```

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

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://avatars.githubusercontent.com/u/71467315?v=4)[Jay Burston](/maintainers/jayburston)[@jayburston](https://github.com/jayburston)

---

Top Contributors

[![jayburston](https://avatars.githubusercontent.com/u/71467315?v=4)](https://github.com/jayburston "jayburston (4 commits)")

### Embed Badge

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

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

PHPackages © 2026

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