CLICommands
l4 api
l4 api is the escape hatch: send an authenticated request to any LevelFour API endpoint without writing curl or composing headers yourself. It uses the same auth resolution as every other l4 command (token flag → env var → keychain).
l4 api <endpoint> [flags]The endpoint must start with / (e.g. /api/v1/costs/summary). GET is the default; pass -X for other methods.
Flags
| Flag | Description |
|---|---|
-X / --method <verb> | HTTP method (default GET) |
-f / --field <key=value> | Request body field (repeatable, used for POST) |
--include | Include the HTTP status line and headers in the output |
Examples
GET an endpoint:
l4 api /api/v1/costs/summaryFilter the response with --jq:
l4 api /api/v1/recommendations --jq '.data.items[0]'POST with body fields:
l4 api -X POST /api/v1/api-keys -f name="CI Pipeline" -f scope=readInspect the raw HTTP envelope (status + headers):
l4 api /api/v1/costs/summary --includeWhen to use the escape hatch
Most workflows are better served by the dedicated subcommands (costs, recommendations, …) — they handle pagination, format the output for humans, and stay forwards-compatible.
Reach for l4 api when:
- The endpoint is so new (or so niche) that no dedicated subcommand exists yet
- You want to script against the raw API envelope
- You're prototyping an integration before deciding whether to use an SDK
For language-native integrations, prefer the SDKs over l4 api.