# `PhoenixKit.API.Legacy`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.64.1/lib/phoenix_kit/api/legacy.ex#L1)

Every name the machine API had before it was made module-neutral, in one
place. The rest of `PhoenixKit.API` knows no module (a guard test fails when
it spells one), so the day the deprecation window closes this file is
deleted and only its callers are touched: `PhoenixKit.API.Paths`, the
fallback in `PhoenixKit.API.Config.rate_limits/0` (with
`rate_limits_without_fallback/0`, which exists only for it), the
Settings -> API form's `write_limits`, `PhoenixKit.API.Problem` (the four
error codes of the shop), `PhoenixKit.API.Executor` (the client token of a tool that
declares none) and `PhoenixKit.API.Idempotency` (the
credential names and markers of the old checkout links).

**This module is deleted in 3.0.0.** A client, a settings row or a module
that still uses a name below has until then to move to the canonical one.

What it holds:

  * the deprecated public paths, `/api/shop/v1` and `/mcp/shop`
    (`alias_paths/0`): `PhoenixKit.API.Paths` forwards them to the same
    plugs as the canonical `/api/public/v1` and `/mcp/public`, and the
    plugs mark every answer with `deprecation/0` and a `Link` to the
    canonical path;
  * the deprecated settings keys (`setting_fallback/1`): `PhoenixKit.API.Config`
    reads a limit from its new key and, when that holds no valid number, from
    the old one. Nothing deletes or migrates the old rows; the first save of
    Settings -> API writes the values in effect under the new keys;
  * the client token of a public tool that declares none (`legacy_client_token/1`):
    a module written before `PhoenixKit.API.Tool` had a `client_token` field named
    its anonymous caller's token `cart_token`, and the executor still reads it so
    such a module keeps its rate limit, its idempotency scope and its danger gate;
  * the four error codes the shop API answered with before modules could declare
    their own (`problems/0`): `PhoenixKit.API.Problem` (and, through it, the MCP advice)
    uses them for as long as no enabled module declares the same code
    (`c:PhoenixKit.Module.api_problems/0`);
  * the names a module's answers carried secrets under before `Tool.credentials`
    existed (`credential_keys/0`, `credential_markers/0`), which
    `PhoenixKit.API.Idempotency` still redacts and never stores for replay.

# `alias_paths`

```elixir
@spec alias_paths() :: [[String.t()]]
```

The deprecated public API paths, as lists of segments (the REST one, then the
MCP one). Each is served by the plug of the canonical public path of its
transport, and nothing publishes them: documents and headers name the
canonical path only.

# `credential_keys`

```elixir
@spec credential_keys() :: [String.t()]
```

The output field names `PhoenixKit.API.Idempotency` treats as credentials besides the
ones core's rule covers.

# `credential_markers`

```elixir
@spec credential_markers() :: [String.t()]
```

The substrings that make any string value of an answer a credential
(compared without regard to case).

# `deprecation`

```elixir
@spec deprecation() :: String.t()
```

The value of the `Deprecation` response header (RFC 9745) that every answer
on a deprecated path carries.

# `legacy_client_token`

```elixir
@spec legacy_client_token(PhoenixKit.API.Tool.t()) :: String.t() | nil
```

The input field a public `tool` that declares no `client_token` is read through, or
`nil`: `"cart_token"` when the tool's input schema has a property of that name.

# `problems`

```elixir
@spec problems() :: %{
  required(atom()) =&gt; %{
    status: pos_integer(),
    title: String.t(),
    advice: String.t()
  }
}
```

The error codes the shop answered with before modules declared their own, as
`%{code => %{status, title, advice}}`. They apply to a code only while no enabled
module declares it.

# `setting_fallback`

```elixir
@spec setting_fallback(String.t()) :: String.t() | nil
```

The deprecated settings key that `key` replaces, or `nil` when `key` replaced
none. `PhoenixKit.API.Config.int/3` reads it when `key` holds no valid number.

---

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