Agent Wranglers

API-1Recommended

Name resources as plural nouns

Address each kind of thing as a plural noun, and each single thing by its ID under it. Keep verbs out of paths.

How to do it

Use paths such as /orders and /orders/{orderId}. Nest at most one level for things that belong to a parent, such as /orders/{orderId}/items. Use lowercase words joined by hyphens, and no trailing slash. When an action fits no method, model it as a sub-resource, such as POST /orders/{orderId}/cancellation. Once a path is public, keep it as Keep addresses stable says.

Examples

HTTP example

GET  /orders                       list orders
POST /orders                       create an order
GET  /orders/ord_8f2k              read one order
POST /orders/ord_8f2k/cancellation cancel it

Bad: POST /getOrders, POST /cancelOrder?id=8f2k

How to check

A linter such as Spectral passes on the OpenAPI file with three custom rules. Paths are lowercase with hyphens, no segment is a verb such as get or create, and no path nests deeper than one parent.

Sources

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/resource-names">Agent Wranglers API design playbook</a>. In code you write, add a comment next to it with the same link.