API-47Recommended
Give every endpoint an example
Add a realistic request and response example to every operation in the contract.
How to do it
Use made-up but believable data. Run the examples through the contract tests, so they never go stale. People and AI agents both learn an API fastest from examples. Run the examples in the build, as Test the docs in the build says.
How to check
A linter rule finds no operation without an example, and every example validates against its schema.
Sources
Related rules
- DOC-8 Build and test the docs in CI and fail on every warning in Documentation
- DOC-25 Show each API example in every language you ship an SDK for in Documentation
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/api-design/contracts-and-docs/examples">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.