WhaBuzzdocs
Start

PHP SDK

Install whabuzz/whabuzz with Composer, send your first message in ten lines, verify webhooks.

The whabuzz/whabuzz package for PHP 8.1+. No dependencies: it uses curl, or PHP streams when curl is missing. Request bodies and responses are Meta's own.

composer require whabuzz/whabuzz
export WHABUZZ_API_KEY="wb_live_..."   # your key
bash

#First message

<?php
require 'vendor/autoload.php';

$wb = new WhaBuzz\Client(['apiKey' => getenv('WHABUZZ_API_KEY')]);
$res = $wb->messages->send([
    'from' => '+14692311132', // your connected number
    'to' => getenv('TO'),     // the recipient, E.164
    'type' => 'text',
    'text' => ['body' => 'Hello from WhaBuzz'],
]);
echo $res['messages'][0]['id'], "\n";
php

Outside the 24-hour customer window send a template instead.

#Options and resources

new Client(['apiKey', 'baseUrl', 'tenant', 'timeout', 'transport']). Pass an idempotency key as the last argument of send, batch and create calls; see Idempotency.

tenant(), messages (send, batch, getBatch, listBatchItems, cancelBatch, markRead), templates (list, create, get), numbers (list, get), webhookEndpoints (list, create, get, update, delete, verify, rotateSecret), events (list, get, iterate), media->get. For any other route use $wb->json('GET', '/v1/...').

#Errors

Failures throw WhaBuzz\Exception\WhaBuzzException with status, source (meta, whabuzz, client), errorCode, meta (Meta's error object, verbatim) and requestId. See Errors.

#Verify a webhook

use WhaBuzz\WebhookVerifier;

$raw = file_get_contents('php://input'); // the exact bytes received
$event = WebhookVerifier::verify($raw, getallheaders(), getenv('WHABUZZ_WEBHOOK_SECRET'));
echo $event['type'];
php

Throws WebhookVerificationException (with a reason) when the signature, timestamp (300 s) or header is wrong. Details of the scheme: Webhooks.

This page as Markdown: /sdks/php.md. All docs in one file: /llms-full.txt.