WhatsApp OTP Example

Request WhatsApp OTP from Flutter

A Flutter client example that calls your backend securely.

Setup

  • Add the http package to your Flutter app.
  • Create a backend endpoint that sends the DNZ request.

Code

Future<void> requestOtp(String phone) async {
  final response = await http.post(
    Uri.parse('https://api.example.com/request-otp'),
    headers: {'Content-Type': 'application/json'},
    body: jsonEncode({'phone': phone}),
  );

  if (response.statusCode >= 400) {
    throw Exception('Unable to request OTP');
  }
}

Production notes

  • Do not ship the DNZ API key inside the mobile app.
  • Use HTTPS and server-side abuse limits.

Related links