URLs are your API's user interface. A developer who has never read your docs should be able to guess that GET /api/customers/88/orders lists a customer's orders. In this lesson we cover the naming rules, hierarchy patterns, and judgment calls that produce intuitive, durable URL schemes.
The core REST idea: URLs identify things, and HTTP methods act on them. The moment a verb sneaks into a path, the design is drifting.
Good Avoid
GET /api/articles GET /api/getArticles
POST /api/articles POST /api/createArticle
DELETE /api/articles/12 GET /api/deleteArticle?id=12The right-hand column also has a real bug: performing a delete via GET means crawlers, prefetchers, and browser link previews can destroy data.
Nested paths express ownership: /customers/88/orders means orders belonging to customer 88. This is clear and self-documenting, but stop at one level of nesting. A path like /customers/88/orders/1042/items/3/product is fragile and forces callers to know the whole chain.
The standard escape hatch: once a resource has its own identity, promote it to a top-level collection. Order 1042 is globally unique, so expose /orders/1042 directly, and keep /customers/88/orders only as a filtered listing. Rule of thumb: nest for creation and listing within a parent, but fetch and mutate by direct ID.
Some operations resist the noun model: publishing an article, cancelling an order, resending an email. Two accepted patterns exist. Treat the action as a sub-resource with POST, like POST /orders/1042/cancellation, or pragmatically use a verb suffix as many large APIs do, like POST /articles/12/publish. Either is fine; inconsistency between the two across your API is not.
A content platform might expose:
GET /api/v1/authors list authors
POST /api/v1/authors create an author
GET /api/v1/authors/ana-roy one author by slug
GET /api/v1/authors/ana-roy/articles articles by that author
GET /api/v1/articles?status=draft all drafts across authors
PATCH /api/v1/articles/9f31 edit an article
POST /api/v1/articles/9f31/publish state transitionNotice how listing by owner uses nesting, cross-cutting queries use query parameters, and direct access uses top-level IDs. That trio covers nearly every need.
Whatever you choose, apply it everywhere. A style document with ten rules, enforced in code review, is worth more than any individual rule. Clients write wrappers around your URL patterns; every inconsistency becomes a special case in someone else's codebase forever.
Next up: Query Parameters, Filtering, Sorting and Pagination, where collections learn to scale.