PHP SDK
Composer package generated from the public OpenAPI spec.
The PHP SDK (emailguard/emailguard-sdk) wraps /api/v1 with Guzzle-backed API classes generated from OpenAPI (version 1.2.0). Use it in Laravel, Symfony, or plain PHP apps.
composer require emailguard/emailguard-sdk:1.2.0Require the package in composer.json and run composer update in CI for locked builds.
| Variable | Required | Description |
|---|---|---|
EMAILGUARD_API_KEY | Yes | Team-scoped live key (egsk_live_...) |
API_KEY is accepted as an alias in most clients.
Point the client at your API origin when it differs from the default (https://api.emailguard.co):
Configuration::getDefaultConfiguration()->setHost('https://api.emailguard.co');<?php
use emailguardSdk\Api\TeamsApi;
use emailguardSdk\ApiException;
use emailguardSdk\Configuration;
require __DIR__ . '/vendor/autoload.php';
Configuration::getDefaultConfiguration()
->setHost('https://api.emailguard.co')
->setApiKey('Authorization', getenv('EMAILGUARD_API_KEY'))
->setApiKeyPrefix('Authorization', 'Bearer');
$api = new TeamsApi();
try {
$result = $api->getTeam();
} catch (ApiException $e) {
throw new RuntimeException($e->getResponseBody() ?: $e->getMessage(), $e->getCode(), $e);
}Generated methods return model objects from the HTTP response. Unwrap data from the envelope when code is SUCCESS.
{
"code": "SUCCESS",
"data": { "..." : "..." },
"message": "OK"
}Decode the response array or model and read data when code === 'SUCCESS'.
20 operations are grouped into \emailguardSdk\Api\* classes:
Use the PHP SDK tab on any endpoint page for a complete snippet including namespaces and method names.
use emailguardSdk\Api\TeamsApi;
use emailguardSdk\Configuration;
Configuration::getDefaultConfiguration()
->setApiKey('Authorization', getenv('EMAILGUARD_API_KEY'))
->setApiKeyPrefix('Authorization', 'Bearer');
$api = new TeamsApi();
$team = $api->apiV1TeamGet();The SDK throws ApiException on HTTP errors. Connection failures surface as Guzzle exceptions. Handle HTTP 401, 403, and 429 explicitly. See API rate limiting.
On timeout, connection errors, 429, or 5xx, fail open for ordinary signup. A 2xx body with disposable true is a verdict. Give Guzzle at least a 2 second timeout on detect.
Signup policy: Confidence, evidence, and fail-open.