@@ -19,7 +19,7 @@ collection is empty) or 404 (if the collection is missing)
1919* {GET} requests must NOT have a request body payload
2020
2121*Note:* {GET} requests on collection resources should provide sufficient
22- <<filter, #137 >> and <<pagination>> mechanisms.
22+ <<137, filter >> and <<pagination>> mechanisms.
2323
2424
2525[[get-with-body]]
@@ -54,7 +54,7 @@ settings. Thus, switching to headers does not solve the original problem.
5454=== PUT
5555
5656{PUT} requests are used to *update* (in rare cases to create) *entire*
57- resources - single or collection resources. The semantic is best described
57+ resources – single or collection resources. The semantic is best described
5858as _"please put the enclosed representation at the resource mentioned by
5959the URL, replacing any existing resource."_.
6060
@@ -66,7 +66,7 @@ implicitly creating before updating
6666addressed by the URL with the representation passed in the payload (subsequent
6767reads will deliver the same payload)
6868* successful {PUT} requests will usually generate 200 or 204 (if the resource
69- was updated - with or without actual content returned), and 201 (if the
69+ was updated – with or without actual content returned), and 201 (if the
7070resource was created)
7171
7272*Important:* It is best practice to prefer {POST} over {PUT} for creation of
@@ -95,9 +95,10 @@ identified by the URL"_.
9595
9696* on a successful {POST} request, the server will create one or multiple new
9797resources and provide their URI/URLs in the response
98- * successful {POST} requests will usually generate 200 (if resources have been
99- updated), 201 (if resources have been created), and 202 (if the request was
100- accepted but has not been finished yet)
98+ * successful {POST} requests will usually generate 200 (if resources have
99+ been updated), 201 (if resources have been created), 202 (if the request was
100+ accepted but has not been finished yet), and exceptionally 204 with {Location}
101+ header (if the actual resource is not returned).
101102
102103The semantic for single resource endpoints is best described as _"please
103104execute the given well specified request on the resource identified by the
@@ -246,24 +247,30 @@ lost updates, e.g. if same resources may be created or changed in parallel or
246247multiple times. To design an idempotent API owners should consider to apply
247248one of the following three patterns.
248249
249- * A client specific *idempotency key* provided as {Idempotency-Key} header
250- in the request. The key is not part of the resource but stored temporarily
251- pointing to the resource to ensure idempotent behavior when _re-sending_
252- a request from the same client - for some time (see <<230>>).
253- * A resource specific *secondary key* provided as resource property in the
254- request body. The _secondary key_ is stored permanently in the resource as
255- _alternate_ (or _unique foreign key_, if it links to an another - often
256- parent - resource, e.g. the shopping cart ID is a natural _unique foreign
257- key_ candidate for an order. It can be used to ensure idempotent request
258- behavior in case of multiple independent requests of clients.
259- * A resource specific *conditional key* provided as <<182,`If-Match` header>>
250+ * A resource specific *conditional key* provided via <<182,`If-Match` header>>
260251 in the request. The key is in general a meta information of the resource,
261252 e.g. a _hash_ or _version number_, often stored with it. It allows to detect
262253 concurrent creations and updates to ensure idempotent request behavior
263254 (see <<182>>).
255+ * A resource specific *secondary key* provided as resource property in the
256+ request body. The _secondary key_ is stored permanently in the resource as
257+ _alternate_ (or _unique foreign key_, if it links to an another – often
258+ parent – resource, e.g. the shopping cart ID is a natural _unique foreign
259+ key_ candidate for an order. It allows to ensure idempotent request behavior
260+ in case of multiple independent resource creations from different clients
261+ (see <<231>>).
262+ * A client specific *idempotency key* provided via {Idempotency-Key} header
263+ in the request. The key is not part of the resource but stored temporarily
264+ pointing to the original response to ensure idempotent response behavior
265+ when retrying a request (see <<230>>).
266+
267+ *Note:* While *conditional key* and *secondary key* are focused on handling
268+ concurrent requests, the *idempotency key* is focused on providing exact same
269+ responses and can be combined with the other patterns.
264270
265271To decide, which pattern is suitable for your use case, please consult the
266- following table showing the major properties of each pattern:
272+ following table showing the major properties of each pattern. As far as this
273+ patterns can be applied to {PUT} we added it to allow full comparison:
267274
268275[,cols="40%,20%,20%,20%",options="header",]
269276|========================================================================================
@@ -279,6 +286,14 @@ following table showing the major properties of each pattern:
279286(before {PUT}/{POST}/{PATCH}) | {YES} | {YES} | {NO}
280287|========================================================================================
281288
289+ If you mainly aim to support safe retries, we suggest to apply <<182,
290+ conditional key>> and <<231,secondary key>> pattern before the <<230,
291+ Idempotency Key>> pattern.
292+
293+ [#231]
294+ == {MAY} Use Secondary Key for Idempotent `POST`
295+
296+
282297[#154]
283298== {SHOULD} Define Collection Format of Query Parameters and Headers
284299
0 commit comments