# Naming Conventions — OmniMeta

Padrões derivados do código existente (`api/app/Models`, `api/src/Core`, Resources, `MessageWebhookTriggerUseCase`).

## Persistência (MongoDB)

| Item | Padrão | Exemplos |
| :--- | :----- | :------- |
| Collection | plural `snake_case` | `messages`, `whatsapp_accounts`, `billing_events` |
| Model Eloquent | PascalCase singular | `Message`, `BillingEvent` |
| Campos do documento | `snake_case` | `client_id`, `whatsapp_account_id`, `meta_fee` |
| IDs de wire Meta já usados | manter como no projeto | `wamid` (não `wam_id`) |
| Timestamps | Laravel | `created_at`, `updated_at` |

## Domain / UseCase

| Item | Padrão | Exemplos |
| :--- | :----- | :------- |
| Entity | PascalCase | `BillingEvent` |
| Props / DTO | `camelCase` | `$whatsappAccountId`, `$metaFee` |
| Repository | mapear no boundary | `whatsapp_account_id` ↔ `$whatsappAccountId` |
| Enum | `{Name}Enum` | `WebhookEventsEnum` |
| Cases de evento OmniMeta | SCREAMING_SNAKE | `BILLING_UPDATE` |
| Valores Meta espelhados | lowercase / snake Meta | `utility`, `messages` |

## API REST

- Prefixo: `/api/v1/...`
- Paths: `kebab-case` (`whatsapp-account`, `billing/rate-cards`)
- JSON request/response: **snake_case** (Resources atuais)

## Webhook outbound (cliente)

- JSON: **camelCase** (`subscriptionId`, `whatsappAccountId`, `metaFee`)
- Campo `event`: valor do enum (`BILLING_UPDATE`)
- Evidência: `api/src/Core/UseCase/Webhook/MessageWebhookTriggerUseCase.php`

## Billing — mapa rápido

| Persistência / REST | Domain / Webhook |
| :------------------ | :--------------- |
| `idempotency_key` | `idempotencyKey` |
| `message_id` | `messageId` / webhook `messageId` |
| `whatsapp_account_id` | `whatsappAccountId` |
| `client_id` | `clientId` |
| `meta_fee` | `metaFee` |
| `partner_fee` | `partnerFee` |
| `omni_fee` | `omniFee` |
| `price_resolved` | `priceResolved` |
| `occurred_at` | `occurredAt` |
| `include_non_billable` | `includeNonBillable` |
| `applied_rules.rate_card_id` | `appliedRules.rateCardId` |

No webhook, o id estável do evento no body `billing` é **`eventId`** (valor = `billing_events.id`).
