# Bird Module

This module provides Bird API integration for voice calls and number management.

## Endpoints

### Voice calls
- `POST /bird/voice/calls`
  - Permission: `modules_bird_voice_calls_create`
  - Required: `workspaceId`, `channelId`
  - Body: passthrough to Bird call create API (except `workspaceId` and `channelId`).

- `GET /bird/voice/calls`
  - Permission: `modules_bird_voice_calls_list`
  - Required query: `workspaceId`, `channelId`
  - Query params are passed through to Bird.

- `GET /bird/voice/calls/{id}`
  - Permission: `modules_bird_voice_calls_get`
  - Required query: `workspaceId`, `channelId`

- `POST /bird/voice/calls/{id}/hangup`
  - Permission: `modules_bird_voice_calls_hangup`
  - Required: `workspaceId`, `channelId`

- `POST /bird/voice/calls/test-outbound`
  - Permission: `modules_bird_voice_calls_test_outbound`
  - Required: `workspaceId`, `channelId`
  - Places an outbound call to the fixed test number `+45 42 33 11 28` (`+4542331128`), polls call state, and sends hangup when state is `accepted` or `ongoing`.
  - Optional tuning params:
    - `pollIntervalSeconds` (default `2`)
    - `maxPollSeconds` (default `30`)
    - `hangupCause`

### Numbers
- `GET /bird/numbers`
  - Permission: `modules_bird_numbers_list`
  - Optional query: `workspaceId` (if not configured)
  - Query params are passed through to Bird.

- `GET /bird/numbers/{id}`
  - Permission: `modules_bird_numbers_get`
  - Optional query: `workspaceId` (if not configured)

- `DELETE /bird/numbers/{id}`
  - Permission: `modules_bird_numbers_delete`
  - Optional query/body: `workspaceId` (if not configured)
  - Releases/deletes a number if supported by Bird account policy.

## Logging

Bird requests are logged through `logs_o` with module `bird`, including:
- Request start (`BIRD_HTTP_REQUEST`)
- Response status (`BIRD_HTTP_RESPONSE`)
- API or transport errors (`BIRD_HTTP_ERROR`, `BIRD_HTTP_CURL_ERROR`)
- Test outbound flow events (`BIRD_TEST_OUTBOUND_CALL_*`)

## Notes

- Bird credentials and base URL are configured in Bird module config.
- Route handlers enforce workspace/channel requirements before outbound API calls.
