Postman collections as agent contracts
API examples agents should follow, turning Postman collections into executable contracts for coding agents.
Coding agents guess APIs when examples are missing. Postman collections (and similar) can act as executable contracts: routes, headers, payloads, variables, and example responses that agents must follow. Done right, this reduces invented endpoints and makes review faster. Done poorly, it becomes stale example theater.
The trap is simple: a collection that is not canonical and not run becomes fiction. Agents will follow it anyway.
Decide: Postman collections, OpenAPI-first, or ad hoc examples
Use Postman-as-contract when agents implement or call HTTP APIs frequently, when your team already maintains collections for QA, and when copy-pasteable requests help tickets and prompts. Prefer OpenAPI-first when the schema is the real contract and collections should be generated from it.
Fix this before agents touch the API: the contract flow

Contract Flow
Collections become useful when you make them canonical, include errors, and keep them secret-free.
Practical defaults:
- One canonical collection per service/version. Archive conflicting legacy collections.
- Include error shapes. Without them, agents overfit to 200 OK and invent edge cases.
- Placeholders only. Use variables and vaults. Never commit live tokens.
- Explicit environments. Staging vs prod hosts must be unambiguous.
- Sync with CI. Break builds when examples drift from real behavior.
Three failure modes to guard against

Failure modes to catch early
- Stale export. The collection is yesterday’s API. Fix: automate generation or enforce an update gate on API changes.
- Secret leakage. Tokens land in exports or shared workspaces. Fix: placeholders only, and rotate if a token leaked.
- Environment confusion. Requests hit the wrong host. Fix: lock environments and require explicit host variables per environment.
A weekly loop for keeping collections honest
- Weekly: run the canonical collection against staging. If it fails, fix the collection or the API before the next agent task.
- Monthly: prune duplicates and archive dead collections ruthlessly.
Bottom line

When this fits vs when it does not
Postman collections become agent contracts when they are canonical, secret-free, and kept in sync with CI. Point agents at examples and forbid invented routes. If OpenAPI leads, generate collections and prevent freestyle exports from becoming truth.
Share