Validate Your API Contracts in CI/CD with MarkApiDown
Run MarkApiDown in CI to validate specs and run contract tests. Use exit codes, JUnit output, and the npm wrapper for easy integration with any CI system.
Use this file to discover all available pages before exploring further.
MarkApiDown is a single static binary with no runtime dependencies, which makes it straightforward to drop into any CI pipeline. You get spec validation, contract test execution, and structured output in one tool — gated by stable exit codes that never change between releases.
Run mad doctor as a pre-flight check before any CI step. It verifies your collection exists, all specs are valid, and common misconfigurations (such as a missing .env.local entry in .gitignore) are caught before they cause a cryptic failure downstream.
Use mad validate to check that every spec file in api-docs/ is structurally correct. It exits with code 2 if any spec has a frontmatter error, a missing required section, or an unresolved variable. It exits with code 5 if a secret pattern is detected in a versioned file.
mad validate api-docs/
Run this before any test step so that malformed specs are caught early, independently of whether the API is reachable.
Use mad exec to run a single endpoint against a live environment and compare the response to the ## Expected response block in the spec. Use mad flow for multi-step pipelines that chain captures across endpoints.
Pass secrets via MAD_* environment variables. The MAD_ prefix is stripped and the remainder is converted to lower camelCase before variable resolution — MAD_AUTH_TOKEN becomes {{authToken}} in your specs.
For Node.js projects, use npx to run MarkApiDown without a global install step. The npm wrapper downloads the platform-appropriate binary on first use.
Use --output=json to get machine-readable output from any mad exec or mad flow command. The JSON includes the pass/fail status, HTTP status code, duration, diff details, and any assertion results.
This is useful for custom dashboards, Slack notifications, or any downstream step that needs to act on structured results rather than parsing terminal output.
Set any secret as a MAD_-prefixed environment variable. MarkApiDown strips the prefix and converts the remainder to lower camelCase before resolving it as a spec variable.
Environment variable
Resolved as
MAD_AUTH_TOKEN
{{authToken}}
MAD_STRIPE_KEY
{{stripeKey}}
MAD_BASE_URL
{{baseUrl}}
MAD_API_SECRET_KEY
{{apiSecretKey}}
Never put secrets directly in spec files or pass them with --var authToken=$SECRET on the command line. Shell argument lists can appear in CI logs and expose the secret value. Always use MAD_* environment variables — MarkApiDown reads them at runtime and masks them in all output.