# 03 — Team / Staff

← [Back to index](README.md)

A clinic has **at most one** receptionist member besides the owner. Creating one
**provisions a login** the secretary uses on [`POST /auth/login`](01-auth.md). Doctor-only.

The frontend has a single `saveMember()` call used for both create and update — **dispatch
by whether the member already has a server `id`** (no id → POST, has id → PUT).

---

## `GET /tenant/staff`
**Response `200`** — the single member, or `null`/empty when none:
```json
{
  "id": "stf_1",
  "name": "سارة محمد",
  "email": "sara@example.com",
  "role": "receptionist",
  "password": "******"
}
```
> 🔒 **Never return the real password.** Return a placeholder or omit the field. The app
> only displays name/email/role.

---

## `POST /tenant/staff`
Creates the receptionist account (this is what enables the secretary to log in).

**Request**
```json
{
  "name": "سارة محمد",
  "email": "sara@example.com",
  "password": "secret123",
  "role": "receptionist"
}
```
- `role` is always `receptionist` (the app fixes it).
- **One-member limit:** if a member already exists, return `409`.
- Hash the password; create a real login user scoped to this tenant.

**Response `201`** — the created member (password omitted/masked).

---

## `PUT /tenant/staff/{id}`
Edits the member. Name + email always sent. **Password may be empty → keep current.**

**Request**
```json
{ "name": "سارة م.", "email": "sara2@example.com", "password": "" }
```
- Empty/omitted `password` → do not change it. Otherwise hash + update (min:6).

**Response `200`** — the updated member.

---

## `DELETE /tenant/staff/{id}`
Removes the member and their login. **Response `200`/`204`**.

---

## `TeamMember` fields (contract)

| Field | Type | Notes |
|---|---|---|
| `id` | string | server-assigned |
| `name` | string | |
| `email` | string | unique within tenant |
| `role` | string | always `receptionist` ([StaffRole](11-enums.md)) |
| `password` | string | write-only: app sends it on create/update; server never returns it |
