PHPackages                             okolaa/termiiphp - 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. okolaa/termiiphp

ActiveLibrary[API Development](/categories/api)

okolaa/termiiphp
================

Termii Rest API php library

v2.0.0(1y ago)112.4k—5.6%5[2 PRs](https://github.com/Douglasokolaa/termii-php/pulls)MITPHPPHP ^8.2CI passing

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Douglasokolaa/termii-php)[ Packagist](https://packagist.org/packages/okolaa/termiiphp)[ GitHub Sponsors](https://github.com/Douglasokolaa)[ RSS](/packages/okolaa-termiiphp/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (7)Versions (5)Used By (0)

Termii PHP SDK
==============

[](#termii-php-sdk)

 [![Github top language](https://camo.githubusercontent.com/b33bf67234fadd670264df124abb0a4bffbba895b449b0342172893430b4a0cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238)](https://camo.githubusercontent.com/b33bf67234fadd670264df124abb0a4bffbba895b449b0342172893430b4a0cf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f746f702f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238) [![License](https://camo.githubusercontent.com/e52b95ebf957f3a9cd6c949a82d3323c4aa21b7ac75646e07939af5a9919eec0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238)](https://camo.githubusercontent.com/e52b95ebf957f3a9cd6c949a82d3323c4aa21b7ac75646e07939af5a9919eec0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238) [![Github issues](https://camo.githubusercontent.com/40f28f13e9e61589a1bd1f69009dc8e5c1ee26dc52eee49d799b1984d613d05b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238)](https://camo.githubusercontent.com/40f28f13e9e61589a1bd1f69009dc8e5c1ee26dc52eee49d799b1984d613d05b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238) [![Github forks](https://camo.githubusercontent.com/466ae63ed2dee62238fd96f129fdea33beb11b0b8920caecb494d4f9bc2ed27e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238)](https://camo.githubusercontent.com/466ae63ed2dee62238fd96f129fdea33beb11b0b8920caecb494d4f9bc2ed27e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f446f75676c61736f6b6f6c61612f7465726d69697068703f636f6c6f723d353642454238)

---

 [About](#dart-about) | [Requirements](#white_check_mark-requirements) | [Usage](#checkered_flag-usage) | [Contribution](#hammer-contribution) | [License](#memo-license) | [Author](https://github.com/Douglasokolaa)

🎯 About
-------

[](#dart-about)

Termii PHP SDK is a robust library designed to facilitate seamless integration with the [Termii API](http://developer.termii.com/docs/). It enables developers to efficiently send SMS messages, manage sender IDs, handle campaigns, and verify tokens within PHP applications.

✅ Requirements
--------------

[](#white_check_mark-requirements)

1. To use Termii's APIs, you need to first create an account for free at [termii.com](https://termii.com/).
2. BASE URL: Your Termii account has its own base URL, which you should use in all API requests. Your base URL can be found on your dashboard.
3. Ensure that PHP 8.1 [PHP 8.1+](https://php.net/) or higher is installed on your system.

🔨 Installation
--------------

[](#hammer-installation)

```
# Installation
composer require okolaa/termiiphp
```

🏁 Usage
-------

[](#checkered_flag-usage)

### TLDR;

[](#tldr)

> - Your API Token can be found in your Termii account settings

```

    use Okolaa\TermiiPHP\Endpoints\Messaging\GetSenderIdsEndpoint;
    use Okolaa\TermiiPHP\Termii;

    // Initialize the SDK
    $termii = Termii::initialize('api-token', 'https://termi-base-url');

    // make a request
    $response = $termii->senderIdApi()->getIds(page: 1);

    // get result as array
    $response->json();

    // Alternatively, convert result to DTO
    $request = new GetSenderIdsEndpoint();
    $senderIds = $request->createDtoFromResponse($response);
    // you can now interact with data e.g.
    $senderIds->currentPage; // int
    $senderIds->currentPage; // int
    $senderIds->lastPage; // int
    $senderIds->total; //int
    $senderIds->data; //array
```

### Switch API

[](#switch-api)

Termii’s Messaging allows you to send messages to any country in the world across SMS and WhatsApp channel through a REST API. Every request made is identified by a unique ID that help our users track the status of their message either by receiving Delivery Reports (DLRs) over their set webhook endpoints or polling the status of the message using a specific endpoint.

#### Messaging

[](#messaging)

### Send Message

[](#send-message)

```
use Okolaa\TermiiPHP\Data\Message;
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');
$message = new Message(
    to: "23490555546",
    from: "talert",
    sms: "Hi There, Testing Termii",
    type: "plain",
    channel:\Okolaa\TermiiPHP\Enums\MessageChannel::DND,
    media: null,
    time_to_live: 0
);
$response = $termii->messagingApi()->send($message);
```

### Send Bulk Message

[](#send-bulk-message)

```
$bulkMessage = new Message(
    to: ["2347012345678", "2349067890123"],
    from: "bulkAlert",
    sms: "Bulk message content, Testing Termii",
    type: "plain",
    channel: \Okolaa\TermiiPHP\Enums\MessageChannel::DND,
    media: null,
    time_to_live: 1 // Example TTL in minutes
);
$response = $termii->messagingApi()->sendBulk($bulkMessage);
```

### Send Device Template

[](#send-device-template)

```
$deviceTemplate = new \Okolaa\TermiiPHP\Data\DeviceTemplate(
    template_id: "sampleTemplate1234",
    phone_number: "2348076543210",
    device_key: "ABCD1234DEVICEKEY"
);
$response = $termii->messagingApi()->sendDeviceTemplate($deviceTemplate);
```

### Sender ID

[](#sender-id)

```
$response = $termii->senderIdApi()->getIds($pageNumber);
$senderId = new \Okolaa\TermiiPHP\Data\SenderId(...);
$senderId = new \Okolaa\TermiiPHP\Data\SenderId(
    name: "TestSender",
    company: "TestCompany Ltd",
    purpose: "Testing purposes for SDK"
);
```

### Campaigns

[](#campaigns)

```
$campaign = new \Okolaa\TermiiPHP\Data\Campaign(
    name: "Test Campaign",
    message: "This is a test campaign message",
    sender_id: "TestSenderId",
    recipients: ["2347012345678", "2349067890123"],
    channel: "sms",
    time_to_send: "2023-12-01 10:00:00"
);
$response = $termii->campaignApi()->send($campaign);
$response = $termii->campaignApi()->get($campaingId, $pageNumber);
$response = $termii->campaignApi()->getHistory($pageNumber);
```

### Phonebook

[](#phonebook)

```
$phonebook = new \Okolaa\TermiiPHP\Data\Phonebook(
    name: "Test Phonebook",
    description: "Sample description for test phonebook"
);
$responseCreate = $termii->campaignApi()->phoneBook()->create($phonebook);
$responseUpdate = $termii->campaignApi()->phoneBook()->update($phonebook);
$response = $termii->campaignApi()->phoneBook()->get();
$response = $termii->campaignApi()->phoneBook()->delete($phonebook->id);
```

### Contact

[](#contact)

```
$contact = new \Okolaa\TermiiPHP\Data\Contact(
    phone_number: "2347012345678",
    first_name: "John",
    last_name: "Doe",
    email: "johndoe@example.com",
    phonebook_id: "testPhonebook123"
);
$responseAddContact = $termii->campaignApi()->phoneBook()->addContact($contact);
$importedContactsResponse = $termii->campaignApi()->phoneBook()->importContact($phonebook->id, 234, 'path/to/your/file.csv');

$fetchedContactsResponse = $termii->campaignApi()->phoneBook()->getContacts($phonebook->id, $pageNumber);
$deleteContactResponse = $termii->campaignApi()->phoneBook()->deleteContact($contact->id);
```

Token API
---------

[](#token-api)

The `TokenApi` in the Termii PHP SDK enables businesses to **generate**, **send**, and **verify One-Time Passwords ( OTPs)**. It's a powerful feature tailored for two-factor authentication and secure user verification processes.

### Send Token

[](#send-token)

```
use Okolaa\TermiiPHP\Data\TokenSend;
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$tokenSend = new \Okolaa\TermiiPHP\Data\Token\SendToken(
    to: "23490555546",
    from: "talert",
    messageText: "Your verification code is ",
    pinType: \Okolaa\TermiiPHP\Enums\PinType::AlphaNumeric,
    pinAttempts: 3,
    pinTimeToLiveMinute: 5,
    pinLength: 6,
    pinPlaceHolder: "",
    channel: \Okolaa\TermiiPHP\Enums\MessageChannel::DND
    messageType: 'plain',
);

$response = $termii->tokenApi()->send($tokenSend);
```

### Voice Token

[](#voice-token)

The voice token API enables you to generate and trigger one-time passwords (OTP) through the voice channel to a phone number.

```
use Okolaa\TermiiPHP\Data\Token\VoiceToken;
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$voiceToken = new VoiceToken(
    phoneNumber: "2348000000000",
    pin_length: 6
);

$response = $termii->tokenApi()->voice($voiceToken);
```

### Voice Call Token

[](#voice-call-token)

The voice call API enables you to send messages from your application through our voice channel to a phone number.

```
use Okolaa\TermiiPHP\Data\Token\VoiceToken;
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$response = $termii->tokenApi()->voiceCall('2348000000000', '12345);
```

### Verify Token

[](#verify-token)

Verify token API, checks tokens sent to customers and returns a response confirming the status of the token.

```
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$response = $termii->tokenApi()->verify('pinId', 'the-pin-code');
```

### Email Token

[](#email-token)

The email token API enables you to send one-time-passwords from your application through our email channel to an email address.

```
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$response = $termii->tokenApi()->email('test@test.com', 'the-pin-code', 'email-config-id');
```

### In-App Token

[](#in-app-token)

This API returns OTP codes in JSON format which can be used within any web or mobile app.

```
use Okolaa\TermiiPHP\Termii;

$termii = Termii::initialize('api-token');

$payload = new \Okolaa\TermiiPHP\Data\Token\InAppToken(
            pinType: \Okolaa\TermiiPHP\Enums\PinType::Numeric,
            phoneNumber: '2348000000000'
         );

$response = $termii->tokenApi()->inApp($payload);
```

Advanced Configuration
----------------------

[](#advanced-configuration)

- Customizing Requests

```
use Okolaa\TermiiPHP\Endpoints\Messaging\RequestSenderIdEndpoint;
use Okolaa\TermiiPHP\Termii;

$senderIdData = new \Okolaa\TermiiPHP\Data\SenderId(
    'okolaa',
    'Okolaa INC',
    'To be used for sending alerts to customers.'
);
$request = new RequestSenderIdEndpoint($senderIdData);
$request->query()->merge(['page' => 4]);
$request->headers()->merge(...);
$request->body()->merge(...);
$request->config()->merge(...);

$client = Termii::initialize('api-token');
$response = $client->send($request);
```

- The Response Class

```
use Okolaa\TermiiPHP\Termii;
$termii = Termii::initialize('api-token');
$response = $termii->send($request);

$response->json(); // returns array/scalar value
$response->collect(); // returns Illuminate/Collection or scalar value
$response->object(); // returns php object
$response->dto(); // returns Data objects e.g. PaginationData, SenderId, Message, Phonebook
$response->headers(); // returns all the response headers
$response->stream(); // returns the body as a stream
```

Troubleshooting
---------------

[](#troubleshooting)

The simplest way to debug a request and response is to use the debug() method on your connector before sending a request. This will output an easy-to-understand array of the request and the response.

```
    use Okolaa\TermiiPHP\Termii;
    $termii = Termii::initialize('api-token'));
    // You can provide the die argument if you would like to terminate the application after receiving the response.
    $termii->debug(die: false);
```

You may also use debugRequest and debugResponse independently if you would like to debug just the request or response respectively.

```
   $termii->debugRequest(); // $connector->debugRequest(die: true);
   $termii->debugResponse(); // $connector->debugResponse(die: true);
```

### Common Issues

[](#common-issues)

1. Invalid API Key: Ensure you’ve set a valid API key. You can validate this by logging into the Termii Dashboard.
2. SSL Certificate Issues: If you encounter SSL errors in local environments, ensure your system’s CA certificates are up to date. Alternatively, you can disable the SSL certificate verification as shown below:

    ```
        $termii->config()
            ->merge([
               'verify' => false
            ]);
    ```
3. Timeouts: Increase the timeout values if the Termii API is slow to respond:

    ```
       use Okolaa\TermiiPHP\Termii;
       $termii = Termii::initialize('api-token'));
       $termii->config()->merge(
        [
            'connect_timeout' => 60,
            'timeout' => 120
        ]
       );
    ```

🔨 Contribution
--------------

[](#hammer-contribution)

```
# fork and Clone the fork project
# Access the folder
cd termiiphp

# Install dependencies
composer Install

# Run test
./vendor/bin/pest
```

📝 License
---------

[](#memo-license)

This project is under license from MIT. For more details, see the [LICENSE](LICENSE.md) file.

Made with ❤️ by [Douglas Okolaa](https://github.com/Douglasokolaa)

[Back to top](#top)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance40

Moderate activity, may be stable

Popularity30

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~742 days

Total

3

Last Release

511d ago

Major Versions

v1.0.1 → v2.0.02024-12-16

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/136802939?v=4)[okolaa](/maintainers/okolaa)[@okolaa](https://github.com/okolaa)

---

Top Contributors

[![Douglasokolaa](https://avatars.githubusercontent.com/u/53460169?v=4)](https://github.com/Douglasokolaa "Douglasokolaa (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![drchibs](https://avatars.githubusercontent.com/u/66283877?v=4)](https://github.com/drchibs "drchibs (1 commits)")

---

Tags

phpsmstermiitermii-phptermiiphpwhatsappphpapismssendinblue

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/okolaa-termiiphp/health.svg)

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

###  Alternatives

[unicodeveloper/jusibe-php-lib

Jusibe PHP Library

3417.4k1](/packages/unicodeveloper-jusibe-php-lib)[lakshmaji/plivo

Send SMS using Plivo Cloud API

2016.8k](/packages/lakshmaji-plivo)[lakshmajim/plivo

Send SMS using Plivo Cloud API

205.7k](/packages/lakshmajim-plivo)

PHPackages © 2026

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