PHPackages                             siren/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. [Payment Processing](/categories/payments)
4. /
5. siren/sdk

ActiveLibrary[Payment Processing](/categories/payments)

siren/sdk
=========

Official Siren SDK for PHP — affiliate and incentive tracking for any commerce stack.

0.1.0(1mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Jul 11Pushed 1mo agoCompare

[ Source](https://github.com/Novatorius/siren-php)[ Packagist](https://packagist.org/packages/siren/sdk)[ Docs](https://sirenaffiliates.com)[ RSS](/packages/siren-sdk/feed)WikiDiscussions main Synced 1w ago

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

Siren SDK for PHP
=================

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

Affiliate and incentive tracking for any commerce stack — record sales, verify signed webhooks, and reconcile your ledger in a few lines of PHP.

[![Packagist Version](https://camo.githubusercontent.com/755300488e835d21d62beef044a704d01a9a5b72f03d157661fa29b2e23827e1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736972656e2f73646b2e737667)](https://packagist.org/packages/siren/sdk)[![CI](https://github.com/Novatorius/siren-php/actions/workflows/ci.yml/badge.svg)](https://github.com/Novatorius/siren-php/actions/workflows/ci.yml)[![License: MIT](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](./LICENSE)[![PHP Version](https://camo.githubusercontent.com/bc9cdbcee819460a908e867d05802cb70ea4ae6f295a26e47b5d8cecd27e1638/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736972656e2f73646b2e737667)](https://packagist.org/packages/siren/sdk)

What is Siren?
--------------

[](#what-is-siren)

[Siren](https://sirenaffiliates.com) is an affiliate, referral, and incentive platform. You track the events that matter — sales, refunds, referred visits — and Siren attributes them to collaborators, calculates rewards, and manages payouts.

This SDK is the official PHP client for the Siren API. It lets you:

- Record commerce and tracking events (`sale`, `refund`, `siteVisited`, and custom event types)
- Verify signed webhooks in a single, constant-time call
- Manage API keys and webhook subscriptions
- Reconcile Siren's ledger (conversions, transactions, obligations, payouts) against your own

The full API surface is described in the [OpenAPI spec](./openapi.yaml).

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

[](#requirements)

- PHP 8.1+
- `ext-json`

Install
-------

[](#install)

```
composer require siren/sdk
```

Quickstart
----------

[](#quickstart)

### Record a sale

[](#record-a-sale)

Mint an API key in the Siren dashboard (Settings → API Keys), then:

```
use Siren\Sdk\Siren;

$siren = new Siren(['apiKey' => 'sk_live_...']);

$result = $siren->events->sale([
    'source'     => 'stripe',            // your commerce source
    'externalId' => 'cs_test_a1b2c3',    // your order id — used to match refunds later
    'total'      => 49.99,               // major units: 49.99 = $49.99
    'trackingId' => 4021,                // opportunity id from the Siren tracking cookie
    'currency'   => 'USD',               // optional, defaults to USD
    'items'      => [                    // optional; omit to treat total as one line
        ['name' => 'Pro Plan (annual)', 'amount' => 49.99, 'quantity' => 1],
    ],
]);

echo $result->getOpportunityId(); // read from the X-Siren-OID response header
```

Refunds reverse a sale by `(externalId, source)`:

```
$siren->events->refund([
    'source'     => 'stripe',
    'externalId' => 'cs_test_a1b2c3',
]);
```

### Verify a webhook

[](#verify-a-webhook)

Siren signs every delivery with `X-Siren-Signature: sha256=` — an HMAC-SHA256 of the **raw request body** keyed by your subscription's signing secret.

> ⚠️ **Pass the raw body bytes.** The HMAC is computed over the exact bytes Siren sent. Read `php://input` directly — if you `json_decode` and re-encode the payload, verification **will fail**.

```
use Siren\Sdk\Siren;
use Siren\Sdk\WebhookEventType;
use Siren\Sdk\Exception\SignatureVerificationException;

$siren = new Siren(['apiKey' => 'sk_live_...']);

$rawBody   = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_SIREN_SIGNATURE'] ?? null;

try {
    $event = $siren->webhooks->constructEvent($rawBody, $signature, $signingSecret);
} catch (SignatureVerificationException $e) {
    http_response_code(400);
    exit;
}

match ($event->getType()) {
    WebhookEventType::CONVERSION_APPROVED => handleConversion($event->getData()),
    WebhookEventType::PAYOUT_PAID         => handlePayout($event->getData()),
    default                               => null,
};
```

Create a subscription (the `signingSecret` is returned **once** — store it):

```
$subscription = $siren->webhooks->subscriptions->create([
    'targetUrl' => 'https://example.com/webhooks/siren',
    'events'    => [WebhookEventType::CONVERSION_APPROVED, WebhookEventType::PAYOUT_PAID],
    // or [WebhookEventType::ALL] to subscribe to everything
]);

$secret = $subscription['signingSecret'];
```

Features
--------

[](#features)

- **Event ingestion** — `sale`, `refund`, `siteVisited`, and custom event types via `ingest`.
- **Webhook verification** — one-call `constructEvent`, plus a lower-level constant-time `verifySignature` boolean check.
- **Subscription management** — create, list, and delete webhook subscriptions.
- **API key management** — create, list, and revoke keys.
- **Reconciliation readers** — paginated iterators over conversions, transactions, obligations, and payouts.
- **Automatic retries** — network errors, 429s, and 5xx are retried with exponential backoff on idempotent operations; management writes are never auto-retried.
- **Typed exceptions** — every error extends `Siren\Sdk\Exception\SirenException` and carries the status code, error code, and error data.
- **Typed taxonomy** — Siren's domain vocabulary as constants, so no magic strings cross the boundary: `WebhookEventType`, `EventSlug`, and the status vocabularies (`ConversionStatus`, `TransactionStatus`, `ObligationStatus`, `PayoutStatus`, `FulfillmentStatus`, `OpportunityStatus`, `ApiKeyStatus`, `WebhookSubscriptionStatus`).

```
use Siren\Sdk\ConversionStatus;

$approved = $siren->conversions->list(['status' => ConversionStatus::APPROVED]);
```

### Configuration

[](#configuration)

```
$siren = new Siren([
    'apiKey'     => 'sk_live_...',                              // required
    'baseUrl'    => 'https://api.sirenaffiliates.com/siren/v1', // default
    'timeout'    => 30,                                         // seconds, default 30
    'maxRetries' => 2,                                          // default 2
]);
```

### Errors

[](#errors)

Every exception extends `Siren\Sdk\Exception\SirenException` and carries `getStatusCode()`, `getErrorCode()`, and `getErrorData()`.

StatusException400`BadRequestException`401`AuthenticationException`403`PermissionException`404`NotFoundException`409`ConflictException`422`ValidationException` — `getFieldErrors()`429`RateLimitException` — `getRetryAfter()`5xx / other`ApiException`network/timeout`ConnectionException`Webhook verification failures throw `SignatureVerificationException`.

Other SDKs
----------

[](#other-sdks)

Siren also ships official clients for other stacks:

- **Node.js** — [Novatorius/siren-node](https://github.com/Novatorius/siren-node)
- **Python** — [Novatorius/siren-python](https://github.com/Novatorius/siren-python)

Links
-----

[](#links)

- Website: [sirenaffiliates.com](https://sirenaffiliates.com)
- API reference: [openapi.yaml](./openapi.yaml)

Contributing
------------

[](#contributing)

Contributions are welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for how to set up the project, run the tests, and open a pull request. By participating you agree to the [Code of Conduct](./CODE_OF_CONDUCT.md).

```
composer install
composer test
```

Tests mock the HTTP layer — no live network calls.

License
-------

[](#license)

Released under the [MIT License](./LICENSE). Copyright © 2026 Novatorius LLC.

###  Health Score

34

—

LowBetter than 74% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

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

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e6206223bd6f2a57b8ac80605b1b5c3521faaec18ad3f20f25fb728a9a13784?d=identicon)[tstandiford](/maintainers/tstandiford)

---

Top Contributors

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

---

Tags

affiliateaffiliate-marketingecommerceincentivesphpreferralreferral-programrewardssdksirenwebhookssdkstripewebhooksecommercerewardsSirenreferralaffiliateAffiliate Marketingincentives

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.4k567.5M2.9k](/packages/aws-aws-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.1k1.0M59](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3751.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.9M10](/packages/chargebee-chargebee-php)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

529.0M7](/packages/avalara-avataxclient)

PHPackages © 2026

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