PHPackages                             trigv/trigv - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. trigv/trigv

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

trigv/trigv
===========

Official Trigv SDK for PHP — send notification events to your workspace

1.0.0(3d ago)00MITPHP ^8.2

Since Jul 7Compare

[ Source](https://github.com/Trigv/trigv-php)[ Packagist](https://packagist.org/packages/trigv/trigv)[ Docs](https://github.com/Trigv/trigv-php)[ RSS](/packages/trigv-trigv/feed)WikiDiscussions Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

trigv/trigv
===========

[](#trigvtrigv)

Official Trigv SDK for PHP. Send notification events from scripts, servers, Laravel apps, and WordPress plugins.

What Trigv is
-------------

[](#what-trigv-is)

Trigv delivers developer notifications to your team's devices. Your backend sends lightweight JSON events; Trigv queues push delivery. Notification title and body are not stored on Trigv servers — metadata only.

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

[](#installation)

```
composer require trigv/trigv
```

Requires PHP 8.2+ with the `curl` and `json` extensions.

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

[](#quick-start)

```
use Trigv\Client;

$trigv = new Client(['api_key' => getenv('TRIGV_API_KEY')]);

$result = $trigv->sendEvent([
    'channel' => 'general',
    'title' => 'Deploy finished',
    'description' => 'Build #42 succeeded in 38s',
]);
```

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

[](#authentication)

Create a workspace API key at [app.trigv.com](https://app.trigv.com). Keys look like `trgv_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`.

```
$trigv = new Client(['api_key' => 'trgv_your_api_key']);
// or set TRIGV_API_KEY in the environment
```

**Do not** send the API key in the JSON body — use the `Authorization: Bearer` header (handled automatically).

Sending an event
----------------

[](#sending-an-event)

```
$result = $trigv->sendEvent([
    'channel' => 'general',
    'title' => 'Cron job failed',
    'description' => 'Nightly backup did not complete',
    'level' => 'error',
    'event_type' => 'cron.failed',
]);

echo $result->event->public_id;
```

You can also pass a `SendEventRequest` value object:

```
use Trigv\SendEventRequest;

$request = new SendEventRequest(
    channel: 'general',
    title: 'Hello',
    level: 'info',
);

$result = $trigv->sendEvent($request);
```

Event options
-------------

[](#event-options)

FieldRequiredDescription`channel`YesChannel slug (e.g. `general`)`title`YesNotification title`description`NoBody text`image_url`NoHTTPS image URL (not stored server-side)`url`NoDestination URL for the notification (max 2048 characters; not stored server-side)`level`No`info`, `success`, `warning`, `error` (default: `info`)`delivery_urgency`No`standard` or `time_sensitive` (default: `standard`)`event_type`NoFree-form label (e.g. `deploy.completed`)`idempotency_key`NoDedup key per workspaceLevels
------

[](#levels)

- `info` — general information (default)
- `success` — completed successfully
- `warning` — attention needed
- `error` — failure or alert

Delivery urgency
----------------

[](#delivery-urgency)

- `standard` — normal notifications (default)
- `time_sensitive` — iOS Time Sensitive delivery (requires user permission)

Idempotency
-----------

[](#idempotency)

When you set `idempotency_key`, retries with the same key return the existing event (`duplicate: true`, HTTP 200) without billing again.

```
$result = $trigv->sendEvent([
    'channel' => 'deploys',
    'title' => 'Production deploy complete',
    'idempotency_key' => 'deploy-prod-42',
]);

if ($result->duplicate) {
    // Already processed
}
```

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

[](#error-handling)

```
use Trigv\Exception\AuthenticationException;
use Trigv\Exception\NotFoundException;
use Trigv\Exception\RateLimitException;
use Trigv\Exception\ValidationException;

try {
    $trigv->sendEvent(['channel' => 'general', 'title' => 'Hello']);
} catch (ValidationException $e) {
    print_r($e->errors);
} catch (NotFoundException $e) {
    echo 'Channel not found';
} catch (RateLimitException $e) {
    echo $e->retryable ? 'Retry later' : 'Monthly limit reached';
} catch (AuthenticationException $e) {
    echo 'Invalid API key';
}
```

Configuration
-------------

[](#configuration)

OptionDefaultDescription`api_key``TRIGV_API_KEY` envWorkspace API key`base_url``https://api.trigv.com/api`API base URL`timeout``30`Request timeout (seconds)`max_retries``2`Retries for retryable errors`http_client`cURLCustom `HttpClientInterface` (for testing)### Verify connection

[](#verify-connection)

```
$connection = $trigv->verifyConnection();
echo $connection->workspace->name;
```

Laravel usage
-------------

[](#laravel-usage)

Add your API key to `.env`:

```
TRIGV_API_KEY=trgv_your_api_key
```

Register the client in a service provider or `AppServiceProvider`:

```
use Illuminate\Support\ServiceProvider;
use Trigv\Client;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(Client::class, function () {
            return new Client([
                'api_key' => config('services.trigv.api_key'),
                'base_url' => config('services.trigv.base_url'),
            ]);
        });
    }
}
```

Add to `config/services.php`:

```
'trigv' => [
    'api_key' => env('TRIGV_API_KEY'),
    'base_url' => env('TRIGV_BASE_URL', 'https://api.trigv.com/api'),
],
```

Send from a job or listener:

```
use Trigv\Client;

class NotifyDeployCompleted
{
    public function __construct(private Client $trigv) {}

    public function handle(): void
    {
        $this->trigv->sendEvent([
            'channel' => 'deploys',
            'title' => 'Production deploy complete',
            'description' => 'Build #42 succeeded in 38s (commit abc1234)',
            'level' => 'success',
            'event_type' => 'deploy.completed',
            'idempotency_key' => 'deploy-prod-42',
        ]);
    }
}
```

WordPress usage
---------------

[](#wordpress-usage)

Install via Composer in your plugin or theme (or bundle `vendor/` in your plugin):

```
composer require trigv/trigv
```

```
