# Contract: Interação create/update (US1)

Endpoints: `includes/ajax/interacoes/create.php`, `includes/ajax/interacoes/update.php`
Callers: `includes/js/interacoes.js`, `includes/js/sucesso.js` (via `sendFormValues()`)

## Request (unchanged shape, relaxed constraint)

| Field | Type | Required | Change |
|---|---|---|---|
| `efetividade` | `"0"` \| `"1"` | yes | unchanged |
| `profissionais[]` | int[] | **required only when `efetividade == "1"`** | was unconditionally required client-side; now conditional, matching `titulo`/`descricao`/`canal`/`status`/`tipo` |
| all other fields | — | unchanged | unchanged |

## Server-side handling

- `create.php` / `update.php`: `$profissionais = $_POST['profissionais'] ?? [];` (new — defends against the field being entirely absent from the POST body when zero options are selected, which is the common client serialization behavior for an empty multi-select).
- Loop over `$profissionais` and insert into `InteracaoProfissional新` exactly as today; zero iterations is a valid, non-error outcome.
- No change to response shape: both endpoints still `die(json_encode($empresaId))` on success, or a JSON error body with HTTP 500 on failure.

## Client-side handling

- Remove the hardcoded `required` attribute from `<select multiple name="profissionais">` in `pages/interacoes/interacoes.php` and `pages/interacoes/sucesso.php`.
- Add `inputRequired('#interacao-input-profissionais', <efetividade == 1>)` inside the existing `$('input[name="efetividade"]').change(...)` handler in both `interacoes.js` and `sucesso.js`, alongside the existing titulo/descricao/canal/status/tipo calls.

## Acceptance mapping

- FR-001, FR-002, FR-003 ↔ spec User Story 1, Acceptance Scenarios 1–3.
