# `Jido.Messaging.OutboundGateway`
[🔗](https://github.com/agentjido/jido_messaging/blob/v1.0.0/lib/jido_messaging/outbound_gateway.ex#L1)

Partitioned outbound gateway for send/edit delivery operations.

The gateway enforces:

- Stable partition routing by `bridge_id:external_room_id`
- Bounded per-partition queues with pressure transition signals
- Normalized outbound error categories for retry and terminal handling

# `error_category`

```elixir
@type error_category() :: :retryable | :terminal | :fatal
```

# `error_response`

```elixir
@type error_response() :: %{
  type: :outbound_error,
  category: error_category(),
  disposition: :retry | :terminal,
  operation: operation(),
  reason: term(),
  attempt: pos_integer(),
  max_attempts: pos_integer(),
  partition: non_neg_integer(),
  routing_key: String.t(),
  retryable: boolean()
}
```

# `operation`

```elixir
@type operation() :: :send | :edit | :send_media | :edit_media
```

# `priority`

```elixir
@type priority() :: :critical | :high | :normal | :low
```

# `request`

```elixir
@type request() :: %{
  :operation =&gt; operation(),
  :channel =&gt; module(),
  :bridge_id =&gt; String.t(),
  :external_room_id =&gt; term(),
  :payload =&gt; String.t() | map(),
  :opts =&gt; keyword(),
  :routing_key =&gt; String.t(),
  :session_key =&gt; Jido.Messaging.SessionManager.session_key(),
  optional(:external_message_id) =&gt; term(),
  optional(:route_resolution) =&gt; Jido.Messaging.SessionManager.resolution(),
  optional(:idempotency_key) =&gt; String.t() | nil,
  optional(:max_attempts) =&gt; pos_integer() | nil,
  optional(:base_backoff_ms) =&gt; pos_integer() | nil,
  optional(:max_backoff_ms) =&gt; pos_integer() | nil,
  optional(:priority) =&gt; priority()
}
```

# `success_response`

```elixir
@type success_response() :: %{
  :operation =&gt; operation(),
  :message_id =&gt; term(),
  :result =&gt; map(),
  :partition =&gt; non_neg_integer(),
  :attempts =&gt; pos_integer(),
  :routing_key =&gt; String.t(),
  :pressure_level =&gt; :normal | :warn | :degraded | :shed,
  :idempotent =&gt; boolean(),
  optional(:route_resolution) =&gt; Jido.Messaging.SessionManager.resolution(),
  optional(:security) =&gt; map(),
  optional(:media) =&gt; map()
}
```

# `classify_error`

```elixir
@spec classify_error(term()) :: error_category()
```

Normalize raw provider/channel failures into gateway categories.

# `config`

```elixir
@spec config(module()) :: keyword()
```

Returns gateway config for an instance module.

# `edit_media`

```elixir
@spec edit_media(module(), map(), term(), map(), keyword()) ::
  {:ok, success_response()} | {:error, error_response()}
```

Edit media through the outbound gateway.

# `edit_message`

```elixir
@spec edit_message(module(), map(), term(), String.t(), keyword()) ::
  {:ok, success_response()} | {:error, error_response()}
```

Edit a message through the outbound gateway.

# `partition_count`

```elixir
@spec partition_count(module()) :: pos_integer()
```

Returns configured partition count for the gateway.

# `route_partition`

```elixir
@spec route_partition(module(), String.t(), term()) :: non_neg_integer()
```

Resolve a stable partition for a routing key tuple.

# `routing_key`

```elixir
@spec routing_key(String.t(), term()) :: String.t()
```

Returns a stable routing key used by partition hashing.

# `send_media`

```elixir
@spec send_media(module(), map(), map(), keyword()) ::
  {:ok, success_response()} | {:error, error_response()}
```

Send media through the outbound gateway.

# `send_message`

```elixir
@spec send_message(module(), map(), String.t(), keyword()) ::
  {:ok, success_response()} | {:error, error_response()}
```

Send a message through the outbound gateway.

---

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