WhatsApp Cloud API Calling.
Your text, spoken to your recipients.
Connect your application to the WebWMS2U Voice API: request calling permission, preview a selected voice, queue recipients and track each call. Built for Malaysian businesses using an eligible Meta Cloud API number.
Growth & Pro include Voice Calls access. Platform credits and applicable Meta fees apply to usage. See WhatsApp Business Calling API features.
Planning your integration? See real-world voice alert examples and when to choose voice, text or media.
Use your voice-enabled Cloud API number
- Use a plan with Meta Cloud API access, such as Growth or Pro.
- Open My Cloud Number, connect an eligible Cloud API number and enable Voice.
- Obtain an active Meta API key bound to that sending number. A personal-device API key cannot send Voice Calls.
- Request each recipient's calling permission, then send your announcement. The worker checks permission again before calling.
number_id. Coexistence and personal-device numbers cannot send Voice Calls in this release.| Purpose | Endpoint |
|---|---|
| Preview, call and status | POST https://www.webwms2u.com/api/send-voice.php |
| Calling-permission requests | POST https://www.webwms2u.com/api/request-call-permission.php |
Authorization: Bearer YOUR_META_API_KEY
Content-Type: application/json
Accept: application/json
Idempotency-Key: YOUR_UNIQUE_REQUEST_KEYX-API-KEY: YOUR_META_API_KEY is also supported. An idempotency key is required for calls and permission requests, not previews or status reads. The Voice API does not require the messaging API's X-API-Version: 1 header. Keep keys on your server, outside public JavaScript, URLs and source control.
1. Preview the voice and exact credit quote
Send a plain text string and select one of the four voices below. Female is the default for existing integrations. Previewing uses zero WebWMS2U credits. The audio must be no longer than 180 seconds; the text limit is 6,000 characters.
export WMS_META_API_KEY='YOUR_META_API_KEY'
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"action":"preview","voice":"female","text":"Temperature alert. Please check the freezer immediately."}'{
"success": true,
"voice": "female",
"voice_label": "English Female Voice",
"audio_id": "YOUR_AUDIO_ID",
"audio_seconds": 4.8,
"estimated_credits_per_recipient": 2,
"credits_charged": 0,
"billing_mode": "charge_on_answer",
"cached": false
}Four separate voice choices
| API value | Voice | Example input |
|---|---|---|
female | English Female Voice (default) | Temperature alert. Please check the freezer. |
male | English Male Voice | Temperature alert. Please check the freezer. |
indonesian | Bahasa Indonesia | Peringatan suhu. Silakan periksa lemari pembeku. |
mandarin | Mandarin | 温度警报。请立即检查冷冻库。 |
The language is selected explicitly, not detected or translated. Mandarin accepts Chinese characters directly using UTF-8 JSON. Bahasa Indonesia uses Indonesian pronunciation, not Malaysian Malay. The Indonesian and Mandarin choices each provide one voice, without a gender selector. Status results and logs retain the selected voice.
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json; charset=utf-8' \
--data '{"action":"preview","voice":"mandarin","text":"温度警报。请立即检查冷冻库。"}'Durations above are illustrative. The result reports the actual generated length and quote. Write temperatures, abbreviations and vehicle codes as you want them spoken. Preview again after changing the text or voice.
Download the generated preview
curl --fail --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php?action=audio&audio_id=YOUR_AUDIO_ID' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
--output preview.wavThe authenticated preview endpoint returns audio while available. Do not place API keys in the query string or expose an authenticated URL as a public audio player. A missing/expired recording does not delete the text stored with the call log.
2. Request permission before calling
A request accepted by Meta is not the recipient's consent. Call only after permission is granted. Existing valid permission is reused; recipients who already allow calls are skipped when requesting permission again.
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"action":"permission_check","recipients":["60122921138","60123456789"]}'The check reads current Meta permission without sending a message. Inspect each recipient's result, even when the overall request succeeds. Your application does not need to perform a manual check before every call; the calling worker rechecks.
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/request-call-permission.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: freezer-permission-20261124-001' \
--data '{"action":"permission_request","mode":"interactive","recipients":["60122921138","60123456789"],"message":"May we call you with freezer monitoring alerts?"}'Outside the window: use an approved call-permission template
Use the exact approved Meta template name and language code, not a numeric WebWMS2U template ID. The template must include a call-permission request component. This release supports numbered body text parameters; it does not support media headers, named variables or additional buttons/components.
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/request-call-permission.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: freezer-permission-template-20261124-001' \
--data '{"action":"permission_request","mode":"template","recipients":["60122921138"],"template":{"name":"YOUR_APPROVED_CALL_PERMISSION_TEMPLATE","language":"en_US","parameters":[]}}'If the template body has variables, supply their text values in order, for example "parameters":["Freezer Monitoring"] for one body variable. List usable templates with {"action":"permission_templates"} sent to /api/send-voice.php; each result includes its name, language, body, parameter count and usability reason. The scan can be truncated for large template libraries.
mode:"auto" tries a direct request and can fall back to the supplied template for a synchronous 131047 response. A later delivery failure does not trigger that fallback automatically.Track the request separately from consent
Save the returned permission batch_id. Poll {"action":"permission_batch_status","batch_id":"YOUR_PERMISSION_BATCH_ID"} at /api/send-voice.php. A sent request means Meta accepted it. Check recipient permission before considering them callable.
Use {"action":"permission_list","page":1} for your paginated permission directory, including permission_status, can_call, expiry and delivery details. It defaults to 25 rows per page. Permission requests/checks cost zero WebWMS2U credits; applicable Meta template/message fees are separate.
3. Queue one or multiple voice calls
Use international numbers with country code, for example 60122921138. Numbers are normalized and duplicates removed. Send recipients as an array, or to for one recipient. The same generated audio is reused across the batch.
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: freezer-alert-20261124-001' \
--data '{"action":"call","voice":"female","text":"Temperature alert. Please check the freezer immediately.","recipients":["60122921138","60123456789"],"max_credits_per_recipient":2}'Set max_credits_per_recipient to the quote you approved in the preview. If the generated announcement would cost more, the request is rejected instead of silently increasing the price. Send the same text and voice as the preview; audio_id is not a replacement for the text field in the call request.
A successful response includes batch_id, total_recipients, state_counts, audio_seconds, estimated_credits_per_recipient, reserved_credits and calls. Save the batch ID. HTTP 202 means queued, not answered. Responses show the first 50 call records; use the aggregate counts for larger batches and the dashboard's full outbound log for individual history.
Select existing contacts or phonebook groups
Alongside manual numbers, you can supply your accessible contact_ids and group_ids. Only owned/authorized contacts are resolved. Up to 50 contact/group IDs can be submitted per selection; the resolved batch limit is 10,000 unique recipients, subject to available queue capacity and credits.
{
"action": "call",
"group_ids": [12],
"contact_ids": [45, 46],
"text": "Operations alert. Please contact the duty supervisor.",
"voice": "male",
"max_credits_per_recipient": 2
}Replace these sample IDs with your own. Check the male-voice preview quote before setting the credit ceiling. A large group that exceeds limits is rejected rather than silently truncated.
4. Poll status and handle each result
curl --fail-with-body --silent --show-error \
'https://www.webwms2u.com/api/send-voice.php' \
-H "Authorization: Bearer $WMS_META_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"action":"status","batch_id":"YOUR_VOICE_BATCH_ID"}'Poll every 5–10 seconds while the batch is active, then stop after its final call/billing outcomes. Read state_counts for the whole batch and each returned call's state, accepted_at, error, played_seconds, billing_status and credits_charged. Call state and billing status are separate; a call can finish while reconciliation is still pending.
| Result to inspect | How to treat it |
|---|---|
| Queued / active call | Keep polling; a reservation is not a final charge. |
Answered / accepted_at present | The full quoted charge applies, including an immediate hang-up. |
| Confirmed rejected, unanswered or failed before answer | Zero final WebWMS2U call credits; reservation is released. |
| Unknown outcome / pending billing | Do not assume a refund or create another call automatically. Wait for reconciliation. |
{"action":"history"} returns up to 20 recent batches. Operational API history has limited retention; use Outbound Meta Logs and Credit Logs for full logged text, filters, exports and billing. Audio normally expires about 24 hours after its last dependent call finishes.
Credits: charged when the call is answered
Billing uses the full generated announcement length, not ringing time or how much the recipient listened to. It starts at 2 credits for up to 30 seconds, with 1 more credit for each additional started 30 seconds.
| Generated audio | Credits per answered recipient |
|---|---|
| Up to 30 seconds | 2 |
| Over 30–60 seconds | 3 |
| Over 60–90 seconds | 4 |
| Over 90–120 seconds | 5 |
| Over 120–150 seconds | 6 |
| Over 150–180 seconds | 7 |
Credits are reserved before queueing. For seven recipients at a 2-credit quote, 14 credits are reserved. If five answer and two are confirmed unanswered, the final platform charge is 10 credits and 4 credits are refunded. Answered recipients pay the quoted amount even if they hang up immediately.
Previewing, permission checks and permission requests use zero platform credits. Applicable Meta calling and messaging/template fees are separate. See plans and Voice Call rates.
API reference
Common request fields
| Field | Usage |
|---|---|
action | Set explicitly for send-voice.php. Permission endpoint defaults to permission_request. |
text | Plain string for preview/call, up to 6,000 characters and 180 seconds of generated speech. |
voice | female (English Female), male (English Male), indonesian (Bahasa Indonesia) or mandarin (Mandarin). Preview again after changing. |
recipients / to | Array of number strings, or a single number. 8–15 digits including country code; leading + is accepted. |
contact_ids / group_ids | Optional accessible phonebook selections; up to 50 selected IDs. |
max_credits_per_recipient | Optional integer 2–7 protecting the approved call quote. |
Idempotency-Key | Required header for call/permission request: 8–128 characters from letters, digits, dot, underscore, colon or hyphen. Body idempotency_key is also supported. |
batch_id | Batch returned by a call/permission request; use the matching status action. |
Actions at /api/send-voice.php
| Action | Purpose |
|---|---|
preview | Generate speech, duration and quote; no recipients needed. |
call | Reserve credits and queue recipients. |
status | Read one call batch. |
history | Read up to 20 recent call batches. |
permission_check | Check up to 50 recipients against Meta without messaging. |
permission_list | Paginated saved permission directory. |
permission_templates | Find approved, usable calling-permission templates. |
permission_request | Also supported here; the dedicated permission endpoint is clearer for new integrations. |
permission_batch_status | Read a permission-request batch, including aggregate counts and up to 50 recipients. |
Permission mode accepts auto (default), interactive or template. The optional direct-request message is 1–1,024 characters. Permission states include queued, sending, sent, already_allowed, not_sent, failed and unknown. Neither sent nor delivery success proves permission was granted.
Limits: JSON requests up to 1 MiB; up to 10,000 unique recipients per call/permission batch, subject to queue capacity. New preview, permission-check and enqueue actions share a limit of 20 requests per minute per account. Batch size does not bypass Meta recipient permissions or request frequency limits.
Errors, retries and duplicate protection
Read both the HTTP status and JSON body. Errors contain success:false and an error; some also include error_code. An accepted batch can contain individual recipient failures without failing the whole HTTP request.
| HTTP / situation | Next step |
|---|---|
| 400 / 415 / 422 | Check JSON, content type, action, text, voice and recipient format. |
| 401 / 403 | Check active Meta key, account access and authorized voice-enabled Cloud API sender. |
| 409 | Check credits, quote ceiling or reuse of an idempotency key with a different payload. |
| 413 / 429 | Reduce request size or wait for rate/queue capacity. |
| 503 | Service/model/billing dependency unavailable. Inspect the error before retrying. |
| Recipient Not Allowed. Permission Not Granted | Request permission and wait for approval. Other batch recipients continue. |
| Permission delivery code 131047 | The messaging window is closed. Use an approved call-permission template; this is not a decline. |
Retry the same operation with the same key
If your connection times out, resend the exact same payload and idempotency key. The existing batch is returned instead of creating duplicate calls or credit reservations. Do not change the voice, recipient order or text under the same key. Use a new key only for a genuinely new request.
After an explicit insufficient-credit failure, top up and submit a new intended batch with a new key. An unknown permission-delivery result should be checked, rather than automatically resent: Meta may already have accepted the request.
PHP: send from your server
This queues calls using an active Meta API key from your environment. First preview the exact text/voice, obtain permission and set the approved quote. Save batch_id and poll status; this code does not imply delivery or playback success.
<?php
$apiKey = getenv('WMS_META_API_KEY');
if (!$apiKey) {
throw new RuntimeException('Missing WMS_META_API_KEY');
}
// Store this alongside the operation; reuse it after a timeout.
$requestKey = 'freezer-alert-20261124-001';
$payload = [
'action' => 'call',
'text' => 'Temperature alert. Please check the freezer immediately.',
'voice' => 'female',
'recipients' => ['60122921138', '60123456789'],
'max_credits_per_recipient' => 2, // From a successful preview.
];
$ch = curl_init('https://www.webwms2u.com/api/send-voice.php');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($payload, JSON_THROW_ON_ERROR),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'Accept: application/json',
'Idempotency-Key: ' . $requestKey,
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 90,
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$error = curl_error($ch);
curl_close($ch);
if ($body === false) {
throw new RuntimeException('Request uncertain: ' . $error
. '. Retry the identical payload with the same request key.');
}
$result = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
if ($status >= 400 || empty($result['success'])) {
throw new RuntimeException($result['error'] ?? 'Voice request failed');
}
echo 'Track batch: ' . $result['batch_id'];