PHP code example of tabi / sdk

1. Go to this page and download the library: Download tabi/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tabi / sdk example snippets




use Tabi\SDK\TabiClient;

$tabi = new TabiClient(
    'tk_your_api_key',
    'https://api.tabi.africa/api/v1'
);

$result = $tabi->messages()->send('your-channel-id', [
    'to' => '2348012345678',
    'content' => 'Hello from the Tabi PHP SDK!',
]);

$tabi = new TabiClient(
    'tk_...',   // tional — defaults to production API base
);



$tabi->channels()->sendOtp('channel-uuid', ['phone' => '+2347000000000']);
$tabi->channels()->verifyOtp('channel-uuid', [
    'phone' => '+2347000000000',
    'code' => '123456',
]);

$session = $tabi->auth()->login('[email protected]', 'password');

$tabi->auth()->register([
    'email' => '[email protected]',
    'password' => 'securePassword',
    'firstName' => 'John',
    'lastName' => 'Doe',
    'workspaceName' => 'My Company',
]);

$tabi->auth()->refresh('your-refresh-token');

$me = $tabi->auth()->me();

$tabi->auth()->logout();

// Workspace invite link token (public preview)
$tabi->auth()->invitePreview('invite-token-from-link');

$tabi->channels()->list();

$tabi->channels()->get('channel-id');

$tabi->channels()->create([
    'name' => 'Support Line',
    'provider' => 'messaging',
]);

$tabi->channels()->connect('channel-id');
$tabi->channels()->connect('channel-id', ['some' => 'payload']); // optional body

$tabi->channels()->status('channel-id');

$tabi->channels()->disconnect('channel-id');

$tabi->channels()->delete('channel-id');

// Requires user JWT — not a channel API key
$tabi->channels()->update('channel-id', ['riskEngineEnabled' => false]);

$tabi->channels()->reconnect('channel-id');

// Hosted OTP — same API key / scopes as messages()->send() — see "OTP over WhatsApp" above
$tabi->channels()->sendOtp('channel-id', ['phone' => '+2347000000000']);
$tabi->channels()->verifyOtp('channel-id', ['phone' => '+2347000000000', 'code' => '123456']);

$tabi->messages()->send('channel-id', [
    'to' => '2348012345678',
    'content' => 'Hello! How can we help you today?',
]);

$tabi->messages()->send('channel-id', [
    'to' => '2348012345678',
    'content' => 'Check this out!',
    'messageType' => 'image',
    'mediaUrl' => 'https://example.com/image.png',
]);

$tabi->messages()->send('channel-id', [
    'to' => '2348012345678',
    'content' => 'Here is your invoice',
    'messageType' => 'document',
    'mediaUrl' => 'https://example.com/invoice.pdf',
]);

$tabi->messages()->get('message-id');

$tabi->messages()->listByConversation('conversation-id', [
    'page' => 1,
    'limit' => 50,
]);

$tabi->messages()->reply('conversation-id', [
    'content' => 'Thanks for reaching out!',
]);

$tabi->messages()->sendPoll('channel-id', [
    'to' => '2348012345678',
    'question' => 'What do you prefer?',
    'options' => ['Option A', 'Option B', 'Option C'],
    'maxAnswer' => 1,
]);

$tabi->messages()->sendLocation('channel-id', [
    'to' => '2348012345678',
    'latitude' => 6.5244,
    'longitude' => 3.3792,
]);

$tabi->messages()->sendContact('channel-id', [
    'to' => '2348012345678',
    'contactName' => 'Jane Doe',
    'contactPhone' => '2348099999999',
]);

$tabi->messages()->sendSticker('channel-id', [
    'to' => '2348012345678',
    // sticker payload per API
]);

$tabi->messages()->react('channel-id', 'provider-msg-id', [
    'emoji' => '👍',
]);

$tabi->messages()->markRead('channel-id', 'provider-msg-id');

$tabi->messages()->edit('channel-id', 'provider-msg-id', [
    'content' => 'Updated message text',
]);

$tabi->messages()->revoke('channel-id', 'provider-msg-id');

$tabi->messages()->downloadMedia('channel-id', 'provider-msg-id');

$tabi->contacts()->list(['page' => 1, 'limit' => 20, 'search' => 'John']);

$tabi->contacts()->get('contact-id');

$tabi->contacts()->create([
    'phone' => '2348012345678',
    'name' => 'John Doe',
    'email' => '[email protected]',
]);

$tabi->contacts()->update('contact-id', ['name' => 'Johnathan Doe']);

$tabi->contacts()->delete('contact-id');

$tabi->contacts()->import([
    'contacts' => [
        ['phone' => '2348012345678', 'name' => 'Alice'],
        ['phone' => '2348087654321', 'name' => 'Bob'],
    ],
]);

$tabi->contacts()->getTags('contact-id');
$tabi->contacts()->addTag('contact-id', 'vip');
$tabi->contacts()->removeTag('contact-id', 'vip');

$tabi->contacts()->optIn('contact-id');
$tabi->contacts()->optOut('contact-id');

$tabi->conversations()->list(['page' => 1, 'limit' => 25, 'status' => 'open']);

$tabi->conversations()->get('conversation-id');

$tabi->conversations()->update('conversation-id', [
    'assignedTo' => 'member-id',
]);

$tabi->conversations()->resolve('conversation-id');
$tabi->conversations()->reopen('conversation-id');
$tabi->conversations()->markRead('conversation-id');

$tabi->webhooks()->create([
    'url' => 'https://example.com/webhook',
    'events' => ['message.received', 'message.sent', 'conversation.created'],
]);

$tabi->webhooks()->list();
$tabi->webhooks()->get('webhook-id');

$tabi->webhooks()->update('webhook-id', [
    'url' => 'https://example.com/new-webhook',
    'events' => ['message.received'],
]);

$tabi->webhooks()->ping('webhook-id');
$tabi->webhooks()->rotateSecret('webhook-id');

$tabi->webhooks()->deliveryLogs(['channelId' => 'channel-uuid', 'limit' => 50]);

$tabi->webhooks()->startTestCapture(['channelId' => 'channel-uuid']);
$tabi->webhooks()->testCaptureStatus(['channelId' => 'channel-uuid']);
$tabi->webhooks()->stopTestCapture(['channelId' => 'channel-uuid']);

$tabi->webhooks()->delete('webhook-id');

$key = $tabi->apiKeys()->create([
    'name' => 'Production Key',
    'scopes' => ['messages:send', 'channels:read'],
]);
// $key['rawKey'] — save immediately; only returned once

$tabi->apiKeys()->list();
$tabi->apiKeys()->list(['channelId' => 'uuid-of-channel']);

$tabi->apiKeys()->revoke('key-id');
$tabi->apiKeys()->delete('key-id');

$tabi->files()->list();
$tabi->files()->get('file-id');
$tabi->files()->getUrl('file-id');
$tabi->files()->delete('file-id');

$tabi->campaigns()->create([
    'name' => 'Promo Blast',
    'channelId' => 'channel-id',
    'content' => 'Flash sale — 50% off today!',
    'audienceFilter' => ['tags' => ['subscribers']],
]);

$tabi->campaigns()->list(['page' => 1, 'limit' => 10]);
$tabi->campaigns()->get('campaign-id');

$tabi->campaigns()->update('campaign-id', ['name' => 'Updated Promo']);

$tabi->campaigns()->schedule('campaign-id');
$tabi->campaigns()->pause('campaign-id');
$tabi->campaigns()->resume('campaign-id');
$tabi->campaigns()->cancel('campaign-id');

$tabi->campaigns()->delete('campaign-id');

$tabi->automationTemplates()->list();
$tabi->automationTemplates()->get('template-id');

$tabi->automationInstalls()->install([
    'templateId' => 'template-uuid',
    'config' => ['greeting' => 'Welcome!'],
]);

$tabi->automationInstalls()->list();
$tabi->automationInstalls()->get('install-id');

$tabi->automationInstalls()->update('install-id', [
    'config' => ['greeting' => 'Hi there!'],
]);

$tabi->automationInstalls()->enable('install-id');
$tabi->automationInstalls()->disable('install-id');
$tabi->automationInstalls()->uninstall('install-id');

$tabi->quickReplies()->list();

$tabi->quickReplies()->create([
    'title' => 'Greeting',
    'shortcut' => '/hello',
    'content' => 'Hello! How can I help you today?',
]);

$tabi->quickReplies()->update('reply-id', ['content' => 'Updated greeting']);
$tabi->quickReplies()->delete('reply-id');

$tabi->analytics()->dashboard(['from' => '2025-01-01', 'to' => '2025-01-31']);
$tabi->analytics()->channels(['from' => '2025-01-01', 'to' => '2025-01-31']);
$tabi->analytics()->conversations(['from' => '2025-01-01', 'to' => '2025-01-31']);

$tabi->notifications()->list(['page' => 1, 'limit' => 20]);
$tabi->notifications()->markRead('notification-id');
$tabi->notifications()->markAllRead();
$tabi->notifications()->unreadCount();

$tabi->integrations()->listProviders();

$tabi->integrations()->create([
    'provider' => 'hubspot',
    'credentials' => ['apiKey' => 'hs_...'],
    'config' => [],
]);

$tabi->integrations()->list();
$tabi->integrations()->get('integration-id');
$tabi->integrations()->test('integration-id');
$tabi->integrations()->update('integration-id', [
    'config' => ['apiKey' => 'hs_new_key'],
]);
$tabi->integrations()->delete('integration-id');

$tabi->workspaces()->list();
$tabi->workspaces()->get('workspace-id');
$tabi->workspaces()->create(['name' => 'New Team']);
$tabi->workspaces()->update('workspace-id', ['name' => 'Renamed Team']);

$tabi->workspaces()->listMembers('workspace-id');

$tabi->workspaces()->inviteMember('workspace-id', [
    'email' => '[email protected]',
    'roleSlug' => 'admin',
]);

use Tabi\SDK\TabiClient;
use Tabi\SDK\TabiException;

$tabi = new TabiClient('tk_...');

try {
    $tabi->messages()->send('channel-id', ['to' => '234...', 'content' => 'Hi']);
} catch (TabiException $e) {
    echo $e->getMessage();   // API message
    echo $e->statusCode;     // e.g. 400, 401, 403, 404
    var_dump($e->body);     // full JSON error payload, if any
}