OTP and website
Send notifications
The WhatsApp notification API sends a transactional message (booking confirmed, order shipped, appointment reminder) from your own number with one call. Authentication is your secret API key.
Before you start #
- Connect your WhatsApp number in the dashboard. Messages are sent from it; without a connected number the call answers
409 no_connected_number. - Create a secret key in Dashboard, API keys, and keep it on your server:
WAFORGE_API_KEY=wf_sk_.... Widget keys (wf_pk_) are refused with403 secret_key_required. - Send only messages the person expects from you. Your number's protection limits apply to these sends too (see limits).
Send a notification #
POST /api/v1/messages/send with {"to": "213555123456", "text": "..."}. to is the international number in digits only, without + or spaces (6 to 15 digits). text is 1 to 4096 characters; WhatsApp formatting such as *bold* works.
Add an Idempotency-Key header (for example your booking or order id plus the event) so a retry never sends twice: the same key within 24 hours returns the first answer without sending again.
curl -X POST https://waforge.online/api/v1/messages/send \
-H "Authorization: Bearer $WAFORGE_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Idempotency-Key: booking-1042-confirmed" \
-d '{"to": "213555123456", "text": "Your booking #1042 is confirmed for 14 November."}'<?php
function waforge_notify(string $to, string $text, ?string $idempotencyKey = null): array
{
$ch = curl_init('https://waforge.online/api/v1/messages/send');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => array_filter([
'Authorization: Bearer ' . getenv('WAFORGE_API_KEY'),
'Content-Type: application/json',
'Accept: application/json',
$idempotencyKey ? 'Idempotency-Key: ' . $idempotencyKey : null,
]),
CURLOPT_POSTFIELDS => json_encode(['to' => $to, 'text' => $text]),
]);
$json = json_decode((string) curl_exec($ch), true) ?? [];
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);
return ['status' => $status, 'body' => $json];
}
$r = waforge_notify('213555123456', 'Your booking #1042 is confirmed.', 'booking-1042-confirmed');
if ($r['status'] !== 200) {
error_log('WaForge: ' . ($r['body']['error'] ?? 'unknown'));
}use Illuminate\Support\Facades\Http;
$r = Http::withToken(config('services.waforge.key')) // WAFORGE_API_KEY
->withHeaders(['Idempotency-Key' => "booking-{$booking->id}-confirmed"])
->acceptJson()
->timeout(30)
->post('https://waforge.online/api/v1/messages/send', [
'to' => $booking->phone, // digits only, e.g. 213555123456
'text' => "Your booking #{$booking->id} is confirmed.",
]);
if ($r->failed()) {
report(new \RuntimeException('WaForge: '.$r->json('error'))); // e.g. daily_cap, opted_out
}async function waforgeNotify(to, text, idempotencyKey) {
const res = await fetch('https://waforge.online/api/v1/messages/send', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.WAFORGE_API_KEY}`,
'Content-Type': 'application/json',
Accept: 'application/json',
...(idempotencyKey ? { 'Idempotency-Key': idempotencyKey } : {}),
},
body: JSON.stringify({ to, text }),
});
return { status: res.status, body: await res.json() };
}
const r = await waforgeNotify('213555123456', 'Your booking #1042 is confirmed.', 'booking-1042-confirmed');
if (r.status !== 200) console.error('WaForge:', r.body.error);import os, requests
def waforge_notify(to, text, idempotency_key=None):
headers = {"Authorization": f"Bearer {os.environ['WAFORGE_API_KEY']}", "Accept": "application/json"}
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
r = requests.post("https://waforge.online/api/v1/messages/send",
json={"to": to, "text": text}, headers=headers, timeout=30)
return r.status_code, r.json()
status, body = waforge_notify("213555123456", "Your booking #1042 is confirmed.", "booking-1042-confirmed")HTTP/1.1 200 OK
{ "id": "48213", "status": "sent" }The call waits until WhatsApp has accepted the message, so allow up to about 30 seconds. The message appears in your WaForge inbox, marked API, so your staff see what was sent. If the person replies, the reply lands in the same chat.
Error codes #
Errors are always JSON with an error field and a 4xx status. Nothing is sent when you get an error.
| HTTP | error | Meaning and fix |
|---|---|---|
| 401 | missing_api_key, invalid_api_key | No key, or an unknown or revoked key. |
| 403 | secret_key_required | A widget key (wf_pk_) was used. Use the secret key from your server. |
| 403 | account_suspended | The account is suspended. Contact support. |
| 409 | no_connected_number | No connected WhatsApp number. Scan the QR code in Dashboard, WhatsApp number. |
| 409 | number_paused | Sending is paused on your number to protect it (for example after several failed deliveries). Check the dashboard, then resume. |
| 409 | send_failed | WhatsApp did not accept the message. The number is marked disconnected; reconnect it, then retry. |
| 422 | invalid_number | The number is not on WhatsApp, or to is not 6 to 15 digits. |
| 422 | invalid_text | text missing or longer than 4096 characters. |
| 422 | opted_out | The person wrote STOP (or similar) to your number. They are never messaged again. |
| 429 | rate_limited | Too many sends this minute. Wait for Retry-After seconds. |
| 429 | daily_cap | Your number reached today's safe limit for its warm-up stage. Retry-After points to tomorrow. |
| 429 | quota_exceeded | Free plan: this month's message total is used. Upgrade or wait for next month. |
Limits #
- These sends share your number's daily safe limit and per-minute pace with AI replies and automations, because WhatsApp restricts numbers by total volume, not by type.
- On the Free plan each message counts in the monthly message total. Paid plans have no monthly count.
- The AI's quiet hours do not apply: a notification is sent when your system asks for it.