Laravel Resend
#Laravel Resend
A Laravel wrapper for the Resend API. Covers emails, domains, API keys, audiences, contacts, webhooks, templates, broadcasts and segments through a simple, typed API built on Laravel's Http client.
#Features
- Emails:
send,batch,list,get,cancel - Domains:
list,get,create,verify,delete - API keys:
list,create,delete - Audiences:
list,get,create,delete - Contacts:
list,get,create,update,delete - Webhooks:
list,get,create,delete - Templates:
list,get,create,update,delete,publish,duplicate - Broadcasts:
list,get,create,send,delete - Segments:
list,get,create,delete - Throws
ResendException(with the original API error body) on any non-2xx response
#Installation
You can install the package via composer:
composer require jeffersongoncalves/laravel-resend
Publish the config file:
php artisan vendor:publish --tag=resend-config
Set your Resend API key in .env:
RESEND_API_KEY=re_your_api_key
Create (or find) your API key at resend.com/api-keys.
#Configuration
// config/resend.php return [ 'api_key' => env('RESEND_API_KEY', ''), 'base_url' => env('RESEND_BASE_URL', 'https://api.resend.com'), ];
#Usage
The package is resolved via the Resend facade or by injecting JeffersonGoncalves\Resend\Resend. Each resource is exposed as a method returning a dedicated resource class.
#Emails
use JeffersonGoncalves\Resend\Facades\Resend; Resend::emails()->send([ 'from' => 'Acme <hello@example.com>', 'to' => ['jane@example.com'], 'subject' => 'Hello!', 'html' => '<p>Welcome aboard.</p>', ]); Resend::emails()->batch([ ['from' => 'hello@example.com', 'to' => ['a@example.com'], 'subject' => 'A', 'html' => '<p>A</p>'], ['from' => 'hello@example.com', 'to' => ['b@example.com'], 'subject' => 'B', 'html' => '<p>B</p>'], ]); $emails = Resend::emails()->list(limit: 10); $email = Resend::emails()->get('email_id'); Resend::emails()->cancel('email_id');
#Domains
$domains = Resend::domains()->list(limit: 10); $domain = Resend::domains()->get('domain_id'); Resend::domains()->create('example.com', region: 'us-east-1'); Resend::domains()->verify('domain_id'); Resend::domains()->delete('domain_id');
#API keys
$keys = Resend::apiKeys()->list(); Resend::apiKeys()->create('production', permission: 'sending_access', domainId: 'domain_id'); Resend::apiKeys()->delete('api_key_id');
#Audiences and contacts
$audiences = Resend::audiences()->list(); Resend::audiences()->create('Newsletter'); Resend::contacts()->create( audienceId: 'audience_id', email: 'jane@example.com', firstName: 'Jane', lastName: 'Doe', ); Resend::contacts()->update( audienceId: 'audience_id', contactId: 'contact_id', unsubscribed: true, ); Resend::contacts()->delete('audience_id', 'contact_id');
#Webhooks
Resend::webhooks()->create('https://example.com/webhooks/resend', [ 'email.sent', 'email.delivered', 'email.bounced', ]); $webhooks = Resend::webhooks()->list(); Resend::webhooks()->delete('webhook_id');
#Templates
Resend::templates()->create('Welcome', '<p>Hi {{name}}</p>', [ 'subject' => 'Welcome aboard', 'from' => 'hello@example.com', ]); Resend::templates()->update('template_id', ['subject' => 'New subject']); Resend::templates()->publish('template_id'); Resend::templates()->duplicate('template_id');
#Broadcasts and segments
Resend::segments()->create('Active subscribers'); $broadcast = Resend::broadcasts()->create( segmentId: 'segment_id', from: 'hello@example.com', subject: 'Release notes', attributes: ['html' => '<p>What is new.</p>'], ); Resend::broadcasts()->send($broadcast['id'], scheduledAt: '2026-01-01T10:00:00Z');
#Error handling
Any non-2xx API response throws JeffersonGoncalves\Resend\Exceptions\ResendException, which exposes the decoded error body:
use JeffersonGoncalves\Resend\Exceptions\ResendException; try { Resend::emails()->send($payload); } catch (ResendException $e) { logger()->error($e->getMessage(), $e->errorBody()); }
#Testing
composer test
#Changelog
Please see CHANGELOG for more information on what has changed recently.
#Contributing
Please see CONTRIBUTING for details.
#Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
#Credits
#License
The MIT License (MIT). Please see License File for more information.