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

ActiveLibrary[API Development](/categories/api)

renzojohnson/whatsapp-cloud-api
===============================

Lightweight PHP wrapper for Meta's WhatsApp Cloud API. Send text, template, image, document, video, audio, location, contact, and sticker messages. Receive webhooks with signature verification. Zero dependencies.

v1.0.0(3mo ago)20MITPHPPHP ^8.4

Since Feb 24Pushed 3mo agoCompare

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

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

WhatsApp Cloud API for PHP
==========================

[](#whatsapp-cloud-api-for-php)

[![Latest Version](https://camo.githubusercontent.com/5ec744e7893ebe0bad0eb85212b2e32e2333ac7b166babe089f5be231cbed03d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72656e7a6f6a6f686e736f6e2f77686174736170702d636c6f75642d6170692e737667)](https://packagist.org/packages/renzojohnson/whatsapp-cloud-api)[![PHP Version](https://camo.githubusercontent.com/f975e40122120c555d15ed874abd051c29de007c7562fa44458e654df08e78f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72656e7a6f6a6f686e736f6e2f77686174736170702d636c6f75642d6170692e737667)](https://packagist.org/packages/renzojohnson/whatsapp-cloud-api)[![License](https://camo.githubusercontent.com/6df6d1bff8350d81a36d73cbcda8e73a2be12ceef713e53e017b07b0d5722c8e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72656e7a6f6a6f686e736f6e2f77686174736170702d636c6f75642d6170692e737667)](https://github.com/renzojohnson/whatsapp-cloud-api/blob/main/LICENSE)

Lightweight PHP wrapper for [Meta's WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api). Zero dependencies.

Send text, template, image, document, video, audio, location, contact, and sticker messages. Receive and verify webhooks.

**Author:** [Renzo Johnson](https://renzojohnson.com)

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

[](#requirements)

- PHP 8.4+
- ext-curl
- ext-json

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

[](#installation)

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

Quick Start
-----------

[](#quick-start)

```
use RenzoJohnson\WhatsApp\WhatsApp;

$wa = new WhatsApp('YOUR_PHONE_NUMBER_ID', 'YOUR_ACCESS_TOKEN');

// Send a text message
$wa->sendText('14155551234', 'Hello from PHP!');
```

Sending Messages
----------------

[](#sending-messages)

### Text

[](#text)

```
$wa->sendText('14155551234', 'Hello World');

// With link preview
$wa->sendText('14155551234', 'Check https://example.com', previewUrl: true);
```

### Template

[](#template)

```
// Simple template (no parameters)
$wa->sendTemplate('14155551234', 'hello_world', 'en_US');

// Template with parameters
$wa->sendTemplate('14155551234', 'order_update', 'en_US', [
    [
        'type' => 'body',
        'parameters' => [
            ['type' => 'text', 'text' => 'John'],
            ['type' => 'text', 'text' => 'ORD-12345'],
        ],
    ],
]);
```

### Image

[](#image)

```
// By URL
$wa->sendImage('14155551234', link: 'https://example.com/photo.jpg', caption: 'A photo');

// By media ID (uploaded via uploadMedia)
$wa->sendImage('14155551234', mediaId: 'media_123');
```

### Document

[](#document)

```
$wa->sendDocument(
    '14155551234',
    link: 'https://example.com/invoice.pdf',
    caption: 'Your invoice',
    filename: 'invoice-2026.pdf',
);
```

### Video

[](#video)

```
$wa->sendVideo('14155551234', link: 'https://example.com/clip.mp4', caption: 'Watch this');
```

### Audio

[](#audio)

```
$wa->sendAudio('14155551234', link: 'https://example.com/audio.mp3');
```

### Location

[](#location)

```
$wa->sendLocation(
    '14155551234',
    latitude: 28.5383,
    longitude: -81.3792,
    name: 'Orlando Office',
    address: '123 Main St, Orlando, FL',
);
```

### Contact

[](#contact)

```
$wa->sendContact(
    '14155551234',
    name: ['first_name' => 'Jane', 'last_name' => 'Doe'],
    phones: [['phone' => '+14155559999', 'type' => 'CELL']],
);
```

### Sticker

[](#sticker)

```
$wa->sendSticker('14155551234', link: 'https://example.com/sticker.webp');
```

Media
-----

[](#media)

### Upload

[](#upload)

```
$response = $wa->uploadMedia('/path/to/file.jpg', 'image/jpeg');
$mediaId = $response['id'];
```

### Get Media URL

[](#get-media-url)

```
$media = $wa->getMedia('media_123');
$url = $media['url'];
```

### Delete

[](#delete)

```
$wa->deleteMedia('media_123');
```

Mark as Read
------------

[](#mark-as-read)

```
$wa->markAsRead('wamid.abc123');
```

Webhooks
--------

[](#webhooks)

### Verification (GET request from Meta)

[](#verification-get-request-from-meta)

```
use RenzoJohnson\WhatsApp\Webhook\Listener;

// Responds to Meta's verification challenge
Listener::verify('YOUR_VERIFY_TOKEN');
```

### Receiving Messages (POST from Meta)

[](#receiving-messages-post-from-meta)

```
use RenzoJohnson\WhatsApp\Webhook\Listener;
use RenzoJohnson\WhatsApp\Webhook\Notification;

Listener::listen('YOUR_APP_SECRET', function (Notification $notification, array $raw) {
    if ($notification->isText()) {
        echo 'From: ' . $notification->from . "\n";
        echo 'Text: ' . $notification->text . "\n";
    }

    if ($notification->isImage()) {
        echo 'Image ID: ' . $notification->image['id'] . "\n";
    }
});
```

The listener validates the `X-Hub-Signature-256` header using HMAC-SHA256 before processing. Invalid signatures return 401.

### Notification Properties

[](#notification-properties)

PropertyTypeDescription`from`stringSender's phone number`type`stringMessage type (text, image, document, etc.)`timestamp`stringUnix timestamp`messageId`?stringWhatsApp message ID`text`?stringText body (when type is text)`image`?arrayImage data (id, mime\_type, sha256)`document`?arrayDocument data`video`?arrayVideo data`audio`?arrayAudio data`location`?arrayLocation data (latitude, longitude)`sticker`?arraySticker data`contacts`?arrayContact cards`interactive`?arrayInteractive response data`context`?arrayReply context (quoted message)### Type Checks

[](#type-checks)

```
$notification->isText();
$notification->isImage();
$notification->isDocument();
$notification->isVideo();
$notification->isAudio();
$notification->isLocation();
$notification->isSticker();
$notification->isInteractive();
```

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

[](#error-handling)

```
use RenzoJohnson\WhatsApp\Exception\AuthenticationException;
use RenzoJohnson\WhatsApp\Exception\RateLimitException;
use RenzoJohnson\WhatsApp\Exception\WhatsAppException;

try {
    $wa->sendText('14155551234', 'Hello');
} catch (AuthenticationException $e) {
    // Invalid or expired access token (401)
} catch (RateLimitException $e) {
    // Too many requests (429)
} catch (WhatsAppException $e) {
    // Other API errors (400, 500, etc.)
    $errorData = $e->getErrorData();
}
```

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

Links
-----

[](#links)

- [Packagist](https://packagist.org/packages/renzojohnson/whatsapp-cloud-api)
- [GitHub](https://github.com/renzojohnson/whatsapp-cloud-api)
- [Issues](https://github.com/renzojohnson/whatsapp-cloud-api/issues)
- [Author](https://renzojohnson.com)

License
-------

[](#license)

MIT License. Copyright (c) 2026 [Renzo Johnson](https://renzojohnson.com).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance81

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

106d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e1b69733e3d1fd486158d322c23d99281623046b3c357529c9930e50d73fcda?d=identicon)[renzo.johnson](/maintainers/renzo.johnson)

---

Top Contributors

[![renzojohnson](https://avatars.githubusercontent.com/u/4695400?v=4)](https://github.com/renzojohnson "renzojohnson (7 commits)")

---

Tags

messagingmetaphpwebhookwhatsappwhatsapp-apiwhatsapp-businesswhatsapp-cloud-apiphpsmsmessagingwebhookchatwhatsappmetawhatsapp-businesswhatsapp-cloud-api

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

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

PHPackages © 2026

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