Every MarkApiDown project keeps its environment-specific variables in a single shared file:Documentation Index
Fetch the complete documentation index at: https://docs.markapidown.net/llms.txt
Use this file to discover all available pages before exploring further.
api-docs/_shared/env.md. Each environment — dev, staging, production, and any custom names you define — gets its own ## heading containing a fenced YAML block of key-value pairs. When you run a command with --env staging, MarkApiDown reads only the ## staging block and makes those values available to all your endpoint specs as {{variableName}} references.
Complete example
A typical_shared/env.md defines at least a dev environment and grows as you add deployment targets. The following example is drawn from the JSONPlaceholder sample project included with MarkApiDown.
Commonly used variables
| Variable | Purpose |
|---|---|
baseUrl | Root URL prepended to all request paths — {{baseUrl}}/posts/:postId |
postId | Path parameter for post-related endpoints — /posts/:postId |
userId | Path parameter or request body field for user-scoped requests |
Adding a new environment
Add a new## section to _shared/env.md using the same name you plan to pass to --env. Then run mad validate api-docs/ to confirm the file parses correctly.
Variable resolution order
MarkApiDown resolves{{variableName}} references by layering four sources. Later sources override earlier ones, so CLI flags always win.
env.md — environment block
MarkApiDown reads the
## section in _shared/env.md that matches the active environment name (e.g. ## dev). This is the baseline for every request..env.local — local overrides
MarkApiDown looks for
.env.local in your project root (the directory containing api-docs/). Values here override the env block. This file is never committed to version control.MAD_* OS environment variables
Any OS-level environment variable whose name starts with
MAD_ is mapped into the variable context. The MAD_ prefix is stripped and the remainder is converted to camelCase: MAD_API_TOKEN → apiToken.Secrets management
Keep secrets out ofenv.md entirely. Use one of these two mechanisms instead.
- .env.local
- MAD_* env vars
Create a Reference these values in any spec exactly like env variables:
.env.local file in your project root (the directory that contains api-docs/). Write one KEY=value pair per line. Lines starting with # are comments.mad init automatically adds .env.local to your .gitignore. If you add the file manually, add this line to .gitignore yourself:.gitignore entry
mad init adds .env.local to your .gitignore automatically. If you manage your own .gitignore, add the entry manually:
mad doctor at any time to confirm .env.local is excluded:
Browser UI: the Variables drawer
When you open the web preview withmad serve, the Variables drawer in the sidebar shows all resolved variables for the active environment. It splits them into two tabs:
Env
Variables sourced from the
## <env> block in env.md. These are read-only in the browser and reflect the file on disk.Browser
Variables stored in
localStorage for the current browser session. Use these to temporarily override an env variable without modifying any file — useful for pasting in a token during manual testing.env.md or .env.local.