PHP QUICKSTART
Send your first WhatsApp message in under 5 minutes. You need a WA Bridges API key - get one from the dashboard.
1. INSTALL
PHP has no required dependencies. The examples use built-in curl functions.
ENV
export WA_API_KEY="sk_..."
2. PROVISION A BRIDGE
One bridge = one WhatsApp number. customer_ref is your internal identifier (user ID, slug, etc.).
PHP
<?php
$apiKey = getenv('WA_API_KEY');
$base = 'https://wabridges.com/api';
function waPost(string $path, array $body) use ($apiKey, $base): array {
$ch = curl_init($base . $path);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($body),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
],
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
return $res;
}
$bridge = waPost('/instances', [
'customer_ref' => 'user-123',
'webhook_url' => 'https://yourbackend.com/hook',
]);
print_r($bridge);
RESPONSE
{"id": 42, "customer_ref": "user-123", "state": "running"}
3. PAIR A PHONE
Request a pairing code. Open WhatsApp on the phone, go to Linked Devices → Link a device → Link with phone number, then enter the code.
PHP
$result = waPost('/instances/user-123/proxy/pair', ['phone' => '15550001234']);
echo "Enter this code on the phone: " . $result['code'];
RESPONSE
{"code": "ABCD-EFGH"}
Once paired, the bridge fires a connected webhook event. Poll /proxy/status or wait for the event.
4. SEND A MESSAGE
PHP
$msg = waPost('/instances/user-123/proxy/send/text', [
'chat' => '15559876543',
'body' => 'Hello from the API!',
]);
echo $msg['message_id'];
RESPONSE
{"message_id": "ACE41E...", "timestamp": 1777180605}
5. RECEIVE EVENTS
Inbound messages and events are delivered via POST to your webhook_url. Return 200 immediately.
PHP
<?php
$payload = json_decode(file_get_contents('php://input'), true);
http_response_code(200);
if (($payload['event'] ?? '') === 'message' && empty($payload['from_me'])) {
error_log("{$payload['name']}: {$payload['body']}");
}
See the webhook guide for all event types and fields.