📦 Brevo PHP SDK v4.0.3
Modernized, type-safe rewrite of the Brevo PHP client with a unified client architecture, PSR-18 compatibility, and built-in reliability features.
🚀 Highlights
- Type-safe SDK with strongly typed request/response objects and PHPDoc annotations
- Single unified client (
Brevo) replaces multiple API classes and manual configuration - Built-in retries + timeouts
- Structured error handling
- PSR-18 compatible — works with Guzzle, Symfony HttpClient, or any PSR-18 implementation
- PHP 8.1+ with support for Laravel, Symfony, and plain PHP
- Legacy v2.x now maintenance-only
⚠️ Breaking Changes
This is a full rewrite of the SDK. v4.0.3 is not backwards compatible with v2.x.
Key breaking changes:
- The multi-class initialization pattern (
Configuration::getDefaultConfiguration()+ per-API class instantiation) is replaced by a singleBrevoclient - Setter-based request building (e.g.,
$message->setSubject(...)) is replaced by typed request objects with named constructors - Error handling now uses
BrevoApiException/BrevoExceptioninstead of Guzzle-specific exceptions - The SDK now requires PHP 8.1+ (previously PHP 7.x)
- PSR-18 HTTP client replaces the hard Guzzle dependency
The legacy v2.x SDK will continue to receive critical security updates but no new features. We strongly recommend migrating to v4.x.
Added
New Client Architecture
- Introduced
Brevoas the single entry point - Namespaced API clients (e.g.,
$brevo->transactionalEmails->*,$brevo->contacts->*) - 30+ resource clients accessible from one instance: contacts, deals, campaigns, ecommerce, webhooks, and more
Type Safety
- Strongly typed request and response classes for every endpoint
- Full PHPDoc annotations for IDE autocomplete
- Named constructors with typed arrays replace untyped setters
Reliability Features
- Automatic retries with exponential backoff and jitter (~1s, ~2s, ~4s)
- Honors
Retry-Afterheaders on rate-limited responses - Configurable global and per-request timeouts (default: 60s)
- Retryable status codes:
408,429,500,502,503,504
Error Handling
BrevoApiExceptionfor all non-2xx API responses with:getCode()— HTTP status codegetMessage()— error messagegetBody()— parsed error response body
BrevoExceptionas a base for all SDK-level errors- Clean
try/catchbranching by status code
Advanced Configuration
- Custom PSR-18 HTTP client support (Guzzle, Symfony HttpClient, etc.)
- Custom headers at client and per-request level
- Configurable base URL
- Binary response support for file downloads
Runtime Compatibility
- PHP 8.1+
- Laravel
- Symfony
- Any framework or plain PHP project with Composer
Read more at https://developers.brevo.com/docs/api-clients/php