PHPackages                             rstacode/otpiq - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. rstacode/otpiq

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

rstacode/otpiq
==============

A Laravel package for handling OTP verification, The most reliable SMS &amp; WhatsApp &amp; Telegram verification platform for your business in Iraq

2.1.1(5d ago)4358↓100%MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Jan 30Pushed 5d agoCompare

[ Source](https://github.com/Rstacode/otpiq)[ Packagist](https://packagist.org/packages/rstacode/otpiq)[ Docs](https://github.com/rstacode/otpiq)[ RSS](/packages/rstacode-otpiq/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (16)Used By (0)

OTPIQ Laravel Package
=====================

[](#otpiq-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dfb96241fba27b23f161dd234f525ec04b5ced67dd71ee75ea3528b3dbafa13e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72737461636f64652f6f747069712e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rstacode/otpiq)[![Total Downloads](https://camo.githubusercontent.com/a270031c9b13433b069873ce349c019b474db89754acd042f0cec905f6375bd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72737461636f64652f6f747069712e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rstacode/otpiq)[![License](https://camo.githubusercontent.com/eb6b7581a35a00df830968bd1a42a9872888bf422178e12c437e471365da7609/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72737461636f64652f6f747069712e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rstacode/otpiq)

The most reliable SMS, WhatsApp, and Telegram verification platform for your business in Iraq and Kurdistan.

OTPIQ provides a simple and powerful Laravel package to send verification codes and custom messages through multiple channels including SMS, WhatsApp, and Telegram with automatic fallback support.

Features
--------

[](#features)

- 🚀 **Multiple Channels**: SMS, WhatsApp, Telegram with automatic fallback
- 🔐 **Verification Codes**: Send OTP codes with ease
- 💬 **Custom Messages**: Send transactional and marketing messages
- 📱 **WhatsApp Templates**: Support for WhatsApp Business templates
- 🔄 **Auto Fallback**: Automatic channel switching for delivery guarantee
- 📊 **Delivery Tracking**: Real-time SMS delivery status tracking
- 🎯 **Custom Sender IDs**: Use your own branded sender IDs
- ⚡ **Fast &amp; Reliable**: Optimized for performance
- 🛡️ **Exception Handling**: Comprehensive error handling

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

[](#requirements)

- PHP 8.1, 8.2, 8.3, or 8.4
- Laravel 10, 11, 12, or 13

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

[](#installation)

Install the package via Composer:

```
composer require rstacode/otpiq
```

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

[](#configuration)

Publish the configuration file:

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

Add your OTPIQ API key to your `.env` file:

```
OTPIQ_API_KEY=sk_live_your_api_key_here
OTPIQ_BASE_URL=https://api.otpiq.com/api/
OTPIQ_TIMEOUT=30
```

You can get your API key from the [OTPIQ Dashboard](https://app.otpiq.com).

Usage
-----

[](#usage)

### Get Project Information

[](#get-project-information)

Retrieve your project details and remaining credits:

```
use Rstacode\Otpiq\Facades\Otpiq;

$info = Otpiq::getProjectInfo();

echo $info['projectName'];
echo $info['credit'];
```

**Response:**

```
[
    'projectName' => 'My SMS Project',
    'credit' => 15000
]
```

### Send Verification Code

[](#send-verification-code)

Send a verification code to a phone number:

```
use Rstacode\Otpiq\Facades\Otpiq;

$response = Otpiq::sendSms([
    'phoneNumber' => '964750123456',
    'smsType' => 'verification',
    'verificationCode' => '123456',
    'provider' => 'whatsapp-sms',
]);

echo $response['smsId'];
echo $response['remainingCredit'];
echo $response['cost'];
```

**Response:**

```
[
    'message' => 'SMS task created successfully',
    'smsId' => 'sms-1234567890abcdef123456',
    'remainingCredit' => 14800,
    'cost' => 200,
    'canCover' => true,
    'paymentType' => 'prepaid'
]
```

#### With Custom Sender ID

[](#with-custom-sender-id)

```
$response = Otpiq::sendSms([
    'phoneNumber' => '964750123456',
    'smsType' => 'verification',
    'verificationCode' => '123456',
    'senderId' => 'MyBrand',
    'provider' => 'sms',
]);
```

#### With Delivery Report Webhook

[](#with-delivery-report-webhook)

```
$response = Otpiq::sendSms([
    'phoneNumber' => '964750123456',
    'smsType' => 'verification',
    'verificationCode' => '123456',
    'deliveryReport' => [
        'webhookUrl' => 'https://your-app.com/webhooks/sms-status',
        'deliveryReportType' => 'all',
        'webhookSecret' => 'your_webhook_secret_123',
    ],
]);
```

### Send Custom Message

[](#send-custom-message)

Send a custom transactional or marketing message:

```
use Rstacode\Otpiq\Facades\Otpiq;

$response = Otpiq::sendSms([
    'phoneNumber' => '964750123456',
    'smsType' => 'custom',
    'customMessage' => 'Your order #12345 has been confirmed. Thank you!',
    'senderId' => 'MyShop',
    'provider' => 'sms',
]);
```

### Send WhatsApp Template Message

[](#send-whatsapp-template-message)

Send a message using a pre-approved WhatsApp template:

```
use Rstacode\Otpiq\Facades\Otpiq;

$response = Otpiq::sendSms([
    'phoneNumber' => '964750123456',
    'smsType' => 'whatsapp-template',
    'templateName' => 'auth_template',
    'whatsappAccountId' => '68c46fecc509cdcec8fb3ef2',
    'whatsappPhoneId' => '68da31fb518ac3db3eb0a0f4',
    'templateParameters' => [
        'body' => [
            '1' => '123456',
            '2' => '10',
        ],
    ],
    'provider' => 'whatsapp',
]);
```

### Track SMS Status

[](#track-sms-status)

Track the delivery status of a sent message:

```
use Rstacode\Otpiq\Facades\Otpiq;

$status = Otpiq::trackSms('sms-1234567890abcdef123456');

echo $status['status'];
echo $status['lastChannel'];
```

**Response:**

```
[
    'smsId' => 'sms-1234567890abcdef123456',
    'phoneNumber' => '964750123456',
    'status' => 'delivered',
    'cost' => 200,
    'isFinalStatus' => true,
    'lastChannel' => 'whatsapp',
    'channelFlow' => [
        [
            'channel' => 'whatsapp',
            'tried' => true,
            'success' => true,
        ],
    ]
]
```

### Get Sender IDs

[](#get-sender-ids)

Retrieve all your available sender IDs:

```
use Rstacode\Otpiq\Facades\Otpiq;

$senderIds = Otpiq::getSenderIds();

foreach ($senderIds['data'] as $sender) {
    echo $sender['senderId'];
    echo $sender['status'];
    echo $sender['pricePerSms']['korekTelecom'];
}
```

**Response:**

```
[
    'success' => true,
    'data' => [
        [
            '_id' => '507f1f77bcf86cd799439011',
            'senderId' => 'OTPIQ',
            'status' => 'accepted',
            'pricePerSms' => [
                'korekTelecom' => 80,
                'asiaCell' => 80,
                'zainIraq' => 80,
                'others' => 100,
            ]
        ]
    ]
]
```

Provider Options
----------------

[](#provider-options)

The `provider` parameter allows you to choose how your message is delivered:

- `auto` - Automatic channel selection (default)
- `whatsapp-sms` - Try WhatsApp first, fallback to SMS
- `telegram-sms` - Try Telegram first, fallback to SMS
- `whatsapp-telegram-sms` - Try WhatsApp, then Telegram, then SMS
- `sms` - SMS only
- `whatsapp` - WhatsApp only
- `telegram` - Telegram only

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

[](#error-handling)

The package provides comprehensive error handling through the `OtpiqApiException` class:

```
use Rstacode\Otpiq\Facades\Otpiq;
use Rstacode\Otpiq\Exceptions\OtpiqApiException;

try {
    $response = Otpiq::sendSms([
        'phoneNumber' => '964750123456',
        'smsType' => 'verification',
        'verificationCode' => '123456',
    ]);
} catch (OtpiqApiException $e) {
    if ($e->isAuthError()) {
        echo 'Invalid API key';
    }

    if ($e->isCreditError()) {
        echo 'Insufficient credit: ' . $e->getRemainingCredit();
        echo 'Required credit: ' . $e->getRequiredCredit();
    }

    if ($e->isRateLimitError()) {
        echo 'Rate limit exceeded. Wait ' . $e->getRateLimitWaitMinutes() . ' minutes';
    }

    if ($e->isTrialModeError()) {
        echo 'Account in trial mode';
    }

    if ($e->isSpendingThresholdError()) {
        echo 'Spending threshold exceeded';
    }

    if ($e->isSenderIdError()) {
        echo 'Sender ID not found';
    }

    if ($e->isValidationError()) {
        echo 'Validation error: ' . $e->getFirstError();
    }

    echo $e->getMessage();
    print_r($e->getResponseData());
}
```

### Available Exception Methods

[](#available-exception-methods)

- `isAuthError()` - Check if error is authentication related
- `isCreditError()` - Check if error is due to insufficient credit
- `isRateLimitError()` - Check if rate limit was exceeded
- `isTrialModeError()` - Check if account is in trial mode
- `isSpendingThresholdError()` - Check if spending threshold was exceeded
- `isSenderIdError()` - Check if sender ID is invalid
- `isValidationError()` - Check if error is validation related
- `getRemainingCredit()` - Get remaining credit balance
- `getRequiredCredit()` - Get required credit for the request
- `getRateLimitWaitMinutes()` - Get wait time in minutes
- `getFirstError()` - Get first validation error message
- `getResponseData()` - Get full API response data

Testing
-------

[](#testing)

You can use the OTPIQ dashboard to test your integration:

1. Visit the [OTPIQ Dashboard](https://app.otpiq.com)
2. Navigate to **Messaging** → **Send SMS**
3. Build and test your API calls interactively

API Reference
-------------

[](#api-reference)

### sendSms(array $data): array

[](#sendsmsarray-data-array)

Send an SMS message.

**Parameters:**

#### Verification Message

[](#verification-message)

```
[
    'phoneNumber' => 'string (required)',
    'smsType' => 'verification',
    'verificationCode' => 'string (required)',
    'senderId' => 'string (optional)',
    'provider' => 'string (optional)',
    'whatsappAccountId' => 'string (optional)',
    'whatsappPhoneId' => 'string (optional)',
    'templateName' => 'string (optional)',
    'deliveryReport' => [
        'webhookUrl' => 'string',
        'deliveryReportType' => 'all|final',
        'webhookSecret' => 'string',
    ],
]
```

#### Custom Message

[](#custom-message)

```
[
    'phoneNumber' => 'string (required)',
    'smsType' => 'custom',
    'customMessage' => 'string (required)',
    'senderId' => 'string (optional)',
    'provider' => 'string (optional)',
    'whatsappAccountId' => 'string (optional)',
    'whatsappPhoneId' => 'string (optional)',
    'templateName' => 'string (optional)',
    'deliveryReport' => [
        'webhookUrl' => 'string',
        'deliveryReportType' => 'all|final',
        'webhookSecret' => 'string',
    ],
]
```

#### WhatsApp Template Message

[](#whatsapp-template-message)

```
[
    'phoneNumber' => 'string (required)',
    'smsType' => 'whatsapp-template',
    'templateName' => 'string (required)',
    'whatsappAccountId' => 'string (required)',
    'whatsappPhoneId' => 'string (required)',
    'templateParameters' => [
        'body' => [
            '1' => 'string',
            '2' => 'string',
        ],
    ],
    'provider' => 'string (optional)',
    'deliveryReport' => [
        'webhookUrl' => 'string',
        'deliveryReportType' => 'all|final',
        'webhookSecret' => 'string',
    ],
]
```

### getProjectInfo(): array

[](#getprojectinfo-array)

Get project information and remaining credits.

**Returns:**

```
[
    'projectName' => 'string',
    'credit' => 'integer'
]
```

### trackSms(string $smsId): array

[](#tracksmsstring-smsid-array)

Track SMS delivery status.

**Parameters:**

- `$smsId` - The SMS ID returned from sendSms()

**Returns:**

```
[
    'smsId' => 'string',
    'phoneNumber' => 'string',
    'status' => 'string',
    'cost' => 'integer',
    'isFinalStatus' => 'boolean',
    'lastChannel' => 'string',
    'channelFlow' => 'array'
]
```

### getSenderIds(): array

[](#getsenderids-array)

Get all available sender IDs.

**Returns:**

```
[
    'success' => 'boolean',
    'data' => [
        [
            '_id' => 'string',
            'senderId' => 'string',
            'status' => 'string',
            'pricePerSms' => [
                'korekTelecom' => 'integer',
                'asiaCell' => 'integer',
                'zainIraq' => 'integer',
                'others' => 'integer',
            ]
        ]
    ]
]
```

Support
-------

[](#support)

- **Email**:
- **Issues**: [GitHub Issues](https://github.com/rstacode/otpiq/issues)

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Credits
-------

[](#credits)

- [Rstacode](https://github.com/rstacode)
- [All Contributors](https://github.com/rstacode/otpiq/contributors)

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance99

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~29 days

Recently: every ~103 days

Total

15

Last Release

5d ago

Major Versions

v1.2 → v2.0.02025-09-04

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cafb10306186274eb27244cf4f1bce80b8d89eb13c0cb8f6493f3ecb84100df?d=identicon)[codenashwan](/maintainers/codenashwan)

---

Top Contributors

[![codenashwan](https://avatars.githubusercontent.com/u/35005761?v=4)](https://github.com/codenashwan "codenashwan (22 commits)")

---

Tags

laravelotpsmstelegramwhatsappverificationiraqkurdistan

### Embed Badge

![Health badge](/badges/rstacode-otpiq/health.svg)

```
[![Health](https://phpackages.com/badges/rstacode-otpiq/health.svg)](https://phpackages.com/packages/rstacode-otpiq)
```

###  Alternatives

[rinvex/laravel-authy

Rinvex Authy is a simple wrapper for Authy TOTP, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

3276.6k1](/packages/rinvex-laravel-authy)

PHPackages © 2026

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