# Eneba CRM API contract

Every connected storefront sends orders to one shared API. Each record includes `site_key`, `source_domain`, `landing_page`, `product_slug`, customer fields, status fields, `archived`, notes, and timestamps.

```text
POST  /api/orders
GET   /api/orders?site_key=eneba-autos&archived=false
PATCH /api/orders/:id/status
POST  /api/orders/:id/archive
POST  /api/orders/:id/restore
GET   /api/sites
```

`site_key` is stable and identifies a storefront even if its domain changes. The CRM groups active and archived records by that key and shows the source domain on every order.

```env
PUBLIC_API_URL=https://eneba.website/api
STOREFRONT_URL=https://eneba.autos
CRM_URL=https://eneba.website
ALLOWED_ORIGINS=https://eneba.autos,https://airgo.example,https://partner.example
```

The password in `admin.html` is a local demo gate. Production authentication must use a server-side password hash and an HttpOnly session cookie.

The current local demo refreshes immediately through the browser storage event and every five seconds through a live refresh loop. The production CRM should poll `GET /api/orders` at the same interval or use SSE if the hosting plan supports it.
