# SMS Online GH Setup Guide

## Error: HSHK_ERR_UA_MODEL

This error means "Unauthorized - Invalid API Model/Credentials". It indicates an authentication issue with SMS Online GH.

## Quick Fix Steps

### Step 1: Verify Your API Key

1. Log in to your SMS Online GH dashboard: https://smsonlinegh.com
2. Navigate to **API Settings** or **Developer** section
3. Copy your API Key (it should be a long string)
4. Make sure you're copying the FULL key without any spaces

### Step 2: Check API Key Format

SMS Online GH API keys typically look like:
```
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

**Important**: 
- Copy the ENTIRE key
- Don't include any spaces before or after
- Don't include quotes

### Step 3: Update Your Settings

1. Go to Admin Dashboard → Settings
2. Scroll to "SMS Configuration"
3. Select "SMS Online GH" from the dropdown
4. Paste your API key in the "SMS API Key" field
5. Set your Sender ID (must be approved by SMS Online GH)
6. Click "Save Settings"

### Step 4: Test Again

1. Enter your phone number in "Admin Alert Phone Number"
2. Click "Send Test SMS"
3. Check if you receive the message

## Common Issues

### Issue 1: Wrong API Endpoint

**Symptoms**: HSHK_ERR_UA_MODEL error

**Solution**: The system now uses the correct endpoint:
```
https://api.smsonlinegh.com/v4/sms/send
```

If you're still getting errors, SMS Online GH might have changed their API. Check their documentation.

### Issue 2: API Key Not Activated

**Symptoms**: Unauthorized error

**Solution**:
- Verify your SMS Online GH account is active
- Check if your API key is enabled
- Some accounts require email verification before API access

### Issue 3: Insufficient Credits

**Symptoms**: Error after authentication passes

**Solution**:
- Log in to SMS Online GH dashboard
- Check your SMS credit balance
- Top up if balance is low

### Issue 4: Sender ID Not Approved

**Symptoms**: SMS fails with sender ID error

**Solution**:
- Use the default sender ID provided by SMS Online GH
- Or request approval for your custom sender ID
- Approval can take 24-48 hours

## SMS Online GH API Documentation

### Authentication
SMS Online GH uses API key authentication with the format:
```
Authorization: key YOUR_API_KEY
```

**Note**: Use `key` prefix, NOT `Bearer`

### Request Format
```json
POST https://api.smsonlinegh.com/v4/sms/send

Headers:
  Authorization: key YOUR_API_KEY
  Content-Type: application/json
  Accept: application/json

Body:
{
  "sender": "YourSenderID",
  "recipients": ["+233XXXXXXXXX"],
  "message": "Your message here"
}
```

### Success Response
```json
{
  "status": "success",
  "data": {
    "id": "message_id",
    "status": "sent"
  }
}
```

### Error Response
```json
{
  "handshake": {
    "id": 1201,
    "label": "HSHK_ERR_UA_MODEL"
  },
  "data": null
}
```

## Alternative: Use BulkSMS Ghana

If you continue having issues with SMS Online GH, you can switch to BulkSMS Ghana:

1. Go to Admin Settings
2. Change "SMS Provider" to "BulkSMS Ghana"
3. Enter your BulkSMS Ghana API key
4. Save and test

## Getting Help from SMS Online GH

If the issue persists:

1. **Contact SMS Online GH Support**
   - Website: https://smsonlinegh.com
   - Email: support@smsonlinegh.com
   - Provide them with:
     - Your account email
     - The error message: "HSHK_ERR_UA_MODEL"
     - Your API key (first and last 4 characters only)

2. **Check Their Documentation**
   - Look for API documentation on their website
   - Check if they've updated their API endpoints
   - Verify the authentication method

3. **Verify Account Status**
   - Ensure your account is fully activated
   - Check if there are any restrictions
   - Verify your account type supports API access

## Testing Your Configuration

After making changes:

1. Save your settings
2. Click "Send Test SMS"
3. Check the detailed error message
4. If it still fails, check Laravel logs:
   ```bash
   tail -f storage/logs/laravel.log | grep SMS
   ```

## What We Changed

The system now uses:
- Correct API endpoint: `/v4/sms/send`
- Correct auth header: `key` instead of `Bearer`
- Correct parameter: `recipients` instead of `recipient`
- Better error handling and logging

## Next Steps

1. **Verify your API key is correct**
2. **Make sure your account is active**
3. **Test with the updated code**
4. **Check Laravel logs for detailed errors**
5. **Contact SMS Online GH if issue persists**

## Quick Checklist

- [ ] API key is copied correctly (no spaces)
- [ ] SMS provider is set to "SMS Online GH"
- [ ] Sender ID is configured
- [ ] Account has SMS credits
- [ ] Account is fully activated
- [ ] API access is enabled for your account
- [ ] Phone number format is correct (+233XXXXXXXXX)
