PHP SDK
irisend/irisend-php requires PHP 8.1+ with ext-curl and ext-json, zero third-party dependencies. Not yet on Packagist — require it as a path repository for now.
composer.jsonJSON
// Not yet on Packagist — Packagist needs a dedicated Git repo per package, and this SDK lives
// inside the irisend monorepo (packages/sdk-php). Until a split-repo publish step exists,
// require it as a VCS/path repository pointing at the monorepo:
{
"repositories": [{ "type": "path", "url": "../irisend/packages/sdk-php" }],
"require": { "irisend/irisend-php": "*" }
}Quickstart
Every resource method returns a plain associative array (the wire's own snake_case field names, no translation layer) or throws Irisend\Exceptions\IrisendException.
send.phpphp
use Irisend\Client;
$irisend = new Client($_ENV['IRISEND_API_KEY']);
try {
$email = $irisend->emails->send([
'from' => 'Acme <[email protected]>',
'to' => '[email protected]',
'subject' => 'Welcome!',
'html' => '<p>Thanks for signing up.</p>',
]);
echo "sent {$email['id']}\n";
} catch (\Irisend\Exceptions\IrisendException $e) {
echo "{$e->getErrorName()} ({$e->getStatusCode()}): {$e->getMessage()}\n";
}Send with a template
send-with-template.phpphp
$template = $irisend->templates->create([
'name' => 'Welcome email',
'from' => '[email protected]',
'subject' => 'Welcome, {{{CUSTOMER_NAME}}}!',
'html' => '<p>Hi {{{CUSTOMER_NAME}}}, thanks for trying {{{PRODUCT}}}!</p>',
'variables' => [
['key' => 'CUSTOMER_NAME', 'type' => 'string', 'fallback_value' => 'there'],
['key' => 'PRODUCT', 'type' => 'string'],
],
]);
$irisend->templates->publish($template['id']); // required before the template can be used to send
$irisend->emails->send([
'to' => '[email protected]',
'template' => ['id' => $template['id'], 'variables' => ['CUSTOMER_NAME' => 'Jane', 'PRODUCT' => 'Irisend']],
]);Verifying webhooks
verify-webhook.phpphp
use Irisend\Webhooks;
$body = file_get_contents('php://input');
$headers = ['webhook-id' => $_SERVER['HTTP_WEBHOOK_ID'] ?? null, /* ...and timestamp/signature */];
if (!Webhooks::verify($webhookSigningSecret, $headers, $body)) {
http_response_code(401);
exit;
}