PHPackages                             tarwege/sms-whatsapp - 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. tarwege/sms-whatsapp

ActiveLibrary[API Development](/categories/api)

tarwege/sms-whatsapp
====================

A PHP package to interact with Tarwege SMS, WhatsApp, and USSD endpoints.

12PHP

Since Mar 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Anwar-alhitar/tarwege-sms-whatsapp)[ Packagist](https://packagist.org/packages/tarwege/sms-whatsapp)[ RSS](/packages/tarwege-sms-whatsapp/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Below is an updated version of the README that reflects usage based on the provided class structure and the Guzzle-based API client implementation.

Tarwege SMS &amp; WhatsApp API Client
=====================================

[](#tarwege-sms--whatsapp-api-client)

Official PHP client for Tarwege's SMS &amp; WhatsApp API with first-class Laravel support. Use your SIM to send SMS as a provider.

[![Latest Version](https://camo.githubusercontent.com/75a6a5e26b5775632445a703eb4c1db5a688344bf1cdc0be6561c79f2210d66b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746172776567652f736d732d7768617473617070)](https://packagist.org/packages/tarwege/sms-whatsapp)[![Total Downloads](https://camo.githubusercontent.com/48a64ff5d019f1951fb37b29fa8b54acfbe314dfb73db521e6c89b180474dcfd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746172776567652f736d732d7768617473617070)](https://packagist.org/packages/tarwege/sms-whatsapp)[![License](https://camo.githubusercontent.com/50b27e57444d4748e20a9d20620c561173a1e801705319552b0eb8355bfcfddc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746172776567652f736d732d7768617473617070)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/cd2aff09ca5cd324a362028541e659738ae294406d9a45d5e3b64a8bef3ce95d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f746172776567652f736d732d7768617473617070)](https://php.net)

Features ✨
----------

[](#features-)

Tarwege SMS &amp; WhatsApp API Client provides extensive API coverage including messaging, contact management, campaign management, OTP services, USSD, notifications, and more.

### Core Messaging Features

[](#core-messaging-features)

- **SMS Operations**

    - Send Single SMS
    - Send Bulk SMS
    - Scheduled SMS Campaigns
    - SMS Delivery Status Tracking
    - SMS Message History
    - SMS Auto-Reply System
    - SMS Forwarding
    - SMS Number Validation
- **WhatsApp Operations**

    - Send Text Messages
    - Send Media Messages (Images/Video/Audio)
    - Send Documents (PDF, DOC, XLS)
    - Send Location Sharing
    - Send Contact Cards
    - Bulk WhatsApp Campaigns
    - WhatsApp Template Messages
    - WhatsApp Group Management

### Contact &amp; Campaign Management

[](#contact--campaign-management)

- **Contact System**

    - Create &amp; Manage Contacts and Groups
    - CSV Contact Upload
    - Contact Import/Export and Deduplication
    - Unsubscribe Management
- **Campaign Engine**

    - Create and Schedule SMS/WhatsApp Campaigns
    - Analytics, A/B Testing, and Personalized Messaging
    - Click Tracking and Campaign Pause/Resume

### OTP &amp; Security

[](#otp--security)

- **OTP Services**
    - OTP Generation, Sending &amp; Verification
    - OTP Expiry and Rate Limiting

### Advanced &amp; Enterprise Features

[](#advanced--enterprise-features)

- Automation, USSD Services, Notifications, API Enhancements, and more

---

Installation 🚀
--------------

[](#installation-)

Install via Composer:

```
composer require tarwege/sms-whatsapp
```

For Laravel projects, publish the configuration file:

```
php artisan vendor:publish --provider="Tarwege\SmsWhatsapp\Providers\TarwegeServiceProvider" --tag="tarwege-config"
```

Then, add your API credentials to your `.env` file:

```
TARWEGE_API_SECRET=your_api_secret_here
TARWEGE_BASE_URL=https://api.tarwege.com
```

---

Usage Examples 📖
----------------

[](#usage-examples-)

This package uses a dedicated API client (`TarwegeClient`) and multiple service classes for specific endpoints. When using Laravel, you can access the client via the provided facade (`Tarwege`). Otherwise, instantiate the classes directly by passing a configured client instance.

### 1. Initializing the API Client

[](#1-initializing-the-api-client)

You can either use the facade in Laravel:

```
use Tarwege\SmsWhatsapp\Facades\Tarwege;

// Get the underlying TarwegeClient instance
$tarwegeClient = Tarwege::getFacadeRoot();
```

Or create a new client instance manually:

```
use Tarwege\SmsWhatsapp\Services\TarwegeClient;

$tarwegeClient = new TarwegeClient('your_api_secret_here', 'https://api.tarwege.com');
```

---

### 2. Account Management

[](#2-account-management)

```
use Tarwege\SmsWhatsapp\Services\AccountService;

// Instantiate AccountService with the client
$accountService = new AccountService($tarwegeClient);

// Example: Get partner earnings and remaining credits
$partnerEarnings = $accountService->getPartnerEarnings();
$remainingCredits = $accountService->getRemainingCredits();

// Example: Get subscription package details
$subscription = $accountService->getSubscriptionPackage();
```

---

### 3. SMS Operations

[](#3-sms-operations)

```
use Tarwege\SmsWhatsapp\Services\SmsService;

// Instantiate SmsService with the client
$smsService = new SmsService($tarwegeClient);

// Send a single SMS
$response = $smsService->sendSingleMessage([
    'mode'    => 'credits',
    'phone'   => '+967781606026',
    'message' => 'Your OTP is {{otp}}',
    'gateway' => 'partner_device_id'
]);

// Send bulk SMS messages
$bulkResponse = $smsService->sendBulkMessages([
    'campaign' => 'Holiday Sale',
    'groups'   => '1,2,5',
    'message'  => 'Special discounts inside!'
]);
```

---

### 4. WhatsApp Integration

[](#4-whatsapp-integration)

```
use Tarwege\SmsWhatsapp\Services\WhatsAppService;

// Instantiate WhatsAppService with the client
$waService = new WhatsAppService($tarwegeClient);

// Send a single WhatsApp chat message
$response = $waService->sendSingleChat([
    'account'   => 'wa_account_id',
    'recipient' => '+967781606026',
    'type'      => 'text',
    'message'   => 'Hello from Tarwege!'
]);

// Validate a WhatsApp phone number
$validation = $waService->validateWhatsAppPhoneNumber([
    'unique' => 'wa_account_id',
    'phone'  => '+967781606026'
]);
```

---

### 5. OTP Services

[](#5-otp-services)

```
use Tarwege\SmsWhatsapp\Services\OTPService;

// Instantiate OTPService with the client
$otpService = new OTPService($tarwegeClient);

// Send an OTP (with a 5-minute expiration)
$sendResponse = $otpService->sendOTP([
    'phone'   => '+967781606026',
    'message' => 'Your verification code: {{otp}}',
    'expire'  => 300
]);

// Verify an OTP
try {
    $verifyResponse = $otpService->verifyOTP([
        'phone' => '+967781606026',
        'otp'   => '123456'
    ]);
} catch (\Tarwege\SmsWhatsapp\Exceptions\TarwegeApiException $e) {
    // Handle error, e.g., invalid OTP or API error
    logger()->error("OTP Verification failed: {$e->getMessage()}");
}
```

---

### 6. Additional Services

[](#6-additional-services)

Similarly, you can use the other provided services by instantiating them with the API client:

- **ContactService**: Manage contacts and groups

    ```
    use Tarwege\SmsWhatsapp\Services\ContactService;

    $contactService = new ContactService($tarwegeClient);
    $contacts = $contactService->getContacts();
    ```
- **NotificationService**: Manage notifications

    ```
    use Tarwege\SmsWhatsapp\Services\NotificationService;

    $notificationService = new NotificationService($tarwegeClient);
    $notifications = $notificationService->getNotifications();
    ```
- **SystemService**: Get system-related data (gateway rates, shorteners)

    ```
    use Tarwege\SmsWhatsapp\Services\SystemService;

    $systemService = new SystemService($tarwegeClient);
    $gatewayRates = $systemService->getGatewayRates();
    ```
- **UssdService**: Handle USSD requests

    ```
    use Tarwege\SmsWhatsapp\Services\UssdService;

    $ussdService = new UssdService($tarwegeClient);
    $ussdRequests = $ussdService->getUssdRequests();
    ```

---

Advanced Configuration ⚙️
-------------------------

[](#advanced-configuration-️)

Customize settings in `config/tarwege.php` (published for Laravel or manually created for non-Laravel usage):

```
return [
    'secret' => env('TARWEGE_API_SECRET'),

    // Request timeout in seconds
    'timeout' => 15,

    // Automatic retry configuration
    'retries' => [
        'attempts'   => 3,
        'sleep_ms'   => 1000,
        'http_codes' => [500, 502, 503, 504]
    ],

    // Default SMS settings
    'sms_defaults' => [
        'mode'     => 'credits',
        'sim'      => 1,
        'priority' => 1
    ]
];
```

---

API Method Reference 📚
----------------------

[](#api-method-reference-)

CategoryMethods**Account**`getPartnerEarnings()`, `getRemainingCredits()`, `getSubscriptionPackage()`**Contacts**`createContact()`, `getContacts()`, `deleteContact()`, `getGroups()`**SMS**`sendSingleMessage()`, `sendBulkMessages()`, `getSentMessages()`, `deleteReceivedMessage()`, etc.**WhatsApp**`sendSingleChat()`, `sendBulkChats()`, `getAccounts()`, `validateWhatsAppPhoneNumber()`, etc.**USSD**`sendUssdRequest()`, `getUssdRequests()`, `clearPendingUssd()`**Notifications**`getNotifications()`, `deleteNotification()`---

Testing 🧪
---------

[](#testing-)

Run the test suite using:

```
composer test
```

Tests cover:

- API request validation
- Error handling and retry logic
- File uploads and response parsing

---

Security 🔒
----------

[](#security-)

Please report security vulnerabilities to **** – do **NOT** use the public issue tracker.

---

Support &amp; Contributing 🤝
----------------------------

[](#support--contributing-)

**Official Support:**

- **Email:**
- **Chat:** [Tarwege Support Portal](https://wa.me/+967781606026)

**Contributing Guidelines:**

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/amazing-feature`
3. Commit your changes: `git commit -m 'Add amazing feature'`
4. Push your branch: `git push origin feature/amazing-feature`
5. Open a Pull Request

---

License 📄
---------

[](#license-)

This project is licensed under the MIT License – see the [LICENSE](LICENSE) file for details.

---

📄 **Full API Documentation:** [Tarwege API Docs](https://sms.tarwege.com/docs)
🐛 **Issue Tracker:** [GitHub Issues](https://github.com/tarwege/sms-whatsapp/issues)
💡 **Changelog:** [Releases Page](https://github.com/tarwege/sms-whatsapp/releases)

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/18a7f2bd06a537ac216cd164a4336724a2efc799a7019804e32dd6ff14ad31e4?d=identicon)[Anwar-alhitar](/maintainers/Anwar-alhitar)

---

Top Contributors

[![Anwar-alhitar](https://avatars.githubusercontent.com/u/32067919?v=4)](https://github.com/Anwar-alhitar "Anwar-alhitar (29 commits)")

### Embed Badge

![Health badge](/badges/tarwege-sms-whatsapp/health.svg)

```
[![Health](https://phpackages.com/badges/tarwege-sms-whatsapp/health.svg)](https://phpackages.com/packages/tarwege-sms-whatsapp)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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