Skip to content

Commit 62ee1f6

Browse files
authored
Merge pull request #17 from sdatspun2/main
Draft 02 (wip)
2 parents 5fa4dd1 + 6f1c78c commit 62ee1f6

File tree

2 files changed

+767
-3
lines changed

2 files changed

+767
-3
lines changed

draft-ietf-httpapi-idempotency-key-header.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,55 @@ For each request, server SHOULD
141141

142142
## Error Scenarios
143143

144-
If the `Idempotency-Key` request header is missing for a documented idempotent operation requiring this header, the resource server SHOULD reply with an HTTP `400` status code with body containing a link pointing to relevant documentation. Alternately, using the HTTP header `Link`, the client can be informed about the error as shown below.
144+
If the `Idempotency-Key` request header is missing for a documented idempotent operation requiring this header, the resource server SHOULD reply with an HTTP `400` status code with body containing a link pointing to relevant documentation. Following examples shows an error response describing the problem using {{!RFC7807}}.
145+
146+
HTTP/1.1 400 Bad Request
147+
Content-Type: application/problem+json
148+
Content-Language: en
149+
{
150+
"type": "https://developer.example.com/idempotency",
151+
"title": "Idempotency-Key is missing",
152+
"detail": "This operation is idempotent and it requires correct usage of Idempotency Key.",
153+
}
154+
155+
Alternately, using the HTTP header `Link`, the client can be informed about the error as shown below.
145156

146157
HTTP/1.1 400 Bad Request
147158
Link: <https://developer.example.com/idempotency>;
148159
rel="describedby"; type="text/html"
149160

150-
If there is an attempt to reuse an idempotency key with a different request payload, the resource server SHOULD reply with a HTTP `422` status code with body containing a link pointing to relevant documentation. The status code `422` is defined in Section 11.2 of {{!RFC4918}}. The server can also inform the client by using the HTTP header `Link` as shown below.
161+
If there is an attempt to reuse an idempotency key with a different request payload, the resource server SHOULD reply with a HTTP `422` status code with body containing a link pointing to relevant documentation. The status code `422` is defined in Section 11.2 of {{!RFC4918}}.
162+
163+
164+
HTTP/1.1 422 Unprocessable Entity
165+
Content-Type: application/problem+json
166+
Content-Language: en
167+
{
168+
"type": "https://developer.example.com/idempotency",
169+
"title": "Idempotency-Key is already used",
170+
"detail": "This operation is idempotent and it requires correct usage of Idempotency Key. Idempotency Key MUST not be reused across different payloads of this operation.",
171+
}
172+
173+
174+
The server can also inform the client by using the HTTP header `Link` as shown below.
151175

152176
HTTP/1.1 422 Unprocessable Entity
153177
Link: <https://developer.example.com/idempotency>;
154178
rel="describedby"; type="text/html"
155179

156-
If the request is retried, while the original request is still being processed, the resource server SHOULD reply with an HTTP `409` status code with body containing a link or the HTTP header `Link` pointing to the relevant documentation.
180+
If the request is retried, while the original request is still being processed, the resource server SHOULD reply with an HTTP `409` status code with body containing problem description.
181+
182+
183+
HTTP/1.1 409 Conflict
184+
Content-Type: application/problem+json
185+
Content-Language: en
186+
{
187+
"type": "https://developer.example.com/idempotency",
188+
"title": "A request is outstanding for this Idempotency-Key",
189+
"detail": "A request with the same Idempotency-Key for the same operation is being processed or is outstanding.",
190+
}
191+
192+
Or, alternately using the HTTP header `Link` pointing to the relevant documentation
157193

158194
HTTP/1.1 409 Conflict
159195
Link: <https://developer.example.com/idempotency>;

0 commit comments

Comments
 (0)