# Sample API Requests

Base URL: `http://127.0.0.1:8000`

Replace `YOUR_API_KEY` with a key from **Projects → Show** or:

```bash
php artisan tinker --execute="echo App\Models\ApiKey::first()->key;"
```

Seeded demo key (regenerate after re-seed):

```
fk_ba9ibtW9r4o5ElyBaBzJ81Z5zuCHlSHKiqfNHSCvl7yDdcR0
```

## cURL — JSON

```bash
curl -X POST "http://127.0.0.1:8000/api/form-submit" ^
  -H "Content-Type: application/json" ^
  -H "X-API-Key: YOUR_API_KEY" ^
  -H "Accept: application/json" ^
  -d "{\"form_name\":\"Contact\",\"name\":\"John Doe\",\"email\":\"john@example.com\",\"phone\":\"9999999999\",\"message\":\"Interested in your services\",\"city\":\"Mumbai\"}"
```

## cURL — URL Encoded

```bash
curl -X POST "http://127.0.0.1:8000/api/form-submit" ^
  -H "Accept: application/json" ^
  -d "api_key=YOUR_API_KEY&form_name=Enquiry&name=Sara&email=sara@example.com&phone=9888877777&message=Need%20a%20quote"
```

## JavaScript (fetch)

```javascript
fetch('https://your-domain.com/api/form-submit', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    form_name: 'Contact',
    name: document.querySelector('[name=name]').value,
    email: document.querySelector('[name=email]').value,
    phone: document.querySelector('[name=phone]').value,
    message: document.querySelector('[name=message]').value,
    honeypot: '' // must stay empty
  })
}).then(r => r.json()).then(console.log);
```

## PHP (server-side proxy example)

```php
$ch = curl_init('https://your-domain.com/api/form-submit');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'X-API-Key: YOUR_API_KEY',
        'Accept: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'form_name' => 'Contact',
        'name' => $_POST['name'] ?? '',
        'email' => $_POST['email'] ?? '',
        'phone' => $_POST['phone'] ?? '',
        'message' => $_POST['message'] ?? '',
    ]),
]);
$response = curl_exec($ch);
curl_close($ch);
```

Import `Form_Central_API.postman_collection.json` into Postman for ready-made requests.
