PHPackages                             pyrx/synapse - 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. pyrx/synapse

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

pyrx/synapse
============

Official PHP SDK for PYRX Synapse - CRM, email, and event tracking API

v0.1.0(1mo ago)016MITPHPPHP &gt;=8.1CI passing

Since May 1Pushed 1mo agoCompare

[ Source](https://github.com/PYRX-Tech/pyrx-synapse-php)[ Packagist](https://packagist.org/packages/pyrx/synapse)[ Docs](https://github.com/pyrx-labs/pyrx-synapse-php)[ RSS](/packages/pyrx-synapse/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PYRX Synapse PHP SDK
====================

[](#pyrx-synapse-php-sdk)

[![CI](https://github.com/pyrx-labs/pyrx-synapse-php/actions/workflows/ci.yml/badge.svg)](https://github.com/pyrx-labs/pyrx-synapse-php/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/2b588eb395b7af4e4f5c242a0a335478ed740171affbdc0b1ffefefd17717b41/68747470733a2f2f706f7365722e707567782e6f72672f707972782f73796e617073652f76)](https://packagist.org/packages/pyrx/synapse)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/20624777ec152aa857bfbf05cc497e6c1a166d2680d4b58ae77b23e494c3f72d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f707972782f73796e61707365)](https://packagist.org/packages/pyrx/synapse)

Official PHP SDK for [PYRX Synapse](https://synapse.pyrx.tech) -- CRM, email, and event tracking API.

**Zero runtime dependencies.** Uses PHP's built-in `curl`, `json`, and `hash` extensions.

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

[](#requirements)

- PHP &gt;= 8.1
- ext-curl
- ext-json

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

[](#installation)

```
composer require pyrx/synapse
```

Quick Start
-----------

[](#quick-start)

```
use PyrxSynapse\Client;

$client = new Client(
    apiKey: 'psk_live_your_api_key',
    workspaceId: 'ws_your_workspace_id',
);

// Track an event
$result = $client->track(
    externalId: 'user_123',
    eventName: 'purchase',
    attributes: ['amount' => 99.99, 'currency' => 'USD'],
);
echo $result['event_id']; // "evt_..."

// Identify a contact
$contact = $client->identify(
    externalId: 'user_123',
    email: 'jane@example.com',
    firstName: 'Jane',
    lastName: 'Doe',
    properties: ['plan' => 'pro'],
    tags: ['paying', 'onboarded'],
);

// Send a transactional email
$email = $client->sendEmail(
    templateSlug: 'welcome',
    to: ['email' => 'jane@example.com'],
    attributes: ['name' => 'Jane'],
);
```

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

[](#configuration)

```
$client = new Client(
    apiKey: 'psk_live_...',          // Required
    workspaceId: 'ws_...',           // Required
    baseUrl: 'https://synapse-api.pyrx.tech', // Optional (default)
    timeout: 30,                     // Optional, seconds (default: 30)
    maxRetries: 3,                   // Optional (default: 3)
);

// Environment is auto-detected from the API key prefix
echo $client->environment; // "live", "test", or "unknown"
```

Tracking Events
---------------

[](#tracking-events)

```
// Single event
$result = $client->track(
    externalId: 'user_123',
    eventName: 'page_view',
    attributes: ['page' => '/pricing'],
    idempotencyKey: 'idk_unique_123',
    occurredAt: '2026-01-15T10:30:00Z',
);

// Batch events
$result = $client->trackBatch([
    ['external_id' => 'user_1', 'event_name' => 'login'],
    ['external_id' => 'user_2', 'event_name' => 'signup'],
]);
echo $result['accepted']; // 2
```

Managing Contacts
-----------------

[](#managing-contacts)

```
// Identify (create or update)
$contact = $client->identify(
    externalId: 'user_123',
    email: 'jane@example.com',
    firstName: 'Jane',
);

// Batch identify
$result = $client->identifyBatch(
    contacts: [
        ['external_id' => 'u1', 'email' => 'a@example.com'],
        ['external_id' => 'u2', 'email' => 'b@example.com'],
    ],
    onConflict: 'update',
);

// List contacts
$list = $client->contacts->list(page: 1, perPage: 20, search: 'jane');

// Get a contact
$contact = $client->contacts->get('contact_id');

// Update a contact
$updated = $client->contacts->update('user_123', ['email' => 'new@example.com']);

// Delete a contact
$client->contacts->delete('user_123');
```

Email Templates
---------------

[](#email-templates)

```
// List templates
$templates = $client->templates->list();

// Get a template
$template = $client->templates->get('welcome');

// Create a template
$template = $client->templates->create([
    'name' => 'Welcome Email',
    'slug' => 'welcome',
    'subject' => 'Welcome, {{name}}!',
    'body_html' => 'Hello {{name}}',
]);

// Update a template
$updated = $client->templates->update('welcome', ['subject' => 'Hey {{name}}!']);

// Preview a template
$preview = $client->templates->preview('welcome', [
    'attributes' => ['name' => 'Jane'],
]);
echo $preview['html'];

// Delete a template
$client->templates->delete('old-template');
```

Webhook Verification
--------------------

[](#webhook-verification)

Verify incoming webhooks from Synapse using HMAC-SHA256 (Svix format):

```
use PyrxSynapse\Webhooks;

$payload = file_get_contents('php://input');
$headers = [
    'svix-id' => $_SERVER['HTTP_SVIX_ID'] ?? '',
    'svix-timestamp' => $_SERVER['HTTP_SVIX_TIMESTAMP'] ?? '',
    'svix-signature' => $_SERVER['HTTP_SVIX_SIGNATURE'] ?? '',
];

try {
    $event = Webhooks::verify($payload, $headers, 'whsec_your_webhook_secret');
    // $event is the parsed JSON payload
    echo $event['type']; // e.g., "contact.created"
} catch (\InvalidArgumentException $e) {
    http_response_code(400);
    echo $e->getMessage();
}
```

Error Handling
--------------

[](#error-handling)

```
use PyrxSynapse\Errors\SynapseError;
use PyrxSynapse\Errors\SynapseAuthError;
use PyrxSynapse\Errors\SynapseRateLimitError;
use PyrxSynapse\Errors\SynapsePlanLimitError;
use PyrxSynapse\Errors\SynapseValidationError;

try {
    $client->track('user_1', 'event');
} catch (SynapseAuthError $e) {
    // 401 or 403 (not plan limit)
    echo "Auth error: {$e->getMessage()} (status: {$e->status})";
} catch (SynapseRateLimitError $e) {
    // 429
    echo "Rate limited. Retry after {$e->retryAfter} seconds.";
} catch (SynapsePlanLimitError $e) {
    // 403 with code "plan_limit_reached"
    echo "Plan limit: {$e->current}/{$e->maximum} {$e->limitType} on {$e->plan} plan";
} catch (SynapseValidationError $e) {
    // 422
    foreach ($e->errors as $error) {
        echo "{$error['field']}: {$error['message']}\n";
    }
} catch (SynapseError $e) {
    // Any other API error
    echo "Error: {$e->getMessage()} (status: {$e->status}, code: {$e->errorCode})";
}
```

Retry Behavior
--------------

[](#retry-behavior)

The client automatically retries on:

- HTTP 429, 500, 502, 503, 504
- curl connection errors (timeout, connection refused)

Backoff: `min(1.0 * 2^attempt, 30s) + random jitter (0-0.5s)`. For 429 responses, the `Retry-After` header value is used instead.

Non-retryable errors (401, 403, 422, etc.) are raised immediately.

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance92

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

39d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/54efc028185203ce10f7971e4fa0343bdb7f7f024dba34637e502c469d193703?d=identicon)[pyrx-tech](/maintainers/pyrx-tech)

---

Top Contributors

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

---

Tags

sdkemailcrmSynapsepyrx

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mailerlite/mailerlite-api-v2-php-sdk

MailerLite API v2 PHP SDK

781.8M16](/packages/mailerlite-mailerlite-api-v2-php-sdk)[mailerlite/mailerlite-php

MailerLite PHP SDK

32501.3k5](/packages/mailerlite-mailerlite-php)[hafael/azure-mailer-driver

Supercharge your Laravel or Symfony app with Microsoft Azure Communication Services (ACS)! Effortlessly add email, chat, voice, video, and telephony-over-IP for next-level communication. 🚀

15122.2k](/packages/hafael-azure-mailer-driver)

PHPackages © 2026

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