PHPackages                             wasenderapi/wasenderapi-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wasenderapi/wasenderapi-laravel

ActiveLibrary[API Development](/categories/api)

wasenderapi/wasenderapi-laravel
===============================

Laravel SDK for WasenderAPI with event dispatching and webhook route

v1.0.3(7mo ago)37.4k↓19.4%31MITPHPPHP &gt;=8.0

Since May 27Pushed 5mo agoCompare

[ Source](https://github.com/wasenderapi/wasenderapi-laravel)[ Packagist](https://packagist.org/packages/wasenderapi/wasenderapi-laravel)[ RSS](/packages/wasenderapi-wasenderapi-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (1)

WasenderAPI Laravel SDK
=======================

[](#wasenderapi-laravel-sdk)

**Laravel SDK Author:** YonkoSam

A robust Laravel SDK for interacting with the WasenderAPI (). This SDK simplifies sending WhatsApp messages, managing contacts and groups, handling session statuses, and processing incoming webhooks with Laravel-native events and best practices.

---

Features
--------

[](#features)

- **Modern Laravel Service:** Injectable, testable, and supports Facade usage.
- **Message Sending:**
    - Helper methods for text, image, video, document, audio, sticker, contact, and location messages.
    - DTOs for type-safe payloads.
    - RetryConfig for automatic rate-limit retries on send-message endpoints.
- **Contact Management:** List, get info, get profile picture, block, and unblock contacts.
- **Group Management:** List groups, get metadata, manage participants, update settings.
- **Session Management:** Create, list, update, delete, connect/disconnect sessions, get QR codes, check status.
- **Webhook Handling:** Securely verifies and parses incoming webhooks, dispatches Laravel events for each event type.
- **Error Handling:** Custom `WasenderApiException` with detailed error/response info.
- **Testing:** Pest and Testbench support out of the box.

---

Installation
------------

[](#installation)

```
composer require wasenderapi/wasenderapi-laravel
```

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=wasenderapi-config
```

Set your credentials in `.env`:

```
WASENDERAPI_API_KEY=your_api_key_here
WASENDERAPI_PERSONAL_ACCESS_TOKEN=your_personal_token_here # (optional, for session management)
WASENDERAPI_WEBHOOK_SECRET=your_webhook_secret_here # (for webhook verification)

```

---

Usage
-----

[](#usage)

#### Direct Instantiation

[](#direct-instantiation)

Another way to use the client is by creating a new instance of the `WasenderClient` class directly and providing your API key as an argument:

```
$client = new WasenderClient('your_api_key_here');
```

This method is particularly powerful and becomes the recommended approach when your application needs to manage multiple sessions. Each session you create in your Wasender dashboard has a unique API key. Direct instantiation allows you to dynamically select and use the specific API key for the session you want to communicate with at runtime. This is essential for applications that send messages from different WhatsApp numbers. This approach is also the standard method for using the library in contexts outside of the Laravel framework or in situations where Laravel's service container is not readily available. To get started, you'll need a WasenderAPI account to obtain the unique API key for each of your sessions.

### Dependency Injection (Recommended)

[](#dependency-injection-recommended)

```
use WasenderApi\WasenderClient;

public function send(WasenderClient $client) {
    $client->sendText('1234567890', 'Hello from Laravel!');
}
```

### Facade Usage

[](#facade-usage)

```
use WasenderApi\Facades\WasenderApi;

WasenderApi::sendText('1234567890', 'Hello via Facade!');
```

### DTO Usage

[](#dto-usage)

```
use WasenderApi\Data\SendTextMessageData;
use WasenderApi\Data\RetryConfig;
use WasenderApi\Facades\WasenderApi;

$dto = new SendTextMessageData('1234567890', 'Hello DTO!');
$retry = new RetryConfig(true, 3); // Enable retry, max 3 times
WasenderApi::sendText($dto, null, [], $retry);
```

---

Message Sending
---------------

[](#message-sending)

All message types support both direct parameters and DTOs. All return an array response.

- `sendText($to, $text, $options = [], ?RetryConfig $retry = null)`
- `sendImage($to, $url, $caption = null, $options = [], ?RetryConfig $retry = null)`
- `sendVideo($to, $url, $caption = null, $options = [], ?RetryConfig $retry = null)`
- `sendDocument($to, $url, $fileName, $caption = null, $options = [], ?RetryConfig $retry = null)`
- `sendAudio($to, $url, $options = [], ?RetryConfig $retry = null)`
- `sendSticker($to, $url, $options = [], ?RetryConfig $retry = null)`
- `sendContact($to, $contactName, $contactPhone, $options = [], ?RetryConfig $retry = null)`
- `sendLocation($to, $latitude, $longitude, $name = null, $address = null, $options = [], ?RetryConfig $retry = null)`

**RetryConfig:** Only applies to send-message endpoints. Retries on HTTP 429 (rate limit) up to `maxRetries` times, waiting for `retry_after` seconds if provided.

---

Contact Management
------------------

[](#contact-management)

- `getContacts()`
- `getContactInfo($phone)`
- `getContactProfilePicture($phone)`
- `blockContact($phone)`
- `unblockContact($phone)`

---

Group Management
----------------

[](#group-management)

- `getGroups()`
- `getGroupMetadata($jid)`
- `getGroupParticipants($jid)`
- `addGroupParticipants($jid, $participants)`
- `removeGroupParticipants($jid, $participants)`
- `updateGroupSettings($jid, $settings)`

---

Session Management
------------------

[](#session-management)

- `getAllWhatsAppSessions()`
- `createWhatsAppSession($payload)`
- `getWhatsAppSessionDetails($sessionId)`
- `updateWhatsAppSession($sessionId, $payload)`
- `deleteWhatsAppSession($sessionId)`
- `connectWhatsAppSession($sessionId, $qrAsImage = false)`
- `getWhatsAppSessionQrCode($sessionId)`
- `disconnectWhatsAppSession($sessionId)`
- `regenerateApiKey($sessionId)`
- `getSessionStatus($sessionId)`

---

Webhook Handling &amp; Events
-----------------------------

[](#webhook-handling--events)

- The package auto-registers a POST route (default `/wasender/webhook`).
- Verifies the signature using the secret in config/env.
- Dispatches a dedicated Laravel event for each webhook event type (e.g., `MessagesUpserted`, `GroupsUpdated`, etc.).
- Listen for events in your app:

```
use WasenderApi\Events\MessagesUpserted;

Event::listen(MessagesUpserted::class, function ($event) {
    // $event->payload
});
```

---

Error Handling
--------------

[](#error-handling)

All API errors throw `WasenderApiException`.

```
use WasenderApi\Exceptions\WasenderApiException;

try {
    WasenderApi::sendText('123', 'fail');
} catch (WasenderApiException $e) {
    // $e->getMessage(), $e->getCode(), $e->getResponse()
}
```

---

DTO Reference
-------------

[](#dto-reference)

- `SendTextMessageData($to, $text)`
- `SendImageMessageData($to, $imageUrl, $text = null)`
- `SendVideoMessageData($to, $videoUrl, $text = null)`
- `SendDocumentMessageData($to, $documentUrl, $fileName, $text = null)`
- `SendAudioMessageData($to, $audioUrl)`
- `SendStickerMessageData($to, $stickerUrl)`
- `SendContactMessageData($to, $contactName, $contactPhone)`
- `SendLocationMessageData($to, $latitude, $longitude, $name = null, $address = null)`
- `RetryConfig($enabled = false, $maxRetries = 0)`

---

Testing
-------

[](#testing)

- Pest is included for expressive, modern tests.
- Example:

```
test('sendText via Facade returns success and message', function () {
    Http::fake([
        'https://www.wasenderapi.com/api/send-message' => Http::response(['success' => true, 'message' => 'Message sent'], 200),
    ]);
    $result = WasenderApi::sendText('123', 'hello');
    expect($result['success'])->toBeTrue();
    expect($result['message'])->toBe('Message sent');
});
```

---

Advanced
--------

[](#advanced)

- **Customizing HTTP:** Uses Laravel's HTTP client. You can mock or extend as needed.
- **Extending Events:** You can add listeners for any event type or extend event classes for custom logic.
- **RetryConfig:** Only applies to send-message endpoints. Retries on HTTP 429 (rate limit) up to `maxRetries` times, waiting for `retry_after` seconds if provided.

---

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance68

Regular maintenance activity

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~47 days

Total

4

Last Release

213d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a807b4f899a0a0f7dba1ad42ab7670bbf31c334b670691ce6370d9220cfd0ee8?d=identicon)[YonkoSam](/maintainers/YonkoSam)

---

Top Contributors

[![YonkoSam](https://avatars.githubusercontent.com/u/161728760?v=4)](https://github.com/YonkoSam "YonkoSam (9 commits)")[![JemCdo](https://avatars.githubusercontent.com/u/40404495?v=4)](https://github.com/JemCdo "JemCdo (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/wasenderapi-wasenderapi-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/wasenderapi-wasenderapi-laravel/health.svg)](https://phpackages.com/packages/wasenderapi-wasenderapi-laravel)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
