A unique identifier distinguishes a resource within the scope in which it must be found. In an API, an ID, reference, or code can serve this role. A collection path such as /products names a list; adding an identifier, as in /products/123456, identifies one product. The collection name gives the path meaning, while the identifier distinguishes its element. section 4.2.3 section 4.2.5
Identify a product, not a search preference
GET /products/123456 reads a product; PUT or PATCH at that path updates it, and DELETE removes it. If the product does not exist, these operations need a 404 Not Found response. By contrast, a category reference used to narrow GET /products results is a query-parameter filter: products can still be searched without it. The same category reference could be a path parameter when identifying a category itself. section 4.4.3 section 4.4.6 section 4.9
Choose each input’s location by the job it does:
- Put identifiers needed to identify the operation’s resource in path parameters. Keep create or update representations in the body, and put optional result modifiers in query parameters unless a standard HTTP header fits. section 4.4.7
- Keep collection and element paths consistent: /accounts and /accounts/{accountId} let consumers construct an element path from its collection path. section 9.3.2
- Question a required filter. If GET /transactions requires accountId to mean one account’s transactions, GET /accounts/{accountId}/transactions expresses that resource directly. section 9.6.4
How unique is unique?
A globally unique transaction ID makes /transactions/{transactionId} sufficient; repeating customer and account IDs would lengthen the path without helping identify the transaction. An address ID such as home is different: it is not globally unique, so /customers/{customerId}/addresses/{addressId} needs both IDs. Shorten a path only when it still identifies the intended resource accurately. section 9.3.3
Figure 9.3 We question user needs and use globally unique IDs to reduce the number of path parameters in the Banking API resources paths and make them easier to use.
Compare the banking paths to see which parent identifiers can be removed when a child ID is globally unique. section 9.3.3
An identifier also belongs in the resource’s data model alongside its business properties. A generic property name such as id can make that property immediately recognizable across resources, but naming and ID-format decisions still need reasoning and consumer input. As a design check, take one resource path, remove each parent ID in turn, and ask whether the remaining path still identifies exactly the intended resource. Do not impose one ID format on every resource without examining its needs. section 5.2.2 section 16.1.5 section 16.12








