PHPackages                             texhub/whatsapp-cloud-api - 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. texhub/whatsapp-cloud-api

ActiveLibrary[API Development](/categories/api)

texhub/whatsapp-cloud-api
=========================

Full-featured WhatsApp Cloud API (Business Platform / Graph API) SDK for any PHP framework with first-class Laravel support: send text/media/template/interactive messages, media upload/download, business profile, templates and webhooks.

v1.1.1(1mo ago)01MITPHPPHP ^8.2

Since Jun 1Pushed 1mo agoCompare

[ Source](https://github.com/TexhubPro/whatsapp-cloud-api)[ Packagist](https://packagist.org/packages/texhub/whatsapp-cloud-api)[ Docs](https://texhub.pro)[ RSS](/packages/texhub-whatsapp-cloud-api/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

TexHub · WhatsApp Cloud API
===========================

[](#texhub--whatsapp-cloud-api)

**English** · [Русский](README.ru.md)

[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP](https://camo.githubusercontent.com/d91d3d1139cf0d8faaa80eeeeac7d3c59c9319e56960ef81c948e4160be4c4c1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737376262342e737667)](composer.json)[![Laravel](https://camo.githubusercontent.com/3e9242504354dbb5afd360f9a1ec114126b2caddb73d9e789d9102c3285d2b05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3131253230253743253230313225323025374325323031332d6666326432302e737667)](#laravel)

A complete, framework-agnostic PHP SDK for the **WhatsApp Cloud API** (WhatsApp Business Platform / Graph API) — send text, media, templates and **interactive buttons &amp; lists**, manage media, business profile and templates, and receive **webhooks** — with first-class **Laravel** support.

Reference:

---

What's covered
--------------

[](#whats-covered)

AreaMethods**Messages**text, image, video, audio, document, **interactive buttons**, **lists**, **templates**, location, reaction, mark-read**Media**upload, get URL, **download**, delete**Profile**get/update business profile, phone numbers**Templates**list, create, delete**Webhooks**verify challenge, **verify `X-Hub-Signature-256`**, parse incoming messages + delivery statuses**Escape hatch**`->http()` for any endpoint---

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

[](#installation)

```
composer require texhub/whatsapp-cloud-api
```

Requirements: **PHP ≥ 8.2** with `curl`, `json`, `hash`.

---

Quick start
-----------

[](#quick-start)

```
use TexHub\WhatsApp\WhatsApp;

$wa = WhatsApp::make(
    accessToken: 'YOUR_PERMANENT_TOKEN',
    phoneNumberId: 'YOUR_PHONE_NUMBER_ID',
    businessAccountId: 'YOUR_WABA_ID', // optional, needed for templates/phone list
);

$wa->sendText('992900123456', 'Привет из TexHub! 👋');
```

> Numbers are in international format **without** `+` (e.g. `992900123456`).

---

Messages
--------

[](#messages)

```
use TexHub\WhatsApp\Builders\Button;

// Media (by public URL):
$wa->messages()->image('992900123456', 'https://cdn/photo.jpg', caption: 'Фото');
$wa->messages()->document('992900123456', 'https://cdn/file.pdf', filename: 'invoice.pdf');

// Interactive reply buttons (max 3):
$wa->messages()->buttons('992900123456', 'Подтвердите заказ:', [
    Button::reply('confirm', 'Подтвердить'),
    Button::reply('cancel', 'Отменить'),
]);

// Interactive list:
$wa->messages()->list('992900123456', 'Выберите услугу', 'Открыть меню', [
    Button::section('Услуги', [
        Button::row('svc_1', 'Доставка', 'Курьером по городу'),
        Button::row('svc_2', 'Самовывоз'),
    ]),
]);

// Template (the only way to message outside the 24h window):
$wa->messages()->template('992900123456', 'hello_world', 'en_US');

// Location, reaction, mark as read:
$wa->messages()->location('992900123456', 38.5598, 68.7870, 'Душанбе');
$wa->messages()->reaction('992900123456', 'wamid.XXX', '👍');
$wa->messages()->markRead('wamid.INCOMING');
```

---

Media
-----

[](#media)

```
$id = $wa->media()->upload('/path/image.jpg')->id();   // upload, get a media id
$wa->messages()->mediaById('992900123456', 'image', $id);

$url = $wa->media()->url($mediaId);                     // temporary download URL
$bytes = $wa->media()->download($mediaId);              // raw binary
$wa->media()->delete($mediaId);
```

Profile &amp; templates
-----------------------

[](#profile--templates)

```
$wa->profile()->get();
$wa->profile()->update(['about' => 'TexHub — интеграции', 'email' => 'info@texhub.pro']);
$wa->profile()->phoneNumbers();      // needs businessAccountId

$wa->templates()->list();            // needs businessAccountId
```

---

Webhooks
--------

[](#webhooks)

**Verification (GET)** — echo the challenge:

```
$challenge = $wa->webhooks()->verifyChallenge($_GET);
if ($challenge !== null) { echo $challenge; exit; }
```

**Events (POST)** — verify the signature, then parse messages &amp; statuses:

```
$raw = file_get_contents('php://input');
$wa->webhooks()->assertValidSignature($raw, $_SERVER['HTTP_X_HUB_SIGNATURE_256'] ?? null);

foreach ($wa->webhooks()->parse($raw) as $event) {
    if ($event->isMessage()) {
        $from = $event->from();
        if ($event->messageType() === 'text') {
            $wa->messages()->markRead($event->messageId());
            $wa->messages()->text($from, 'Получили: ' . $event->text());
        }
        if ($event->messageType() === 'interactive') {
            $reply = $event->interactiveReply(); // ['id' => ..., 'title' => ...]
        }
    }

    if ($event->isStatus()) {
        $event->status(); // sent | delivered | read | failed
    }
}
http_response_code(200);
```

---

Error handling
--------------

[](#error-handling)

```
use TexHub\WhatsApp\Exceptions\ApiException;

try {
    $wa->sendText($to, $text);
} catch (ApiException $e) {
    $e->httpStatus; $e->errorCode; $e->errorType; $e->errorSubcode; $e->fbtraceId;
    $e->isTokenError();   // code 190
    $e->isRateLimit();
}
```

---

 Laravel
-------------------------------------------

[](#-laravel)

Auto-discovered. Publish config:

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

`.env`:

```
WHATSAPP_ACCESS_TOKEN=...
WHATSAPP_PHONE_NUMBER_ID=...
WHATSAPP_BUSINESS_ACCOUNT_ID=...
WHATSAPP_APP_ID=...
WHATSAPP_APP_SECRET=...
WHATSAPP_WEBHOOK_VERIFY_TOKEN=...
WHATSAPP_API_VERSION=v23.0
```

Facade:

```
use TexHub\WhatsApp\Laravel\WhatsApp;

WhatsApp::sendText('992900123456', 'Привет из Laravel!');
WhatsApp::messages()->buttons('992900123456', 'Выбор:', [/* ... */]);
```

---

Multi-tenant / SaaS
-------------------

[](#multi-tenant--saas)

Built for SaaS where many customers connect **their own** WhatsApp. One Meta app, one webhook URL, isolated per-tenant data.

```
// 1) Customer onboarding via Embedded Signup (front-end returns a `code`):
$wa = WhatsApp::fromArray(['access_token' => '...', 'phone_number_id' => '...', 'app_id' => '...', 'app_secret' => '...']);
$token = $wa->onboarding()->exchangeCode($code)->get('access_token'); // customer business token
$wa->onboarding()->subscribeApp($wabaId, $token);                      // route their webhooks to you
$wa->onboarding()->registerPhone($phoneNumberId, '123456', $token);    // 6-digit PIN
// → store {token, waba_id, phone_number_id} for this tenant

// 2) Send as any tenant — build a client with their stored creds:
WhatsApp::fromArray($tenant->whatsappConfig())->sendText($to, $text);

// 3) One webhook for everyone — route by phone number / WABA id:
foreach ($wa->webhooks()->parse($raw) as $event) {
    $tenant = Tenant::where('wa_phone_number_id', $event->phoneNumberId())->first();
    //      or ->where('wa_business_account_id', $event->wabaId())
}
```

`$event->phoneNumberId()`, `->wabaId()`, `->displayPhoneNumber()`, `->contactName()` give you everything needed to route to the right customer. Webhook signatures are verified with your single app secret.

Testing
-------

[](#testing)

```
use TexHub\WhatsApp\WhatsApp;
use TexHub\WhatsApp\Config;
use TexHub\WhatsApp\Tests\Support\FakeTransport;

$t = (new FakeTransport())->push(['messages' => [['id' => 'wamid.1']]]);
$wa = new WhatsApp(new Config('TOKEN', '123456'), $t);
$wa->sendText('992900123456', 'hi'); // assert on $t->last()
```

```
composer install && composer test
```

---

Architecture
------------

[](#architecture)

```
src/
├── WhatsApp.php             # entry — messages()/media()/profile()/templates()/webhooks()
├── Config.php               # immutable configuration
├── Http/                    # Transport, CurlTransport (JSON/multipart), HttpClient, FileParam
├── Builders/                # Message, Button (interactive buttons & lists)
├── Resources/               # Messages, Media, Profile, Templates
├── Webhook/                 # WebhookHandler (challenge + signature + parse), WebhookEvent
├── Responses/               # Response (ArrayAccess), ListResponse
├── Exceptions/              # ApiException, TransportException, …
└── Laravel/                 # ServiceProvider + Facade

```

---

License
-------

[](#license)

MIT © TexHub Pro — built by Mahmudi Shodmehr.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance93

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~10 days

Total

3

Last Release

34d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/217647751?v=4)[TexHub Pro](/maintainers/TexhubPro)[@TexhubPro](https://github.com/TexhubPro)

---

Top Contributors

[![TexhubPro](https://avatars.githubusercontent.com/u/217647751?v=4)](https://github.com/TexhubPro "TexhubPro (3 commits)")

---

Tags

laravelmessagingmetaphpsdkwebhookswhatsappwhatsapp-cloud-apiphplaravelmessagingwebhookswhatsappmetawhatsapp-businesswhatsapp-cloud-apitexhub

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/texhub-whatsapp-cloud-api/health.svg)

```
[![Health](https://phpackages.com/badges/texhub-whatsapp-cloud-api/health.svg)](https://phpackages.com/packages/texhub-whatsapp-cloud-api)
```

###  Alternatives

[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

783.8k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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