# Client Onboarding API - Updated

## Create Client (Full Company Onboarding)

**POST** `/api/admin/clients`

### Request Body

**Required Fields:**
- `name` - Contact person name
- `company_name` - Company name
- `email` - Company email
- `mobile` - Primary mobile number

**Optional Fields:**
- `alternate_mobile` - Secondary mobile number
- `gst_number` - GST registration number
- `address` - Company address
- `price_plan` - Pricing plan (default: 'free_trial')

### Example Request

```bash
curl -X POST http://127.0.0.1:8888/api/admin/clients \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "company_name": "Acme Corporation",
    "email": "contact@acme.com",
    "mobile": "+919876543210",
    "alternate_mobile": "+919876543211",
    "gst_number": "29ABCDE1234F1Z5",
    "address": "123 Business Park, Mumbai, India",
    "price_plan": "free_trial"
  }'
```

### Response (201 Created)

```json
{
  "message": "Client created successfully",
  "data": {
    "id": 1,
    "name": "John Doe",
    "company_name": "Acme Corporation",
    "email": "contact@acme.com",
    "mobile": "+919876543210",
    "alternate_mobile": "+919876543211",
    "gst_number": "29ABCDE1234F1Z5",
    "address": "123 Business Park, Mumbai, India",
    "price_plan": "free_trial",
    "api_key": "face_WUpchnbYas9d2ZiactJnwQO9G0L7ksHCsSQYxWBs",
    "is_active": true,
    "created_at": "2026-02-07T11:05:53.000000Z",
    "updated_at": "2026-02-07T11:05:53.000000Z"
  }
}
```

## Minimal Request (Backward Compatible)

```bash
curl -X POST http://127.0.0.1:8888/api/admin/clients \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Test Client"
  }'
```

**Note:** Old clients without company fields will continue to work.

## Database Schema

### Clients Table

| Column | Type | Nullable | Default | Index |
|--------|------|----------|---------|-------|
| id | bigint | No | - | Primary |
| name | string | No | - | - |
| company_name | string | No | - | - |
| email | string | No | - | Yes |
| mobile | string | No | - | - |
| alternate_mobile | string | Yes | NULL | - |
| gst_number | string | Yes | NULL | Yes |
| address | text | Yes | NULL | - |
| price_plan | string | No | 'free_trial' | - |
| api_key | string(64) | No | - | Unique |
| is_active | boolean | No | true | - |
| created_at | timestamp | Yes | - | - |
| updated_at | timestamp | Yes | - | - |

## Price Plans

Available values for `price_plan`:
- `free_trial` (default)
- `basic`
- `professional`
- `enterprise`

## Migration Details

**File:** `2026_02_07_114737_add_company_fields_to_clients_table.php`

**Changes:**
- ✅ Added 7 new columns
- ✅ Preserved existing data
- ✅ Added indexes on `email` and `gst_number`
- ✅ `api_key` and `is_active` unchanged
- ✅ Backward compatible

## Rollback

```bash
php artisan migrate:rollback --step=1
```

This will remove the new columns and restore the original schema.
