# `Noizu.Comms.Message`
[🔗](https://github.com/noizu-labs-sdks/elixir-comms/blob/main/lib/lib/noizu/comms/message.ex#L1)

Channel-agnostic outbound message (contract shape).

* `:text` is required; everything else is optional.
* `:format` — `:markdown` (CommonMark subset: bold, italic, code, code
  block, link) or `:plain`.
* `:fields` — key/value facts, rendered as embed fields (Discord), block
  lines (Slack), or bold-key lines elsewhere.
* `:level` — `:info | :success | :warning | :error` (colour / emoji prefix).
* `:attachments` — by URL only in v1: `%{url:, name: | nil, mime: | nil}`.
* `:silent` — suppress notification where the channel supports it.

# `attachment`

```elixir
@type attachment() :: %{
  url: String.t(),
  name: String.t() | nil,
  mime: String.t() | nil
}
```

# `field`

```elixir
@type field() :: {String.t(), String.t()}
```

# `t`

```elixir
@type t() :: %Noizu.Comms.Message{
  attachments: [attachment()],
  fields: [field()],
  format: :markdown | :plain,
  idempotency_key: String.t() | nil,
  level: :info | :success | :warning | :error | nil,
  metadata: map(),
  reply_to: String.t() | nil,
  silent: boolean(),
  text: String.t() | nil,
  thread: String.t() | nil,
  title: String.t() | nil
}
```

# `new`

```elixir
@spec new(map() | keyword()) :: {:ok, t()} | {:error, Noizu.Comms.Error.t()}
```

Validates and builds a message from a map or keyword list.

# `new!`

```elixir
@spec new!(map() | keyword()) :: t()
```

Like `new/1` but raises `Noizu.Comms.Error` on invalid input.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
