WhatsApp OTP authentication templates carry a one-time code for a verification step such as signing in. A working integration needs more than a send request: configure the sender and template, connect your backend, validate the submitted code and handle expiry, retries and delivery failures.

This guide covers the integration sequence and tests. Use the current API contract supplied for your WASEL workspace for endpoint URLs, credentials and request fields.

What does an authentication template do?

Meta provides authentication messages for OTP verification. The account configuration determines the available template and button options; confirm the template’s language and status before sending. See WhatsApp authentication messages for the category overview.

A delivered message is not a completed verification. Your application should grant access only after the verification operation succeeds for the correct user action.

Before you write code

  • Configure the organisation’s WhatsApp connection.
  • Create a server-side external API key with the required scope.
  • Confirm the authentication template and language used by your account.
  • Obtain the current send, verify and status API contract.
  • Decide how long codes remain valid and how many attempts are allowed.
  • Define the reference that connects a verification to a login or other action.
  • Provide a recovery path for users who cannot receive the message.

The WASEL Templates and OTP reference describes supported operations and policy parameters. The public website’s OpenAPI document describes lead-capture forms; it is not the product’s OTP API contract.

Send a test request from your server

The following shell example deliberately uses your configured API URL, authentication header and documented payload file. It is a request pattern, not a claim that an unverified endpoint or SDK exists.

Terminal window
# Set these locally from your workspace's API documentation.
# Keep the key on your backend; never put it in a browser bundle.
: "${WASEL_OTP_SEND_URL:?Set the documented send URL}"
: "${WASEL_AUTH_HEADER:?Set the documented authentication header}"
curl --fail-with-body --request POST "$WASEL_OTP_SEND_URL" \
--header "$WASEL_AUTH_HEADER" \
--header 'Content-Type: application/json' \
--data @otp-send.json

Create otp-send.json from the actual contract for your workspace. Confirm the recipient field, language, reference and policy parameters instead of copying fields from an unrelated API. Do the same for verification and status requests using their documented methods.

Build the complete verification flow

StageYour applicationWhat to verify
RequestCollect the number and start a verification actionInput format, request limits and user intent
SendCall the OTP operation from the backendAccepted request and a usable tracking reference
DeliverObserve the available messaging statusAn accepted send must not be treated as successful delivery
VerifySubmit the code with the matching contextA successful verification result before granting access
RetryRequest a new code within limitsBehaviour of the previous code and rate limits
RecoverOffer the configured support or alternative pathNo authentication bypass on delivery failure

Keep requests associated with the right reference when users have more than one tab or operation open. Do not expose API keys, raw codes or full credentials in client-side error messages.

Test expiry, attempts and resends

The WASEL reference documents ttl_minutes, max_attempts, button_type and reference. Confirm the allowed values for your workspace and test:

  1. A correct code within its validity period.
  2. An incorrect code.
  3. A code submitted after expiry.
  4. Attempts beyond the configured limit.
  5. A resend followed by use of the previous code.
  6. A code submitted for a different reference.
  7. A delivery failure and the user-facing recovery message.

The documented verification outcomes include verified, invalid_code, expired, max_attempts_exceeded and not_found. Handle each explicitly using the actual response schema. A generic “request succeeded” response must not unlock the account.

Budget for the full verification journey

Include retries and platform charges when comparing channels. The Morocco pricing guide explains the cost components. Use the current Meta pricing page and your commercial terms; do not assume a fixed saving over SMS or a guaranteed delivery rate.

Frequently asked questions

Do I need an approved authentication template?

Confirm the authentication template, language and account configuration before sending. Do not assume that a template is approved immediately or that approval guarantees delivery.

Where are the Wasel OTP endpoints documented?

Use the current API contract supplied for your workspace. This guide does not publish a verified endpoint or SDK; its request example uses your configured URL and payload.

What should happen when a code expires?

Reject the expired code and offer a new request within your retry limits. Validate the latest code and its reference according to the configured OTP policy.

Is WhatsApp OTP always cheaper than SMS?

No fixed saving is guaranteed. Compare your actual message rates, retries, platform fees and completed verifications for the same destination markets.

Prepare the first pilot

Start with an internal recipient and the tests above. Review the API setup and the OTP operations reference with your technical team before increasing traffic.