Get from https://portal.hubtel.com → Developers → SMS API
HUBTEL_SMS_CLIENT_ID=your_client_id
HUBTEL_SMS_CLIENT_SECRET=your_client_secret
HUBTEL_SMS_FROM=Prosperous
HUBTEL_SMS_BASE_URL=https://smsc.hubtel.com/v1/messages/send
The system automatically handles all these formats:
0201234567 → +233201234567 ✓
233201234567 → +233201234567 ✓
+233201234567 → +233201234567 ✓
+1201234567 → ✗ Not Ghana format
02012345 → ✗ Too short (< 10 digits)
✅ Auto-generated username during registration ✅ Phone number validation for Ghana format ✅ Real-time availability checking for usernames ✅ SMS error handling with timeout (15s) ✅ Gmail fallback if SMS delivery fails ✅ Comprehensive logging for debugging ✅ Production-ready implementation
# Create .env file in backend directory
cp .env.example .env
# Add Hubtel credentials
HUBTEL_SMS_CLIENT_ID=your_id
HUBTEL_SMS_CLIENT_SECRET=your_secret
HUBTEL_SMS_FROM=Prosperous
HUBTEL_SMS_* variablescurl -X POST http://localhost:4000/api/auth/otp/request \
-H "Content-Type: application/json" \
-d '{
"purpose": "REGISTER",
"channel": "PHONE",
"target": "0201234567"
}'
Check logs for success indicators:
✓ [otpDelivery] Hubtel SMS sent successfully
✗ [otpDelivery] Hubtel SMS failed - check Hubtel credits
✗ [otpDelivery] Hubtel SMS error - check credentials/network
| Issue | Solution |
|---|---|
| SMS not received | Check Hubtel SMS credits balance |
| Invalid credentials error | Verify HUBTEL_SMS_* env vars |
| Timeout error | Check network to Hubtel API |
| Sender ID rejected | Verify sender ID approved in Hubtel portal |
Full setup instructions: HUBTEL_SMS_SETUP.md