# `CCXT.WS.Auth.ListenKey`
[🔗](https://github.com/ZenHive/ccxt_client/blob/main/lib/ccxt/ws/auth/listen_key.ex#L1)

Listen Key auth pattern — binance family, aster.

`pre_auth/3` resolves the correct REST endpoint for the current market
type from `config[:pre_auth][:endpoints]`. The actual REST call, listen
key extraction, WS URL embedding, and periodic refresh all happen in the
adapter layer (T94/T95) — this module is pure endpoint resolution so it
stays network-free and unit-testable.

## Pre-auth Endpoints by Market Type

| Market | Endpoint |
|---|---|
| Linear (USD-M) | `fapiPrivatePostListenKey` |
| Inverse (COIN-M) | `dapiPrivatePostListenKey` |
| Spot | `publicPostUserDataStream` |
| Margin | `sapiPostUserDataStream` |
| Isolated margin | `sapiPostUserDataStreamIsolated` |
| Portfolio margin | `papiPostListenKey` |

## Config / opts

    config = %{
      pre_auth: %{
        endpoints: [
          %{type: :spot, endpoint: "publicPostUserDataStream", ...},
          %{type: :linear, endpoint: "fapiPrivatePostListenKey", ...}
        ]
      }
    }

    opts[:market_type]  # :spot | :linear | :inverse | :margin | ...
                        # :future and :delivery are normalized to :linear/:inverse

## Returns from `pre_auth/3`

    {:ok, %{endpoint:, market_type:, api_section:, method:, path:, credentials:}}
    | {:error, {:no_endpoint_for_market_type, %{requested:, normalized:, available:}}}

---

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