CLICommands

l4 api

l4 api is the escape hatch: it sends an authenticated request to any LevelFour API endpoint without writing curl or composing headers yourself. It resolves a credential the same way every other l4 command does. CLI authentication has that order.

l4 api <endpoint> [flags]

The endpoint must start with /, for example /api/v1/costs/summary.

A read-only key fails on any endpoint that writes. Key scopes has the split.

Flags

FlagDescription
-X / --method <verb>HTTP method (default GET)
-f / --field <key=value>Request body field (repeatable, used for POST)
--includeInclude the HTTP status line and headers in the output

l4 api also takes the global output flags, including the --jq below.

Examples

GET an endpoint:

l4 api /api/v1/costs/summary

Filter 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=read

Inspect the raw HTTP envelope:

l4 api /api/v1/costs/summary --include
A 2xx on the status line is the proof: the request reached the endpoint and the credential was accepted.

When to use the escape hatch

The dedicated subcommands cover most workflows. They handle pagination, format the output for humans, and stay forwards-compatible.

Reach for l4 api when:

  • No dedicated subcommand wraps the endpoint yet
  • You want to script against the raw API envelope
  • You are prototyping an integration before deciding whether to use an SDK
For language-native integrations, prefer the SDKs over l4 api.