PHPackages                             michotechnologies/michowapi-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. michotechnologies/michowapi-laravel

ActiveLibrary[API Development](/categories/api)

michotechnologies/michowapi-laravel
===================================

Laravel SDK for MichoWAPI - WhatsApp messaging gateway by Micho Technologies

v1.0.0(1mo ago)15MITPHPPHP ^8.1

Since Apr 13Pushed 1mo agoCompare

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

READMEChangelogDependencies (7)Versions (2)Used By (0)

MichoWAPI Laravel SDK
=====================

[](#michowapi-laravel-sdk)

[![Latest Version on Packagist](https://camo.githubusercontent.com/78824b278eb27b9a89e5c39f77bca1f0188420b77342aecc1df325233f7c22b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6963686f746563686e6f6c6f676965732f6d6963686f776170692d6c61726176656c2e737667)](https://packagist.org/packages/michotechnologies/michowapi-laravel)[![License](https://camo.githubusercontent.com/f33fe93ad56ff732f0df9b5495d1e6cb35598271a0f31ff1dcc8a1add26f7de2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6963686f746563686e6f6c6f676965732f6d6963686f776170692d6c61726176656c2e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/17b5e474746502e90d91dd12496e4e9543ccbe197bbdbd8e4053edb0101cb5db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6963686f746563686e6f6c6f676965732f6d6963686f776170692d6c61726176656c2e737667)](composer.json)

Official Laravel SDK for [MichoWAPI](https://wapi.michotech.me) — the WhatsApp messaging gateway by [Micho Technologies](https://michotech.me).

Send text messages, upload media files, retrieve message history, and handle webhooks — all from your Laravel application using a clean, fluent API.

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10, 11, or 12

---

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

[](#installation)

```
composer require michotechnologies/michowapi-laravel
```

Laravel auto-discovers the service provider and `WApi` facade automatically. No manual registration needed.

Publish the config file:

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

---

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

[](#configuration)

Add the following to your `.env` file:

```
MICHOWAPI_URL=https://wapi.michotech.me
MICHOWAPI_KEY=mw_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MICHOWAPI_TIMEOUT=30
MICHOWAPI_MEDIA_TIMEOUT=120
MICHOWAPI_WEBHOOK_SECRET=your-webhook-secret
```

VariableDescriptionDefault`MICHOWAPI_URL`Base URL of the MichoWAPI gateway`https://wapi.michotech.me``MICHOWAPI_KEY`Your API key (format: `mw_` + 40 chars)—`MICHOWAPI_TIMEOUT`HTTP timeout in seconds for text requests`30``MICHOWAPI_MEDIA_TIMEOUT`Timeout for media file uploads`120``MICHOWAPI_WEBHOOK_SECRET`HMAC secret for verifying webhook payloads—> **Note:** Each API key is bound to one WhatsApp session automatically — you do not pass a session ID in requests. To use multiple WhatsApp numbers, generate a separate key per session and instantiate the client separately for each.

---

Getting Started
---------------

[](#getting-started)

### 1. Create a Session

[](#1-create-a-session)

Log into the [MichoWAPI dashboard](https://wapi.michotech.me), go to **Sessions**, click **New Session**, and scan the QR code with your phone via WhatsApp &gt; Linked Devices.

### 2. Generate an API Key

[](#2-generate-an-api-key)

Go to **API Keys**, click **Generate API Key**, select the session, and copy the key. It will not be shown again.

### 3. Send Your First Message

[](#3-send-your-first-message)

```
use MichoTech\WApi\Facades\WApi;

WApi::messages()->sendText('260971000000', 'Hello from MichoWAPI!');
```

---

Usage
-----

[](#usage)

### Via Facade

[](#via-facade)

```
use MichoTech\WApi\Facades\WApi;

WApi::messages()->sendText('260971000000', 'Hello!');
```

### Via Dependency Injection

[](#via-dependency-injection)

```
use MichoTech\WApi\MichoWapi;

class NotificationController extends Controller
{
    public function __construct(protected MichoWapi $wapi) {}

    public function send(): void
    {
        $this->wapi->messages()->sendText('260971000000', 'Hello!');
    }
}
```

---

Messages
--------

[](#messages)

### Send Text

[](#send-text)

```
WApi::messages()->sendText('260971000000', 'Your exam results are ready.');
```

Phone numbers must include the country code and contain digits only (e.g. `260971000000`, not `+260 971 000 000`).

### Send Media

[](#send-media)

Send any file (image, video, audio, PDF, etc.) using `sendMedia()`. The file is uploaded directly — no public URL required.

```
// From a file path
WApi::messages()->sendMedia('260971000000', '/path/to/photo.jpg', caption: 'School photo');

// From an SplFileInfo (e.g. from a Laravel uploaded file)
$file = $request->file('attachment'); // UploadedFile extends SplFileInfo
WApi::messages()->sendMedia('260971000000', $file, caption: 'Your invoice');

// From an open stream
$stream = fopen('/path/to/audio.mp3', 'r');
WApi::messages()->sendMedia('260971000000', $stream, filename: 'voice-note.mp3');
```

**Parameters:**

ParameterTypeRequiredDescription`$to`stringYesRecipient phone number`$file`string / SplFileInfo / resourceYesFile path, SplFileInfo, or stream`$filename`string|nullNoOverride the filename shown to recipient`$caption`string|nullNoCaption shown below the media`$sendAsDocument`boolNoForce the file to be sent as a document### Send as Document

[](#send-as-document)

Use `sendDocument()` as a shortcut to always send as a document attachment:

```
WApi::messages()->sendDocument(
    '260971000000',
    '/path/to/report.pdf',
    filename: 'Term 2 Report Card.pdf',
    caption: 'Please find your results attached.',
);
```

### Send Bulk

[](#send-bulk)

Send the same text to multiple recipients. Returns results keyed by phone number.

```
$results = WApi::messages()->sendBulk(
    ['260971111111', '260972222222', '260973333333'],
    'School fees for Term 3 are due. Log in to MichoSMS to view your balance.'
);

foreach ($results as $phone => $result) {
    $messageId = $result['data']['message_id'];
}
```

---

Message History
---------------

[](#message-history)

### List Messages

[](#list-messages)

```
// All messages (paginated)
$messages = WApi::messages()->list();

// Filtered
$messages = WApi::messages()->list([
    'from_me' => true,                 // outbound only
    'type'    => 'image',              // chat | image | video | audio | document
    'chat_id' => '260971000000@c.us',  // specific contact
    'page'    => 2,
]);
```

### Get a Single Message

[](#get-a-single-message)

```
$message = WApi::messages()->find('3EB0A0B4F3...');

// $message['data']['status'] can be:
// queued | sent | delivered | read | failed
```

### Received Messages

[](#received-messages)

```
// Only inbound messages
$received = WApi::messages()->received(page: 1);
```

### Sync Messages

[](#sync-messages)

Pull in messages that arrived while the session was offline:

```
WApi::messages()->sync();
```

### Messages in a Specific Chat

[](#messages-in-a-specific-chat)

```
$chatMessages = WApi::messages()->forChat('260971000000@c.us', page: 1);
```

---

Webhooks
--------

[](#webhooks)

### Configure

[](#configure)

Set your webhook URL in the MichoWAPI dashboard under your session settings.

Register a route:

```
// routes/api.php
Route::post('/webhooks/whatsapp', [WhatsAppWebhookController::class, 'handle']);
```

Exclude from CSRF in `bootstrap/app.php` (Laravel 11+):

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: ['webhooks/*']);
})
```

### Handle Webhook Events

[](#handle-webhook-events)

```
