# Quick Start - Testing with Postman

## ✅ Yes, You're Right! Everything is Ready

Your commands are correct. Here's how to test:

## Step 1: Start Laravel Server

```bash
cd face-platform
php artisan serve --port=8080
```

**Why port 8080?** Your Python service is already running on port 8000.

Server will show:
```
INFO  Server running on [http://127.0.0.1:8080]
```

## Step 2: Test in Postman

### Request 1: Create Client

**POST** `http://127.0.0.1:8080/api/admin/clients`

Headers:
```
Content-Type: application/json
```

Body (raw JSON):
```json
{
  "name": "Acme Corporation"
}
```

**Click Send** → You'll get:
```json
{
  "message": "Client created successfully",
  "data": {
    "id": 1,
    "name": "Acme Corporation",
    "api_key": "face_xxxxxxxxxxxxxxxxxxxxx",
    "is_active": true
  }
}
```

**📋 COPY THE API KEY!**

---

### Request 2: Register Face

**POST** `http://127.0.0.1:8080/api/face/register`

Headers:
```
Content-Type: application/json
X-API-KEY: face_xxxxxxxxxxxxxxxxxxxxx
```
(Paste your API key from step 1)

Body (raw JSON):
```json
{
  "reference_id": "user_12345",
  "image": "your_base64_image_here"
}
```

**Click Send** → Response from Python service

---

### Request 3: Verify Face

**POST** `http://127.0.0.1:8080/api/face/verify`

Headers:
```
Content-Type: application/json
X-API-KEY: face_xxxxxxxxxxxxxxxxxxxxx
```

Body (raw JSON):
```json
{
  "reference_id": "user_12345",
  "image": "your_base64_image_here"
}
```

**Click Send** → Response from Python service

---

## Quick Test (Without Python Service)

If Python service is not running, you'll get:

**503 Service Unavailable**
```json
{
  "error": "Face engine unavailable"
}
```

This is CORRECT! It means Laravel is working, just can't reach Python.

---

## Postman Setup Tips

### 1. Create Environment
- Name: `Face Platform`
- Variables:
  - `base_url` = `http://127.0.0.1:8080`
  - `api_key` = (paste after creating client)

### 2. Use Variables in Requests
- URL: `{{base_url}}/api/admin/clients`
- Header: `X-API-KEY: {{api_key}}`

### 3. Save Collection
Save all requests as "Face Platform API" collection for reuse.

---

## Testing Checklist

✅ **Laravel Server Running**
```bash
php artisan serve --port=8080
```

✅ **Test Health Check**
- GET `http://127.0.0.1:8080/up`
- Should return: `{"status":"Healthy"}`

✅ **Create Client**
- POST `/api/admin/clients`
- Get API key

✅ **Test Face Register**
- POST `/api/face/register`
- Use API key in header

✅ **Test Face Verify**
- POST `/api/face/verify`
- Use API key in header

---

## Common Issues

### "Could not get any response"
**Problem:** Server not running
**Solution:** Run `php artisan serve --port=8080`

### "Address already in use"
**Problem:** Port 8080 is busy
**Solution:** Use different port: `php artisan serve --port=8081`

### 401 "API key required"
**Problem:** Missing X-API-KEY header
**Solution:** Add header: `X-API-KEY: face_xxx`

### 422 Validation Error
**Problem:** Missing required fields
**Solution:** Include both `reference_id` and `image` in body

### 503 "Face engine unavailable"
**Problem:** Python service not running
**Solution:** This is expected if Python is not running. Laravel is working correctly!

---

## You're Ready! 🚀

1. Start server: `php artisan serve --port=8080`
2. Open Postman
3. Create client → Get API key
4. Test register/verify endpoints

Everything is set up correctly!
