Settings accessors for the shop API.
Every function reads a core setting through PhoenixKit.Settings and applies a
safe default. The API is off by default and fails closed: a switch is on
only when its setting reads exactly "true", so a missing row, an unreadable
database, an unexpected value or a Settings error all count as off.
Settings
| Key | Default |
|---|---|
api_admin_enabled | false |
api_public_enabled | false |
api_disabled_tools | "" (newline separated tool names) |
api_mcp_allowed_origins | "" (newline separated origins) |
api_admin_preauth_fail_per_min | 20 |
api_admin_rate_per_min | 600 |
api_public_cart_rate_per_min | 120 |
api_public_ip_rate_per_min | 300 |
api_public_cart_rows_per_ip_hour | 120 |
api_public_cart_rows_global_hour | 2000 |
List settings are stored as newline-separated strings: PhoenixKit.Settings
has no list setter and a JSON setting cannot hold a bare list. Use
encode_list/1 when writing one and parse_list/1 when reading one.
Summary
Functions
Whether the admin API (/api/admin/v1) is switched on. Fails closed.
Tool names the install has hidden (api_disabled_tools). For display only: a list that
cannot be read is [] here, so request paths (PhoenixKit.API.Registry) use
fetch_disabled_tools/0, which does not treat it as "nothing is hidden".
Joins a list into the newline-separated form the list settings are stored in.
Tool names the install has hidden (api_disabled_tools), telling a list that is empty
from one that could not be read at all (a read that raises or exits).
Reads an integer setting.
Largest request body the API accepts, in bytes (2 MB).
Extra origins allowed to call the MCP endpoint (api_mcp_allowed_origins).
Splits a newline-separated setting value into a list.
Whether the public API (/api/shop/v1, MCP) is switched on. Fails closed.
The rate-limit settings as one map.
Functions
@spec admin_enabled?() :: boolean()
Whether the admin API (/api/admin/v1) is switched on. Fails closed.
@spec disabled_tools() :: [String.t()]
Tool names the install has hidden (api_disabled_tools). For display only: a list that
cannot be read is [] here, so request paths (PhoenixKit.API.Registry) use
fetch_disabled_tools/0, which does not treat it as "nothing is hidden".
Joins a list into the newline-separated form the list settings are stored in.
@spec fetch_disabled_tools() :: {:ok, [String.t()]} | :unreadable
Tool names the install has hidden (api_disabled_tools), telling a list that is empty
from one that could not be read at all (a read that raises or exits).
The tool registry fails closed on :unreadable: a tool the admin switched off must not
come back because of a settings problem. This is the one reader of the setting.
Reads an integer setting.
Returns default when the setting is missing, is not a whole number ("12abc" and
"1.5" are not read by their prefix), is zero or negative, or cannot be read. Every API
integer setting is a positive limit, and a zero limit would silently refuse every
request, so a non-positive value is treated as unset.
@spec max_body_bytes() :: 2_097_152
Largest request body the API accepts, in bytes (2 MB).
@spec mcp_allowed_origins() :: [String.t()]
Extra origins allowed to call the MCP endpoint (api_mcp_allowed_origins).
Splits a newline-separated setting value into a list.
Lines are trimmed; blank lines and duplicates are dropped. nil is [].
@spec public_enabled?() :: boolean()
Whether the public API (/api/shop/v1, MCP) is switched on. Fails closed.
@spec rate_limits() :: %{ preauth_fail_per_min: pos_integer(), admin_per_min: pos_integer(), public_cart_per_min: pos_integer(), public_ip_per_min: pos_integer(), cart_rows_ip_hour: pos_integer(), cart_rows_global_hour: pos_integer() }
The rate-limit settings as one map.
*_per_min limits count over a 60 second window and *_hour limits over a
one hour window (see PhoenixKit.API.RateLimit).