# Client Management API

## Endpoints

### 1. Create Client
**POST** `/api/admin/clients`

Creates a new client and generates a unique API key.

**Request:**
```json
{
  "name": "Acme Corporation"
}
```

**Response:** `201 Created`
```json
{
  "message": "Client created successfully",
  "data": {
    "id": 1,
    "name": "Acme Corporation",
    "api_key": "face_tWTNekwygF7lMHVbN5IGORsVljUekmRwqidTcHYU",
    "is_active": true,
    "created_at": "2026-02-07T10:38:57.000000Z",
    "updated_at": "2026-02-07T10:38:57.000000Z"
  }
}
```

### 2. List Clients
**GET** `/api/admin/clients`

Returns all clients (API keys hidden).

**Response:** `200 OK`
```json
{
  "data": [
    {
      "id": 1,
      "name": "Acme Corporation",
      "is_active": true,
      "created_at": "2026-02-07T10:38:57.000000Z",
      "updated_at": "2026-02-07T10:38:57.000000Z"
    }
  ]
}
```

### 3. Update Client Status
**PATCH** `/api/admin/clients/{id}/status`

Activate or deactivate a client.

**Request:**
```json
{
  "is_active": false
}
```

**Response:** `200 OK`
```json
{
  "message": "Client status updated",
  "data": {
    "id": 1,
    "name": "Acme Corporation",
    "is_active": false,
    "created_at": "2026-02-07T10:38:57.000000Z",
    "updated_at": "2026-02-07T10:38:58.000000Z"
  }
}
```

## Testing

```bash
# Start server
php artisan serve

# Create client
curl -X POST http://127.0.0.1:8000/api/admin/clients \
  -H "Content-Type: application/json" \
  -d '{"name":"Test Company"}'

# List clients
curl http://127.0.0.1:8000/api/admin/clients

# Deactivate client
curl -X PATCH http://127.0.0.1:8000/api/admin/clients/1/status \
  -H "Content-Type: application/json" \
  -d '{"is_active":false}'
```
