Skip to content

SDKs

PHP SDK

deveryidea/voaaro 0.4.0 for PHP 8.1 and later: curl or any PSR-18 client, the same calls as resend-php, retries and pagination iterators.

Installing

Shell
composer require deveryidea/voaaro

Version 0.4.0. PHP 8.1 or later with ext-json. No required dependency: ext-curl is used if present, otherwise pass a PSR-18 client (Guzzle, Symfony HttpClient…).

Configuring

PHP
use Voaaro\Voaaro;

$voaaro = Voaaro::client(getenv('VOAARO_API_KEY'), baseUrl: 'https://mail.example.com', maxRetries: 2);

Parameters: apiKey, baseUrl, transport (PSR-18 client), headers, timeout (30 seconds by default), maxRetries (2 by default), sleep (wait between two attempts, for fast tests). Without a key or address, VOAARO_API_KEY and VOAARO_BASE_URL are read.

Sending

PHP
use Voaaro\Attachment;

$email = $voaaro->emails->send(
    [
        'from' => 'Acme <notifications@example.com>',
        'to' => ['client@example.org'],
        'subject' => 'Welcome',
        'html' => '<p>Your account is ready.</p>',
        'attachments' => [Attachment::fromPath('/path/guide.pdf')],
    ],
    ['idempotencyKey' => 'welcome-42'],
);
echo $email->id;

Attachment::fromPath() reads a local file; content also accepts base64, bytes, a stream or an SplFileInfo (Attachment::fromContent() to force raw bytes).

Retries and idempotency

  • A transient error is retried up to maxRetries times (2 by default): network error (TransporterException), 429 rate_limit_exceeded, 500, 502, 503, 504. Never daily_quota_exceeded nor another 4xx error. Wait: Retry-After (60 seconds at most), otherwise 0.5 s, 1 s, 2 s… with jitter, 8 seconds at most.
  • Any creation accepts the option ['idempotencyKey' => …]. Without it, the SDK draws one (UUID v4) for each POST, the same from one attempt to the next.
  • maxRetries: 0: no retry and no key drawn.
PHP
$voaaro->contacts->create(['email' => 'ada@example.org'], ['idempotencyKey' => 'signup-42']);
$noRetry = Voaaro::client($key, baseUrl: $url, maxRetries: 0);

Pagination

Each cursor list has an iterator: a Generator of Resource that asks for pages of 100 (or limit) and follows after as long as has_more is true.

PHP
foreach ($voaaro->contacts->all(['segmentId' => $segmentId, 'unsubscribed' => false]) as $contact) {
    echo $contact->email, "\n";
}

$all = iterator_to_array($voaaro->suppressions->all(['reason' => 'bounce']), false);
ListIterator
X->list($options)X->all($options): emails, emails->receiving, apiKeys, domains, contacts, contacts->imports, segments, audiences, topics, contactProperties, broadcasts, forms, newsletterTemplates, automations, webhooks, suppressions
contacts->segments->list($contact), audiences->contacts->list($id), webhooks->deliveries->list($id)->all($contact or $id, $options)
segments->contacts($id), forms->signups($id), automations->runs($id), emails->events()allContacts($id), allSignups($id), allRuns($id), allEvents()
any route$voaaro->paginate('/path', $filters)

The list's filters apply; after sets the starting point; before is refused.

The rest

PHP
$voaaro->batch->send([...], ['batchValidation' => 'permissive']);
$voaaro->emails->get($id);
$voaaro->emails->list(['limit' => 20]);
$voaaro->emails->update($id, ['scheduledAt' => 'in 2 hours']);
$voaaro->emails->cancel($id);
$voaaro->emails->events(['type' => 'bounced', 'createdAfter' => '2026-11-01T00:00:00Z']);
$voaaro->emails->receiving->list(['limit' => 10]); // personal key with receiving
$voaaro->domains->create(['name' => 'notify.example.com']);
$voaaro->suppressions->add(['email' => 'former.customer@example.org', 'domain' => 'example.com']);
$voaaro->apiKeys->create(['name' => 'CI', 'permission' => 'sending_access']);
$voaaro->contacts->create(['email' => 'ada@example.org', 'firstName' => 'Ada']);
$voaaro->broadcasts->create(['segmentId' => $segmentId, 'from' => $from, 'subject' => $subject, 'html' => $html, 'send' => true]);

Resources: emails (with attachments and receiving), batch, apiKeys, domains, suppressions, contacts, segments, audiences, topics, contactProperties, broadcasts, newsletter, forms, newsletterTemplates, automations, events, webhooks (with deliveries), organizations (operator key mko_…).

Newsletters

PHP
$voaaro->newsletter->updateSettings(['from' => 'Acme <news@example.com>', 'postalAddress' => "Acme\n12 Lilac Street\nSpringfield"]);
$overview = $voaaro->newsletter->overview(['days' => 30]);

$form = $voaaro->forms->create(['name' => 'Website newsletter', 'doubleOptIn' => true, 'segmentIds' => [$segmentId]]);
$voaaro->segments->preview(['match' => 'all', 'conditions' => [['field' => 'opened', 'op' => 'none', 'days' => 90]]]);

$voaaro->broadcasts->links($broadcastId);
$voaaro->broadcasts->chooseWinner($broadcastId, 'b');
file_put_contents('broadcast.csv', $voaaro->broadcasts->export($broadcastId));

$template = $voaaro->newsletterTemplates->create(['name' => 'Monthly letter', 'subject' => "What's new", 'html' => $html]);
$voaaro->automations->create(['name' => 'After purchase', 'trigger' => ['type' => 'event', 'event' => 'purchase'], 'steps' => $steps, 'status' => 'active']);
$voaaro->events->send(['email' => 'ada@example.org', 'name' => 'purchase', 'data' => ['total' => 42]]);
$voaaro->contacts->cleanup(['days' => 180]); // simulation; 'dryRun' => false to act

Nested keys (trigger, steps, fields, ab) are written in snake_case, like the API; top-level ones in camelCase or snake_case. The domain option names the domain when the key covers several. Route details: Newsletters.

Subscribing and unsubscribing from your application (server: newsletter->subscribe(), unsubscribe(), getSubscription(); browser: PublicForm, PublicForm::solveChallenge), campaign scheduling (schedule, unschedule, sendNow, listScheduled, check): see the guides Your own signup form, Unsubscribing from your application and Scheduling a campaign, with examples for each SDK.

Contact quality and deliverability: verifying an address without storing it (contacts->verifyEmail()) or a contact's address (contacts->reverify()), engagement and address status filters (engagement, emailStatus), CSV export (contacts->export()), importing without invalid addresses (skipInvalid) and a broadcast's deliverability score (broadcasts->deliverability()): see Contacts, segments and topics and Broadcasts, with examples for each SDK.

Errors

PHP
use Voaaro\Exceptions\ErrorException;

try {
    $voaaro->emails->send($params);
} catch (ErrorException $e) {
    echo $e->getStatusCode(), ' ', $e->getErrorName(), ': ', $e->getMessage();
    $e->getRetryAfter(); // seconds from Retry-After, or null
}

Webhooks

PHP
use Voaaro\Webhook;

$event = Webhook::verify(file_get_contents('php://input'), getallheaders(), getenv('VOAARO_WEBHOOK_SECRET'));

Throws WebhookVerificationException if the signature is wrong or too old (5 minutes). Several secrets: pass an array [new, old] instead of one secret (empty values ignored); the notification is accepted if one of them matches one of the header's v1. Full example and rotation: Signature.

Managing endpoints (details):

PHP
$hook = $voaaro->webhooks->create(['endpoint' => 'https://app.example.com/webhooks/voaaro', 'events' => ['email.bounced']]);
$secret = $hook->signing_secret; // shown only once
$voaaro->webhooks->rotateSecret($hook->id, ['graceHours' => 24]);
foreach ($voaaro->webhooks->deliveries->all($hook->id, ['status' => 'failed']) as $d) {
    $voaaro->webhooks->deliveries->replay($hook->id, $d->id);
}
Esc