Skip to content

Cheat sheet

Everything apic understands, on one page. Each section links to the full explanation.

@baseUrl = https://api.example.com # file variable, last one wins
### Log in and keep the token # separator; the title is the description
# @name login # id used on the command line and by MCP
# @assert status == 200
# @capture token = body.$.access_token
POST {{baseUrl}}/auth/login
Content-Type: application/json
{"user": "{{user}}", "password": "{{password}}"}
BodySyntax
InlineEverything after the blank line, {{vars}} substituted
From a file< ./payload.json as it is, <@ ./payload.json with {{vars}} substituted
Multipart uploadContent-Type: multipart/form-data; boundary=X, parts between --X lines, < ./report.pdf as a part’s content; see format
GraphQLGRAPHQL {{baseUrl}}/graphql (or X-REQUEST-TYPE: GraphQL), the query as the body, variables as a JSON object after a blank line; sent as a JSON POST; see format
Save the response>> ./out.json (create) or >>! ./out.json (overwrite) after the body; apic run --output file for one run; see format
HTTP versionGET https://x/ HTTP/1.1 never uses HTTP/2; HTTP/2 requires it; none negotiates; see format
CommandWhat it does
apic run <target>...Send requests; several targets run in order as a flow; --output file saves one response body
apic run <target> --data rows.csvRun once per row of a CSV file or JSON array; each row’s columns are variables
apic run <target> --assert <expr> --capture <name=selector>A check or a capture for this run only, before writing it into the file
apic run <target> --dry-runThe request as it would be sent, resolved; nothing sent, nothing captured
apic run <target> --body-limit 4kAt most that much body in the output, marked body_truncated; the history keeps it all
apic uiTerminal UI; --demo needs no project
apic test [paths]Run Gherkin features
apic list [pattern]Every request, filtered by id, URL, file or description
apic describe <id>Variables, sources, captures, asserts, readiness
apic envEnvironments and the variables in effect
apic session [clear]Captured values; clear --all for every environment
apic history <id>Past responses (needs history: N in apic.yaml; apic init sets 10); --show 2, diff, clear <id> or clear --all
apic select <id> <selector>A value from the last recorded response, without sending again; --entry 2 for the one before
apic curl <id>The equivalent curl command
apic snippet <id> --lang pythonThe request as httpie, powershell, python, js or go code
apic init [dir]Scaffold a project, Agent Skill and .mcp.json included (--no-skill, --no-mcp)
apic skill [name]Print a briefing for an AI agent: apic (how to use apic, the default), api-design (how to design the API) or api-security (how to secure it and prove it)
apic skill installWrite the apic skill into .claude/skills and .agents/skills of the project; --all adds api-design and api-security, --skill <name> picks exactly those, --user writes under your home directory so every project has them
apic import <spec>.http files from an OpenAPI 3 document or a Postman collection (--postman-env for its environments)
apic import --curl '<cmd>' --into f.httpOne request block from a curl command
apic validateParse everything and report problems (CI); --format github|sarif
apic fmt [--check|--diff]Canonical formatting for .http files; - filters stdin; file.http#name for one request
apic mcp [install]Serve the project to agents over MCP, or register the server in .mcp.json
apic lspLanguage server for any LSP editor (set-up)
apic demoScaffold and serve the bundled fake API
apic mock <spec>Serve an OpenAPI 3 document as a stateless mock API; a Prefer: code=404 header line picks another documented response

Targets: get-user (by name) · users.http (whole file as a flow) · users.http#get-user · users.http#3 (third request).

Global flags: -C/--dir, -e/--env, --var k=v, --json, --no-color, --timeout, --no-session, --insecure, --cacert, --cert, --key, --redact, --cookies, --proxy, --no-proxy.

Exit codes: 0 ok · 1 assertion or capture failed · 2 usage, parse error, unknown request or missing variable · 3 network error.

Written as comments before the request line, so editors ignore them.

DirectiveMeaning
# @name get-userId for the command line, MCP and features
# @description textOne line shown by list and describe
# @capture name = selectorStore a value from the response for later runs
# @assert selector op valueCheck the response; failures exit 1
# @auth type ...none, bearer, basic, apikey, digest, aws, oauth2, exec; see auth
# @step a user named {name} existsGherkin phrase that runs this request
# @ref loginRun login first when a variable is missing
# @forceRef loginRun login first every time
# @no-redirectDo not follow 3xx
# @no-sessionDo not persist this request’s captures
# @no-cookiesSend and keep no cookies for this request
# @timeout 10sPer-request timeout
# @retry 10 2sRe-send until the assertions pass, up to 10 times, 2s apart
# @sleep 2sWait before sending
# @disabledSkipped when its file runs as a flow; apic run <name> still sends it
# @note textFree text, ignored (REST Client compatibility)
# @prompt nameIgnored; pass the value with --var name=... instead

Unknown directives are warnings from apic validate, not errors.

First match wins:

  1. --var name=value (or vars in an MCP call)
  2. APIC_VAR_name in the shell environment
  3. values captured earlier in this run
  4. the session, .apic/session.json, per environment
  5. http-client.private.env.json for the environment
  6. http-client.env.json for the environment ($shared applies to all)
  7. .env in the project root
  8. @name = value in the .http file

apic describe <id> prints the source each variable actually resolved from.

PlaceholderValue
{{$uuid}} / {{$guid}}random UUID v4
{{$timestamp}} / {{$timestamp -1 d}}Unix seconds, optional offset (s m h d w M Q y ms)
{{$isoTimestamp}}RFC 3339 UTC
{{$datetime rfc1123|iso8601|"2006-01-02" [1 h]}}formatted UTC time, optional offset
{{$localDatetime [format] [offset]}}the same in the local zone
{{$randomInt 1 100}} / {{$random.integer(1, 100)}}random integer in [min, max)
{{$random.float(0, 1)}}, $random.alphabetic(n), alphanumeric(n), hexadecimal(n), email, uuidJetBrains’ random family
{{$processEnv NAME}} / {{$env.NAME}}shell environment variable
{{$dotenv NAME}}value from .env
{{$projectRoot}}absolute project root
{{$auth.token("name")}}token of a JetBrains Security.Auth configuration; see auth
{{login.response.body.$.token}}an earlier response in the same flow
SelectorValue
statusstatus code
statusTexte.g. OK
header.<name>first value of a response header; .# counts its values, [1] picks one
cookie.<name>value of a cookie the response set
bodyraw body
body.$whole JSON body
body.$.<path>body.$.items[0].id, [-1], [1:3], [*], body.$..id, body.$.items[?(@.done == true)].id, .# or .length (count), body.$["key.with.dots"]; see format
durationround-trip time in milliseconds

== != < <= > >= (numeric when both sides are numbers) · contains · startsWith · endsWith · matches (Go regexp) · exists · not exists · isString isNumber isInteger isBoolean isArray isObject isNull isEmpty (and not …) · length <op> <n> · matchesSchema <file.json>

# @assert status < 300
# @assert body.$.items.# >= 1
# @assert header.content-type contains json
# @assert body.$.email matches ^[^@]+@example\.com$
# @assert body.$.error not exists
# @assert body.$.id isInteger
# @assert body.$.items length == 3
# @assert body.$ matchesSchema ./schemas/user.json

Built-in vocabulary, usable in any .feature file:

Given the environment is "staging"
And the variable "userId" is "42"
And the variables:
| userId | 42 |
When I run "get-user"
And I run "get-user" with:
| userId | 7 |
And I run the file "users.http"
Then the response status is 200
And the response status is not 500
And the response is successful # or a client error, a server error
And the response body "$.name" is "alice"
And the response header "content-type" contains "json"
And the response cookie "sid" exists
And the response body "$.id" exists
And the response body is:
"""
{"id": 42}
"""
And the response time is under 500 ms
When I capture the response body "$.id" as "userId"

# @step phrases on requests add your own wording. apic test --steps lists everything available in the current project.

api/
apic.yaml env, dir, timeout, retry, cookies, history, proxy, noProxy, maxBodyBytes, tls, auth.default, auth.allowExec, test.paths
features/*.feature Gherkin specs run by `apic test`
http-client.env.json public per-environment variables
http-client.private.env.json secrets (gitignored)
.env optional KEY=value
auth.http
users.http
.apic/session.json captured values (created by apic, self-ignored)
.apic/cookies.json the cookie jar, when cookies: true

enter run · f run the file · a run all · / filter · 1-5 tabs · H headers · c curl · e/E environment · r reload · o edit · x clear session · ? help · q quit. Full list in the TUI guide.

Hosted on Cloudflare, which keeps aggregate traffic statistics. No cookies, no tracking scripts, no per-request logs. Privacy