Resources and methods
Name resources as nouns, use each HTTP method for what it means, and answer with the status code that tells the client exactly what happened.
- Recommended 6
Recommended
Name resources as plural nouns
API-1Address each kind of thing as a plural noun, and each single thing by its ID under it. Keep verbs out of paths.
Use each method for what it means
API-2Read with GET, create with POST, replace with PUT, change part with PATCH and remove with DELETE. GET and HEAD never change stored data.
Answer with the right status code
API-3Pick the status code that matches what happened. Never answer 200 with an error inside the body.
Return 405 with the allowed methods
API-4When a path exists but the method doesn't apply, answer 405 and list what works in the
Allowheader.Keep addresses stable
API-5Never change what an address means once clients use it. Add new addresses instead.
Return a result for each item in a batch
API-91Give each batch endpoint a written item limit, and say whether it is all or nothing. Return one result per item, in request order, with its own status and error.
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/resources-and-methods">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.