PHP SDK

Install seed-messages/sdk and send SMS, OTP, and email with one client.

SMS · OTP · Email · package seed-messages/sdk

Install

1composer require seed-messages/sdk

Client

Base URL defaults to https://api-messages.seed.tg/v1. Pass sandbox URL for tests.

1<?php
2require 'vendor/autoload.php';
3
4use SeedMessages\SeedMessages;
5
6// Production
7$client = new SeedMessages('lks_live_xxx');
8
9// Sandbox (optional)
10// $client = new SeedMessages('lks_test_xxx', [
11//     'base_url' => 'https://sandbox-api.seed.tg/v1',
12// ]);

Recommended API key scopes

sms:sendSMS
otp:sendOTP send
otp:verifyOTP verify
email:sendTransactional email
whatsapp:sendWhatsApp messages (optional)

SMS

Approved Sender ID + E.164 recipient. Maps to POST /v1/messages.

1$sms = $client->sms->send([
2    'to' => '+22890000000',
3    'sender' => 'SEED',
4    'text' => 'Hello from SEED Messages',
5]);
6echo $sms['id'], ' ', $sms['status'];

OTP

Primary flow: POST /v1/otp/send → user enters code → POST /v1/otp/verify. Default delivery_mode=auto tries WhatsApp then SMS.

Send (SEED generates the code)

1// SEED generates a 6-digit code, tries WhatsApp then SMS
2$otp = $client->otp->send([
3    'to' => '+22890000000',
4    'reference' => 'login-1',
5    'delivery_mode' => 'auto', // auto | whatsapp | sms
6    'request_messaging_consent' => false,
7]);
8echo $otp['challenge_id'], ' ', $otp['channel'], ' ', $otp['expires_at'];
9// Store challenge_id server-side until the user submits the code

Send (you supply the code)

1// You own the code (must be 4-8 digits)
2$otp = $client->otp->send([
3    'to' => '+22890000000',
4    'code' => '482917',
5    'reference' => 'checkout-42',
6    'delivery_mode' => 'auto',
7    'request_messaging_consent' => false,
8]);

Verify

1$result = $client->otp->verify([
2    'challenge_id' => $otp['challenge_id'],
3    'code' => '482917',
4]);
5var_export($result['verified']); // true
6echo $result['status'];          // verified

Poll challenge status

1$status = $client->otp->get($otp['challenge_id']);
2echo $status['status'], ' ', $status['attempts'], ' ', $status['channel'];

WhatsApp only (no SMS fallback)

Requires a client-supplied code. Prefer otp.send with delivery_mode=auto for production.

1// No SMS fallback - code is required
2$wa = $client->whatsapp->otp->send([
3    'to' => '+22890000000',
4    'code' => '482917',
5    'reference' => 'login-wa-only',
6]);
7echo $wa['challenge_id'], ' ', $wa['wamid'] ?? '';

Email

Send from a verified domain (or SEED shared domains). Maps to POST /v1/emails. At least text or html is required.

Send plain text

1$email = $client->email->send([
2    'to' => ['[email protected]'],
3    'from_email' => '[email protected]',
4    'subject' => 'Welcome to SEED',
5    'text' => 'Thanks for joining us.',
6    'reference' => 'welcome-1',
7]);
8echo $email['id'], ' ', $email['status'];

Send with HTML

1$email = $client->email->send([
2    'to' => ['[email protected]'],
3    'from_email' => '[email protected]',
4    'subject' => 'Your receipt',
5    'text' => 'Thanks for your order.',
6    'html' => '<p>Thanks for your <strong>order</strong>.</p>',
7    'cc' => ['[email protected]'],
8]);

Bulk send

1$bulk = $client->email->sendBulk([
2    'messages' => [
3        [
4            'to' => ['[email protected]'],
5            'from_email' => '[email protected]',
6            'subject' => 'Hello A',
7            'text' => 'Message A',
8        ],
9        [
10            'to' => ['[email protected]'],
11            'from_email' => '[email protected]',
12            'subject' => 'Hello B',
13            'text' => 'Message B',
14        ],
15    ],
16]);
17foreach ($bulk['results'] as $item) {
18    echo $item['id'], ' ', $item['status'], PHP_EOL;
19}