The PHP Signup Step That Stops Codes Going Missing

You do not need an SDK or a WhatsApp Business Platform build to verify a phone number. This guide walks a working WhatsApp OTP API PHP flow using cURL: send the code, verify what the user submitted, and branch on the errors that matter.

This guide uses Replio’s WhatsApp OTP endpoint because it is a single JSON POST with no SDK to install. The shape of the flow is the same whichever provider you use, so the structure transfers.

WhatsApp OTP API PHP flow from send through verify
The four steps of a WhatsApp OTP API PHP integration.

Before you write any PHP code

Three things need to exist first. A WhatsApp number connected to your provider account. At least one approved Authentication template on the WhatsApp Business Account. An API key.

Keep the key server-side. It sends from your verified business number, so a leaked key means someone else messaging your customers under your brand.

WhatsApp OTP API PHP: sending the code

One POST sends the code. You can pass a code you generated yourself, or omit it and let the provider generate, hash and store one for you.

$ch = curl_init("https://engine-production-2647.up.railway.app/api/otp/send");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . getenv("REPLIO_OTP_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "phone"           => "447911123456",
    "idempotency_key" => "signup-" . $signupId,
  ]),
]);

$body   = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

$data = json_decode($body, true);
if ($status >= 400) { throw new RuntimeException($data["detail"]["code"]); }

A success looks like this:

{
  "ok": true,
  "sent_to": "+447911123456",
  "template": "verify_code",
  "credits_charged": 1,
  "verify_enabled": false
}

Read verify_enabled carefully. It is true only when you omitted the code. That flag tells you whether the verify endpoint has anything to check.

Verifying what the user typed back

If you let the provider generate the code, check what the user typed with a second call.

$ch = curl_init("https://engine-production-2647.up.railway.app/api/otp/verify");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST           => true,
  CURLOPT_HTTPHEADER     => [
    "Authorization: Bearer " . getenv("REPLIO_OTP_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "phone" => "447911123456",
    "code"  => $userInput,
  ]),
]);

$body   = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($body, true);

if ($status < 400 && !empty($data["verified"])) { return completeSignup(); }

switch ($data["detail"]["code"]) {
  case "incorrect_code":    return show("That code is not right.");
  case "code_expired":      return show("That code expired. Send a new one.");
  case "too_many_attempts": return forceResend();
}

A correct code returns { "ok": true, "verified": true }. A wrong or expired one is a normal 400, not a 200 with a false flag. Handle it as an error branch.

Where this fits in your signup flow

Treat the send and the verify as two separate states in your own model, not one blocking call. Send the code, store the signup attempt, and return control to the user. Verify runs later, when they submit the form.

That separation matters when things go wrong. If the verify call fails, you still hold the signup attempt and can offer a resend without losing the user’s progress. If you couple the two, a network blip drops them back to the start.

Rate limits sit on the recipient as well as the account. Five codes to one number per hour, and ten verify attempts per number per ten minutes. Surface a clear message when you hit those rather than a generic failure, because a user who resends four times in a minute will hit them.

One detail trips people up on the first run. The phone number goes in international format as digits. A leading plus sign, spaces and dashes are accepted and stripped, but a local-format number without a country code is rejected as invalid_phone. Normalise before you send.

Only a delivered send costs a credit. Rejected requests, rate limits and test-mode calls are free, so strict validation on your side costs nothing.

Handling the errors that actually happen

Branch on the machine-readable code field, never on the human-readable message. The message wording can change at any time; the codes are the contract.

  • incorrect_code — wrong digits. Let the user retry.
  • code_expired — past its time to live. Offer a resend.
  • too_many_attempts — five wrong guesses burn the code. Force a new one.
  • recipient_rate_limited — five codes to one number in an hour. Back off.
  • upstream_error — WhatsApp was unreachable. Safe to retry.

Two habits that save you money and credits

Pass an idempotency key. Networks time out after a send has already happened, and a blind retry sends a second code and spends a second credit. With a key tied to the signup attempt, a retry returns the original result instead.

Then build against a test key. A test credential validates the whole request and applies every rule, but sends nothing and bills nothing.

Hardening the flow before launch

Set a short time to live. Five minutes is the common default and it limits the window for a stolen code. Cap wrong guesses. Never log the code itself.

If you are weighing this against your current SMS provider, we compared the two channels in WhatsApp OTP vs SMS. The full parameter list and error table live in the Replio WhatsApp OTP API reference, and Meta documents the template rules in its message template guide. For context on running WhatsApp as a support channel too, see our piece on answering WhatsApp and Instagram without working nights.

Frequently asked questions

Do I need an SDK for PHP?

No. It is one JSON POST with a bearer token, so your language’s standard HTTP client is enough.

Should I generate the code myself?

Either works. Pass your own code and the provider only delivers it. Omit it and the provider generates one, stores a hash, and gives you a verify endpoint.

How long does a code stay valid?

Five minutes by default, configurable between 60 and 1800 seconds when the provider generates the code.

What if the user never receives it?

Check the error code on the send. If the number has no WhatsApp account the send fails, which is your cue to fall back to SMS.

Is the code stored anywhere?

Replio stores only a sha256 hash of codes it generates, never the code itself. Codes you supply are not stored at all.

Related Guides

Before You Land in Doha, Put These 10 Apps on Your Phone

Moving to Qatar for the first time means building a new phone home screen almost as soon as you land. These are the must-have apps in Qatar that actually earn a spot there. They cover government ID services, getting around, food and grocery delivery, banking, and one tool worth knowing about if you run a small business on the side.

None of these made the list on popularity alone. Each one solves a specific problem a newcomer hits in the first few weeks, from renewing a Qatar ID to finding a ride at 2am.

must-have apps in Qatar

The 10 must-have apps in Qatar, ranked by real use

Numbers below aren’t a strict ranking. They roughly follow the order most newcomers actually need each app, starting with government paperwork and ending with the one tool aimed at business owners rather than everyday errands.

1. Metrash — government and ID services

Metrash is Qatar’s Ministry of Interior app. It is genuinely non-optional for residents. The Ministry retired the older Metrash2 app on March 1, 2025. A rebuilt version replaced it, according to the Qatar Tribune. The new app covers more than 440 services after SIM verification on a Qatar number. That includes Qatar ID renewal, traffic fine payments, visa and exit permit management, address changes, and police clearance certificate requests. It also adds passport scanning for visa applications and a map of service center locations. Download it as soon as your Qatar ID is issued.

2. Hukoomi — the government’s single sign-on

Hukoomi is the national e-government portal. Its app extends one sign-on across more than 1,400 services from different ministries, per Hukoomi’s own service directory. Over 650 of those are fully personalized and transactional, not just informational. It also carries a public events calendar and an interactive map of government offices, banks and points of interest. Metrash covers Interior Ministry services specifically. Hukoomi is the wider net for everything else.

3. Ooredoo or Vodafone — get connected first

Qatar’s mobile market runs on two carriers. You will need one of their apps to manage your line from day one. Ooredoo’s prepaid plans generally offer longer validity periods and wider LTE coverage across the country. Vodafone tends to run slightly cheaper short-term data packs, concentrated in Doha, Pearl and West Bay, according to a comparison by Expatica. Both apps handle top-ups, data bundle changes and bill payment. Pick based on where you will actually live and work, not just price.

4. wer2 GO — ride-hailing that started in Doha

wer2 GO is a Doha-founded ride-hailing platform. It is licensed by Qatar’s Ministry of Transport alongside six other operators. It handles booking, real-time tracking and in-app payment for on-demand rides across Doha and the wider country. It also doubles as an earning platform for local drivers. wer2 GO is one of seven government-licensed ride-hailing apps currently operating in Qatar. See our full ranking of all seven for how it compares on coverage and features.

5. wer2 — e-scooters for short hops

wer2 also runs Qatar’s e-scooter rental network. It’s a separate app from wer2 GO. The idea is simple. Open the app, find a scooter on the map, scan the QR code on the handlebar, and ride. It works well for short trips around the Corniche, Pearl or Lusail that don’t justify booking a full ride. Every scooter in the fleet is electric with zero tailpipe emissions.

6. Snoonu — the do-everything delivery app

Snoonu started as a food delivery app in 2019. It grew into what it calls Qatar’s first super app, according to Gulf Times. Alongside restaurant orders, it now handles grocery delivery through its own Snoomart branches and partner stores. It also covers laundry pickup, pharmacy runs, courier drops and event tickets, all in one app. If you only install one delivery app in your first week, this is the one that covers the most ground.

7. Talabat — the widest restaurant list

Talabat remains the largest food delivery platform in Qatar by restaurant count. It runs across fast food, cafes, bakeries and fine dining. It also carries its own Talabat Mart for groceries and pharmacy items. A loyalty tier called Talabat Pro adds free delivery on qualifying orders. Keep both Talabat and Snoonu installed. Restaurant availability and delivery times vary enough between the two that it’s worth checking both before you order.

8. Your bank’s mobile app — set up before or after arrival

Every major Qatari bank runs a full-service app. Several now let you start the account-opening process before you land. QNB’s digital onboarding, for example, lets you scan a passport and Qatar ID and submit proof of address. You can open a current account without a branch visit. You generally still need a Qatar ID in hand to finish, though. Whichever bank you choose, install the app early. Payroll, rent and most bill payments in Qatar run through mobile banking, not cheques.

9. Visit Qatar — for weekends, not just arrival week

The official Visit Qatar app is run by Qatar Tourism. It’s built for visitors, but it stays useful long after you’ve moved in. It carries an events calendar covering festivals, exhibitions and concerts. It also offers 360-degree previews of attractions like Souq Waqif and Katara Cultural Village, plus personalized itinerary planning with built-in directions. It’s a fast way to find out what’s actually happening in the country on any given weekend.

10. Replio — if you’re bringing a business with you

This one isn’t for everyday errands. It’s for the growing number of newcomers who arrive already running a shop, restaurant or freelance service on the side. Replio is an AI customer-support tool. It answers customer messages around the clock on WhatsApp, Instagram, Messenger, Telegram and a website chat widget. It logs complaints and escalates to a human when needed. For a small business owner juggling a move and a shop at once, it’s one way to stop missing customer messages while you’re buried in visa paperwork.

Frequently asked questions

Do I need a Qatari phone number to use these apps?

Some do. Metrash and most banking apps require SIM verification on a Qatar mobile number. Snoonu, Talabat and wer2 GO work with an international number during setup. A local SIM still makes OTP codes faster and cheaper.

Is Metrash2 still the right app to download?

No. The Ministry of Interior retired the old Metrash2 app on March 1, 2025. Download the newer Metrash app instead. It carries over the same Qatar ID and traffic-fine services under a rebuilt interface.

Which ride-hailing app should I download first?

wer2 GO, Uber and Karwa cover the most ground for newcomers. Qatar’s Ministry of Transport currently licenses seven ride-hailing operators in total. Our full ranking breaks down all seven by coverage and features.

Can I open a Qatar bank account before I land?

With some banks, yes. QNB’s digital onboarding lets you scan your passport and start a current account application from abroad. You still need a Qatar ID to complete it once you arrive.

What’s the difference between Snoonu and Talabat?

Talabat focuses on restaurant and grocery delivery with the widest restaurant list in Qatar. Snoonu is a broader super app. It adds laundry, pharmacy runs, courier drops and event tickets alongside food and groceries.

Do I really need Hukoomi if I already have Metrash?

Metrash handles Ministry of Interior services like ID and traffic fines. Hukoomi is broader. It’s the government’s single sign-on directory for over 1,400 services across multiple ministries, plus a public events calendar.

Related coverage on Tamara News

Sources

Related Guides

A New Executive Order Wants to Stop Visa Holders From Giving Birth on US Soil

President Trump signed a birth tourism executive order on August 6, 2026. It directs federal agencies to crack down on travelers who use tourist or business visas mainly to give birth in the United States. Executive Order 14419 does not touch birthright citizenship law itself. It aims instead to tighten how consular officers screen visa applicants before that question ever arises.

The order arrives alongside a broader run of USCIS and State Department policy changes in August 2026. It is part of a pattern: tightening discretion across multiple visa categories at once.

birth tourism executive order

What the birth tourism executive order actually targets

Executive Order 14419 sets policy to prevent misuse of nonimmigrant visas. That mostly means tourist and business visitor visas. It targets applicants whose main purpose for traveling to the US is to give birth so their child gains citizenship. The order does not try to change birthright citizenship itself. That status stays set by existing constitutional and statutory law, regardless of a parent’s visa status or intent.

Instead, the order works upstream, at the visa screening stage. It directs agencies to develop practices for identifying applicants likely traveling for this purpose. That happens before a visa is even issued. This distinction matters. It is a visa-enforcement action, not a citizenship-law change, even though public debate often conflates the two.

How consular screening could change under the new policy

The order directs agencies to develop screening criteria. Specific operational details were still being finalized as of publication. What questions will officers ask? What documentation will they request? How will pregnancy itself factor into a visa decision? Similar birth-tourism enforcement efforts have historically focused on a few signals. Officers look at visible pregnancy at the time of application. They also weigh limited stated ties to an applicant’s home country, and vague answers about a planned US stay.

Pregnant applicants for tourist visas should expect possible extra questions once agencies finalize implementation. Pregnancy alone has never been a legal bar to receiving a visitor visa.

Why birth tourism sits in a legal gray area

No single federal statute bans traveling to the US specifically to give birth. The legal exposure comes through visa fraud law instead. An applicant who misrepresents their trip’s purpose can face fraud consequences separate from the birth itself. This order leans into that enforcement angle. It aims to catch visa fraud tied to birth tourism before the applicant travels, not after the child is already born a citizen.

Past administrations have debated similar screening measures without fully implementing them, largely because pregnancy itself is not a valid legal basis to deny a visa on its own. This order tries to thread that needle by focusing enforcement on misrepresentation of travel intent rather than pregnancy status directly, though critics argue the two are difficult to separate in practice at the visa window.

What to expect as implementation moves forward

Expect the State Department and USCIS to publish more detailed operational guidance in the coming months. They still need to translate the order’s broad direction into specific consular screening procedures. This administration has moved fast on related visa policy in August 2026. That includes the public charge guidance and the RFE policy change. Further implementation details for the birth tourism order will likely follow on a similarly fast timeline.

Applicants who are pregnant and planning US travel for reasons unrelated to childbirth should keep documentation ready. Proof of return travel, ties to a home country, and a clear stated purpose for the trip can all help at a consular interview once new screening practices take effect. Officers weigh the whole picture an applicant presents, not one factor alone.

Frequently asked questions

What does the birth tourism executive order do?

Executive Order 14419, issued August 6, 2026, sets policy to prevent misuse of nonimmigrant visas. It targets people traveling to the US mainly to give birth so their child gains citizenship.

What is birth tourism?

It means traveling to a country specifically to give birth there so the child acquires that country’s citizenship. The practice is legal in the US under current rules but has drawn criticism for years.

Does the birth tourism executive order change birthright citizenship itself?

No. The order targets visa issuance and consular screening. It does not touch the constitutional citizenship status of children born in the US, which stays governed by existing law.

How will consular officers enforce the new policy?

The order directs agencies to develop screening practices. Officers would look for applicants whose main travel purpose appears to be giving birth in the US, though full procedures were still being finalized as of publication.

Who is most likely to be affected by stricter screening?

Pregnant applicants for tourist or business visitor visas face the most scrutiny. Those in later pregnancy or with limited ties to their home country are most likely to face extra questions.

Is birth tourism illegal under current US law?

No single federal law bans traveling to the US to give birth. The practice sits in a gray area where visa fraud statutes can apply if an applicant misrepresents their travel purpose.

Related coverage on Tamara News

Sources

USCIS Just Quietly Rewrote a Rule That Could Sink Your Green Card Case

US Citizenship and Immigration Services published new guidance on August 18, 2026. It updates how officers apply the USCIS public charge rule when deciding immigration benefit applications. This is the second major USCIS policy shift in two weeks. An August 5 change already lets officers deny incomplete applications without first requesting missing evidence.

Together, the two updates give USCIS adjudicators more discretion. They also face less obligation to let applicants fix problems before a case is denied. Immigration attorneys are watching the shift closely.

USCIS public charge rule

What the USCIS public charge rule guidance actually changes

Public charge determinations decide one thing. Is someone applying for a green card, or certain other benefits, likely to become primarily dependent on government support? The August 18 guidance instructs officers on how to weigh the standard factors. Those factors include age, health, financial resources, education, family status and any history of public benefit use. USCIS has revised its public charge guidance several times over the past decade. Different administrations recalibrated how strictly to apply the standard each time. This update continues that pattern.

The guidance changes officer discretion, not the underlying statute. Its practical impact will show up gradually. Individual case decisions will reveal the shift, not one dramatic announcement.

Public charge policy has swung significantly between administrations over the past ten years. One version expanded the list of benefits that count against an applicant. A later version narrowed it back to a more traditional cash-assistance standard. This latest guidance is best read against that back-and-forth history rather than as a permanent, final word on the subject.

How this connects to the August 5 RFE policy change

Two weeks before the public charge guidance, USCIS made another change. Officers can now deny applications and petitions outright if required initial evidence is missing. They no longer need to first issue a Request for Evidence or a Notice of Intent to Deny. That change removed a longstanding safety net. Applicants used to get a chance to supplement an incomplete filing before facing denial.

Viewed together, the two policies point the same direction. Officers now hold a revised standard for weighing public charge risk. They also carry less obligation to seek clarification before denying a case outright. Applicants filing incomplete evidence near a public charge determination face compounded risk from both changes at once.

Who the public charge rule affects most

The guidance carries the most weight for green card applicants and others in benefit categories where public charge is an explicit eligibility factor. It does not apply the same way across every visa type. Many nonimmigrant visa categories are not directly affected. One group faces the closest scrutiny: applicants with a history of public benefit use, limited financial resources, or health conditions requiring ongoing care.

What applicants should do before filing

Public charge guidance has shifted often across several administrations. Immigration attorneys generally advise applicants to review their financial documentation and benefit history carefully before filing. Do not assume an older approach to a public charge determination still applies. The RFE safety net has also narrowed. That makes a complete application on first submission more important than it was before August 2026. Expect USCIS to issue further procedural guidance as officers start applying both changes in practice over the coming months.

Community legal aid organizations often publish plain-language updates when USCIS guidance shifts like this. Checking a reputable, updated source close to the filing date is generally more reliable than relying on older articles or forum posts, given how often the underlying guidance has moved this year alone. A short consultation with an attorney before filing can catch issues an applicant might otherwise miss entirely.

Frequently asked questions

What did USCIS publish on August 18, 2026?

USCIS published new guidance for adjudicating officers. It covers how to assess whether an applicant for immigration benefits is likely to become a public charge.

What does ‘public charge’ mean in immigration law?

It is a legal ground of inadmissibility. It applies to people considered likely to become primarily dependent on the government, historically measured through cash assistance and long-term institutional care.

Does the new USCIS public charge rule affect all visa applicants?

No. The guidance mainly affects green card applicants and certain other benefit categories where public charge is an eligibility factor. It does not apply the same way to every visa type.

Is this related to the RFE policy change from earlier in August?

It is a separate action. On August 5, 2026, USCIS authorized officers to deny applications without first issuing a Request for Evidence, a distinct policy from the August 18 public charge guidance.

What factors do officers weigh under the public charge rule?

Adjudicators weigh an applicant’s age, health, family status, financial resources, education and skills. They also weigh past or current use of public benefits under the revised standard.

Should applicants get legal advice before applying?

Public charge guidance has changed often in recent years. Applicants with any history of public benefit use or financial uncertainty should consult a licensed immigration attorney before filing.

Related coverage on Tamara News

Sources

$101 Billion in SpaceX Stock Just Became Sellable — Here’s the Catch

SpaceX insiders got their first chance to cash out since the company’s June 2026 IPO. The SpaceX insider lockup expiration freed up to 911.5 million shares for potential sale starting August 6. That stock is worth an estimated $101 billion. The stock touched a new low around the release date. Investors were weighing how much of that stock would actually hit the market.

Unlike most IPOs, SpaceX did not use a single lockup expiration date. It built a staggered schedule instead. That spreads the risk of a selling wave across several months.

SpaceX insider lockup expiration

What the SpaceX insider lockup expiration actually released

The first tranche unlocked August 6, 2026. It let insiders sell up to 20% of their eligible shares. That is as much as 911.5 million shares, or roughly $101 billion at prevailing prices. A second tranche of 319 million shares was scheduled to unlock August 12. More releases continue through the rest of the year. Not every insider share became sellable. A separate block of up to 455.8 million shares stays locked. SpaceX stock has been trading below its $135 IPO price, and that condition was built into the lockup terms.

CEO Elon Musk and a group of other major shareholders operate under a separate, extended lockup. It does not expire until June 2027. So the bulk of the shares now eligible for sale belong to earlier employees and outside investors, not Musk himself.

Why the stock hit a new low around the release

Markets typically price in some selling pressure ahead of a lockup expiration. Existing shareholders now have the option to realize gains, or cut losses, after months of being unable to trade. SpaceX shares fell to a new low around the August 6 date. That fits investors positioning for a supply increase, regardless of how much stock insiders actually chose to sell.

The staggered structure aimed to limit exactly this kind of shock. It spreads eligible sales over multiple dates instead of releasing everything at once. Even so, the first tranche alone, roughly $101 billion in newly sellable stock, was large enough to move the share price.

What’s still locked and for how long

The full 180-day lockup period runs through early December 2026. At that point, up to 5.33 billion shares in total become eligible for trading. Additional tranches will unlock on a rolling basis between now and then. The SpaceX insider lockup expiration is better understood as an ongoing process through year-end, not a single event that already ended on August 6.

Staggered lockups like this one are becoming more common among large, high-profile IPOs. Underwriters use them to avoid dumping an entire float onto the market on a single day, which can overwhelm demand and send a stock sharply lower in a short window. SpaceX’s schedule spreads that risk across roughly six months instead.

What to watch through the rest of the unlock schedule

Investors will watch each tranche for one signal: how much stock insiders actually sell versus hold. That behavior shows how confident early shareholders feel about SpaceX’s valuation going forward. The December milestone matters most. That is when the full 180-day lockup ends. It also marks when the largest pool of shares becomes eligible, well before Musk’s own extended lockup expires in mid-2027.

How SpaceX’s valuation holds up through each unlock will also shape sentiment around other recent high-profile IPOs using similar staggered structures. A smooth series of releases would support the case for spreading lockups over months. A sharp drop at any single tranche would raise fresh questions about whether staggering actually reduces the shock, or simply delays it. The next scheduled unlock date will be an early signal either way.

Frequently asked questions

How much SpaceX stock became sellable after the lockup expired?

Up to 911.5 million insider shares became eligible for sale starting August 6, 2026. That is worth roughly $101 billion, when the first tranche of SpaceX’s post-IPO lockup expired.

Did all SpaceX insiders get to sell their shares?

No. A separate tranche of up to 455.8 million shares stays locked because SpaceX stock trades below its $135 IPO price. Musk’s own shares fall under an extended lockup until June 2027.

What is the full SpaceX insider lockup expiration schedule?

SpaceX used a staggered schedule instead of one release date. 20% of eligible shares unlocked August 6, another 319 million were set for August 12, and the full lockup runs through early December 2026.

How many SpaceX shares could eventually be tradable?

Up to 5.33 billion shares become eligible for trading once the full 180-day lockup ends in early December 2026. Not all of that stock will necessarily be sold.

Did SpaceX’s stock price drop after the lockup expired?

Reports describe the stock hitting a new low around the lockup expiration. That reflects investor concern that a wave of insider selling would pressure the share price.

Why did SpaceX structure its lockup differently from typical IPOs?

A staggered release schedule spreads potential selling pressure across multiple dates instead of one event. The goal is generally to reduce the shock of a single massive sell-off.

Related coverage on Tamara News

Sources