Contracts and docs
Make an OpenAPI file the single source of truth. Test the API against it, generate docs and clients from it, and publish it for people and agents.
- Recommended 6
- Optional 1
Recommended
Write the contract first
API-45Describe every endpoint, parameter, body, response and error in one OpenAPI document, kept in version control next to the code.
Test the API against its contract
API-46Run tests that send requests and validate every response against the contract.
Give every endpoint an example
API-47Add a realistic request and response example to every operation in the contract.
Generate docs and clients from the contract
API-48Build the reference docs from the OpenAPI file, not by hand. Generating SDKs from it too is optional.
Make the API easy for agents to find
API-49Link the contract from a well-known place, so AI agents and tools can find and use the API without a human.
Mark server-set fields read-only and secrets write-only
API-50Mark every field the server sets, such as
id,createdAtandstatus, withreadOnly: truein the contract. Mark every field a client sends but never gets back, such as a password, withwriteOnly: true.
Optional
Describe multi-step tasks as Arazzo workflows
API-68When a common task takes three or more calls in a fixed order, describe it in an Arazzo file next to the OpenAPI contract.
Read this with
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">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.