PHPackages                             chengkangzai/laravel-waha-saloon-sdk - 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. chengkangzai/laravel-waha-saloon-sdk

ActiveLibrary[API Development](/categories/api)

chengkangzai/laravel-waha-saloon-sdk
====================================

WAHA SDK that is generated from WAHA postman collection that is wrapped in SaloonPHP

v0.4.1(1mo ago)04.6k↓43.4%MITPHPPHP ^8.3CI passing

Since Jul 2Pushed 1mo agoCompare

[ Source](https://github.com/chengkangzai/laravel-waha-saloon-sdk)[ Packagist](https://packagist.org/packages/chengkangzai/laravel-waha-saloon-sdk)[ Docs](https://github.com/chengkangzai/laravel-waha-saloon-sdk)[ GitHub Sponsors](https://github.com/CCK)[ RSS](/packages/chengkangzai-laravel-waha-saloon-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (26)Versions (21)Used By (0)

Laravel WAHA Saloon SDK
=======================

[](#laravel-waha-saloon-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/1856414f0716a6e088337fc96f13d15a2efbdbdc0c8116eab06ab36b79db483d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368656e676b616e677a61692f6c61726176656c2d776168612d73616c6f6f6e2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chengkangzai/laravel-waha-saloon-sdk)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7076376fe34bbb2786b34bc2b852f1ea673cdb9bcfa64727ee943b9e8a6058ff/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6368656e676b616e677a61692f6c61726176656c2d776168612d73616c6f6f6e2d73646b2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/chengkangzai/laravel-waha-saloon-sdk/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/0f22e681b62cf98d3a4c92db4673462ab93afb6f00eba02656e639b48b07301b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6368656e676b616e677a61692f6c61726176656c2d776168612d73616c6f6f6e2d73646b2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/chengkangzai/laravel-waha-saloon-sdk/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/086bab6fb9c4c83d6d0e0463a8ddb6bc036e814827d3b7fbe7206cbc4dd22e0c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368656e676b616e677a61692f6c61726176656c2d776168612d73616c6f6f6e2d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/chengkangzai/laravel-waha-saloon-sdk)

A comprehensive Laravel package that provides a PHP SDK for the [WAHA (WhatsApp HTTP API)](https://waha.devlike.pro/) service. This SDK is auto-generated from the WAHA Postman collection and wrapped with [SaloonPHP](https://docs.saloon.dev/) for elegant HTTP client functionality.

What is WAHA?
-------------

[](#what-is-waha)

WAHA (WhatsApp HTTP API) is a service that provides HTTP RESTful API access to WhatsApp. It allows you to:

- Send and receive WhatsApp messages programmatically
- Manage WhatsApp sessions and authentication
- Handle contacts, groups, and channels
- Implement WhatsApp business features in your application

This SDK makes it easy to integrate WAHA with your Laravel application, providing a fluent, type-safe interface to all WAHA API endpoints.

Features
--------

[](#features)

- 🚀 Auto-generated from WAHA Postman collection
- 🔌 Elegant HTTP client powered by SaloonPHP
- 📦 Laravel integration with service provider and facade
- 🛠️ Comprehensive API coverage with 23 resources and 134 request types
- 🔐 Built-in API key authentication support
- 🧪 Built with testing in mind using Pest PHP
- 🎯 Type-safe request and response handling
- 📋 Support for Laravel 10.x, 11.x, and 12.x

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

[](#installation)

You can install the package via composer:

```
composer require chengkangzai/laravel-waha-saloon-sdk
```

You can publish the config file with:

```
php artisan vendor:publish --tag="waha-saloon-sdk-config"
```

This is the contents of the published config file:

```
return [
    'default' => env('WAHA_CONNECTION', 'default'),

    'connections' => [
        'default' => [
            'base_url' => env('WAHA_BASE_URL', ''),
            'api_key' => env('WAHA_API_KEY', ''),
        ],
    ],

    // Legacy keys for backward compatibility
    'base_url' => env('WAHA_BASE_URL', ''),
    'api_key' => env('WAHA_API_KEY', ''),
];
```

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

[](#configuration)

Set your WAHA instance URL and API key in your `.env` file:

```
WAHA_BASE_URL=https://your-waha-instance.com
WAHA_API_KEY=your-api-key-here
```

The API key is optional but required for most WAHA endpoints (approximately 50% of endpoints require authentication). If not provided, requests will be sent without authentication headers.

Multiple WAHA Hosts
-------------------

[](#multiple-waha-hosts)

The SDK supports connecting to multiple WAHA instances. This is useful when you have separate WAHA servers for different purposes (production, staging, different WhatsApp accounts, etc.).

### Configuring Multiple Hosts

[](#configuring-multiple-hosts)

Update your `config/waha-saloon-sdk.php` to define multiple connections:

```
return [
    'default' => env('WAHA_CONNECTION', 'default'),

    'connections' => [
        'default' => [
            'base_url' => env('WAHA_BASE_URL', ''),
            'api_key' => env('WAHA_API_KEY', ''),
        ],
        'production' => [
            'base_url' => env('WAHA_PRODUCTION_URL', ''),
            'api_key' => env('WAHA_PRODUCTION_KEY', ''),
        ],
        'staging' => [
            'base_url' => env('WAHA_STAGING_URL', ''),
            'api_key' => env('WAHA_STAGING_KEY', ''),
        ],
    ],
];
```

### Using the Waha Facade (Recommended)

[](#using-the-waha-facade-recommended)

```
use CCK\LaravelWahaSaloonSdk\Facades\Waha;

// Use default connection
$response = Waha::sessions()->listAllSessions();

// Use a specific connection
$response = Waha::connection('production')->sessions()->listAllSessions();

// Chain resource methods
$response = Waha::connection('staging')
    ->chats()
    ->getsMessagesInTheChat('default', '1234567890@c.us');
```

### Using Dependency Injection

[](#using-dependency-injection)

```
use CCK\LaravelWahaSaloonSdk\WahaManager;

class WhatsAppController extends Controller
{
    public function __construct(
        private WahaManager $waha,
    ) {}

    public function send(Request $request)
    {
        // Use default connection
        $this->waha->sendText()->sendTextMessage(...);

        // Use specific connection
        $this->waha->connection('production')->sendText()->sendTextMessage(...);
    }
}
```

### Direct Instantiation

[](#direct-instantiation)

Direct instantiation still works and ignores the configuration:

```
use CCK\LaravelWahaSaloonSdk\Waha\Waha;

$waha = new Waha(
    baseUrl: 'https://custom-instance.com',
    apiKey: 'custom-api-key'
);
```

Usage
-----

[](#usage)

### Quick Start Example

[](#quick-start-example)

Here's a complete example showing how to send your first WhatsApp message:

```
