API: Configuration
Every key in config/streams/api.php: enabled, prefix, middleware, interface, and the gate.
Configuration merges into streams.api. Publish config/streams/api.php to change it (see Installation).
| Key | Env | Default | Purpose |
|---|---|---|---|
enabled |
STREAMS_API_ENABLED |
false |
Read by the default gate middleware. When false, API routes respond with gate_status. |
prefix |
STREAMS_API_PREFIX |
api |
Path used by API::routeCrud(), routeEntries(), and routeStreams(). |
default_interface |
STREAMS_API_DEFAULT_INTERFACE |
api |
ID of the default interface. Routes on other interfaces are named streams.api.{id}.…. |
middleware |
STREAMS_API_MIDDLEWARE |
api |
Middleware applied first to every interface's routes. Set an array in the config file for more than one. |
gate_middleware |
— | EnsureApiIsEnabled::class |
Middleware applied second to every interface's routes. Point it at your own class to decide who gets in. |
gate_status |
STREAMS_API_GATE_STATUS |
404 |
Status returned when the gate denies a request. |
gate_message |
STREAMS_API_GATE_MESSAGE |
Not Found |
Message returned when the gate denies a request. |
gate_except |
— | [] |
Request paths ($request->is() patterns) that bypass the enabled check. |
Middleware order
Every route on every interface gets this stack, in order:
middlewarefrom config (Laravel'sapigroup by default)gate_middlewarefrom configSetUpApiInterface, which resolves the current interface from the route name and boots it- The interface's own
->middleware([...]) - Resource middleware (
ApiResource::$middleware) and endpoint middleware
Multiple middleware
The env var holds a single value. STREAMS_API_MIDDLEWARE=api,auth:sanctum does not work: Laravel reads it as one middleware named api,auth with a sanctum parameter. Use an array in the published config file instead:
'middleware' => ['api', 'auth:sanctum', 'throttle:api'],
Or keep the config minimal and add middleware per interface (see Authentication).