Developer guide · Automated outbound calls

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.

English female/male · Indonesian · MandarinUp to 3 minutesMultiple recipients

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.

Start here

Use your voice-enabled Cloud API number

  1. Use a plan with Meta Cloud API access, such as Growth or Pro.
  2. Open My Cloud Number, connect an eligible Cloud API number and enable Voice.
  3. Obtain an active Meta API key bound to that sending number. A personal-device API key cannot send Voice Calls.
  4. Request each recipient's calling permission, then send your announcement. The worker checks permission again before calling.
Sender selection is automatic. The Meta API key identifies your sending number. Do not pass a sender number or number_id. Coexistence and personal-device numbers cannot send Voice Calls in this release.
PurposeEndpoint
Preview, call and statusPOST https://www.webwms2u.com/api/send-voice.php
Calling-permission requestsPOST https://www.webwms2u.com/api/request-call-permission.php
Request headers
Authorization: Bearer YOUR_META_API_KEY
Content-Type: application/json
Accept: application/json
Idempotency-Key: YOUR_UNIQUE_REQUEST_KEY

X-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.

cURL · Preview
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."}'
Example · Preview result
{
  "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 valueVoiceExample input
femaleEnglish Female Voice (default)Temperature alert. Please check the freezer.
maleEnglish Male VoiceTemperature alert. Please check the freezer.
indonesianBahasa IndonesiaPeringatan suhu. Silakan periksa lemari pembeku.
mandarinMandarin温度警报。请立即检查冷冻库。

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 · Mandarin preview
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 · Download WAV
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.wav

The 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 · Check current permission (up to 50 recipients)
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 · Request within the open 24-hour messaging window
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 · Approved template request
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.

Error 131047 means the messaging window is closed. It does not mean the recipient declined. Use an approved call-permission template or ask the recipient to message your business number. 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 · Queue two recipients
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.

One missing permission does not fail everyone. The affected recipient is recorded as failed: “Recipient Not Allowed. Permission Not Granted”. Other calls continue. Calls use the available worker concurrency; a batch does not guarantee simultaneous ringing.
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.

JSON · Call an existing group
{
  "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 · Read call batch status
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 inspectHow to treat it
Queued / active callKeep polling; a reservation is not a final charge.
Answered / accepted_at presentThe full quoted charge applies, including an immediate hang-up.
Confirmed rejected, unanswered or failed before answerZero final WebWMS2U call credits; reservation is released.
Unknown outcome / pending billingDo 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.

Use the Voice API's batch status for voice results. The normal text/media Message Status endpoints and Status Webhooks guide are not voice-result callbacks. You do not need to configure your own Meta calling webhook to use this API.

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 audioCredits per answered recipient
Up to 30 seconds2
Over 30–60 seconds3
Over 60–90 seconds4
Over 90–120 seconds5
Over 120–150 seconds6
Over 150–180 seconds7

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

FieldUsage
actionSet explicitly for send-voice.php. Permission endpoint defaults to permission_request.
textPlain string for preview/call, up to 6,000 characters and 180 seconds of generated speech.
voicefemale (English Female), male (English Male), indonesian (Bahasa Indonesia) or mandarin (Mandarin). Preview again after changing.
recipients / toArray of number strings, or a single number. 8–15 digits including country code; leading + is accepted.
contact_ids / group_idsOptional accessible phonebook selections; up to 50 selected IDs.
max_credits_per_recipientOptional integer 2–7 protecting the approved call quote.
Idempotency-KeyRequired header for call/permission request: 8–128 characters from letters, digits, dot, underscore, colon or hyphen. Body idempotency_key is also supported.
batch_idBatch returned by a call/permission request; use the matching status action.

Actions at /api/send-voice.php

ActionPurpose
previewGenerate speech, duration and quote; no recipients needed.
callReserve credits and queue recipients.
statusRead one call batch.
historyRead up to 20 recent call batches.
permission_checkCheck up to 50 recipients against Meta without messaging.
permission_listPaginated saved permission directory.
permission_templatesFind approved, usable calling-permission templates.
permission_requestAlso supported here; the dedicated permission endpoint is clearer for new integrations.
permission_batch_statusRead 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 / situationNext step
400 / 415 / 422Check JSON, content type, action, text, voice and recipient format.
401 / 403Check active Meta key, account access and authorized voice-enabled Cloud API sender.
409Check credits, quote ceiling or reuse of an idempotency key with a different payload.
413 / 429Reduce request size or wait for rate/queue capacity.
503Service/model/billing dependency unavailable. Inspect the error before retrying.
Recipient Not Allowed. Permission Not GrantedRequest permission and wait for approval. Other batch recipients continue.
Permission delivery code 131047The 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 · Queue a voice announcement
<?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'];