@@ -29,14 +29,14 @@ We welcome [contributions](CONTRIBUTING.md) to this guide.
29
29
* [ Provide Request-Ids for Introspection] ( #provide-request-ids-for-introspection )
30
30
* [ Divide Large Responses Across Requests with Ranges] ( #divide-large-responses-across-requests-with-ranges )
31
31
* [ Requests] ( #requests )
32
- * [ Return appropriate status codes] ( #return-appropriate-status-codes )
33
- * [ Provide full resources where available] ( #provide-full-resources-where-available )
34
32
* [ Accept serialized JSON in request bodies] ( #accept-serialized-json-in-request-bodies )
35
33
* [ Use consistent path formats] ( #use-consistent-path-formats )
36
34
* [ Downcase paths and attributes] ( #downcase-paths-and-attributes )
37
35
* [ Support non-id dereferencing for convenience] ( #support-non-id-dereferencing-for-convenience )
38
36
* [ Minimize path nesting] ( #minimize-path-nesting )
39
37
* [ Responses] ( #responses )
38
+ * [ Return appropriate status codes] ( #return-appropriate-status-codes )
39
+ * [ Provide full resources where available] ( #provide-full-resources-where-available )
40
40
* [ Provide resource (UU)IDs] ( #provide-resource-uuids )
41
41
* [ Provide standard timestamps] ( #provide-standard-timestamps )
42
42
* [ Use UTC times formatted in ISO8601] ( #use-utc-times-formatted-in-iso8601 )
@@ -120,71 +120,6 @@ ordering, and iteration.
120
120
121
121
### Requests
122
122
123
- #### Return appropriate status codes
124
-
125
- Return appropriate HTTP status codes with each response. Successful
126
- responses should be coded according to this guide:
127
-
128
- * ` 200 ` : Request succeeded for a ` GET ` call, for a ` DELETE ` or
129
- ` PATCH ` call that completed synchronously, or for a ` PUT ` call that
130
- synchronously updated an existing resource
131
- * ` 201 ` : Request succeeded for a ` POST ` call that completed
132
- synchronously, or for a ` PUT ` call that synchronously created a new
133
- resource
134
- * ` 202 ` : Request accepted for a ` POST ` , ` PUT ` , ` DELETE ` , or ` PATCH ` call that
135
- will be processed asynchronously
136
- * ` 206 ` : Request succeeded on ` GET ` , but only a partial response
137
- returned: see [ above on ranges] ( #divide-large-responses-across-requests-with-ranges )
138
-
139
- Pay attention to the use of authentication and authorization error codes:
140
-
141
- * ` 401 Unauthorized ` : Request failed because user is not authenticated
142
- * ` 403 Forbidden ` : Request failed because user does not have authorization to access a specific resource
143
-
144
- Return suitable codes to provide additional information when there are errors:
145
-
146
- * ` 422 Unprocessable Entity ` : Your request was understood, but contained invalid parameters
147
- * ` 429 Too Many Requests ` : You have been rate-limited, retry later
148
- * ` 500 Internal Server Error ` : Something went wrong on the server, check status site and/or report the issue
149
-
150
- Refer to the [ HTTP response code spec] ( https://tools.ietf.org/html/rfc7231#section-6 )
151
- for guidance on status codes for user error and server error cases.
152
-
153
- #### Provide full resources where available
154
-
155
- Provide the full resource representation (i.e. the object with all
156
- attributes) whenever possible in the response. Always provide the full
157
- resource on 200 and 201 responses, including ` PUT ` /` PATCH ` and ` DELETE `
158
- requests, e.g.:
159
-
160
- ``` bash
161
- $ curl -X DELETE \
162
- https://service.com/apps/1f9b/domains/0fd4
163
-
164
- HTTP/1.1 200 OK
165
- Content-Type: application/json; charset=utf-8
166
- ...
167
- {
168
- " created_at" : " 2012-01-01T12:00:00Z" ,
169
- " hostname" : " subdomain.example.com" ,
170
- " id" : " 01234567-89ab-cdef-0123-456789abcdef" ,
171
- " updated_at" : " 2012-01-01T12:00:00Z"
172
- }
173
- ```
174
-
175
- 202 responses will not include the full resource representation,
176
- e.g.:
177
-
178
- ``` bash
179
- $ curl -X DELETE \
180
- https://service.com/apps/1f9b/dynos/05bd
181
-
182
- HTTP/1.1 202 Accepted
183
- Content-Type: application/json; charset=utf-8
184
- ...
185
- {}
186
- ```
187
-
188
123
#### Accept serialized JSON in request bodies
189
124
190
125
Accept serialized JSON on ` PUT ` /` PATCH ` /` POST ` request bodies, either
@@ -284,6 +219,71 @@ case above where a dyno belongs to an app belongs to an org:
284
219
285
220
### Responses
286
221
222
+ #### Return appropriate status codes
223
+
224
+ Return appropriate HTTP status codes with each response. Successful
225
+ responses should be coded according to this guide:
226
+
227
+ * ` 200 ` : Request succeeded for a ` GET ` call, for a ` DELETE ` or
228
+ ` PATCH ` call that completed synchronously, or for a ` PUT ` call that
229
+ synchronously updated an existing resource
230
+ * ` 201 ` : Request succeeded for a ` POST ` call that completed
231
+ synchronously, or for a ` PUT ` call that synchronously created a new
232
+ resource
233
+ * ` 202 ` : Request accepted for a ` POST ` , ` PUT ` , ` DELETE ` , or ` PATCH ` call that
234
+ will be processed asynchronously
235
+ * ` 206 ` : Request succeeded on ` GET ` , but only a partial response
236
+ returned: see [ above on ranges] ( #divide-large-responses-across-requests-with-ranges )
237
+
238
+ Pay attention to the use of authentication and authorization error codes:
239
+
240
+ * ` 401 Unauthorized ` : Request failed because user is not authenticated
241
+ * ` 403 Forbidden ` : Request failed because user does not have authorization to access a specific resource
242
+
243
+ Return suitable codes to provide additional information when there are errors:
244
+
245
+ * ` 422 Unprocessable Entity ` : Your request was understood, but contained invalid parameters
246
+ * ` 429 Too Many Requests ` : You have been rate-limited, retry later
247
+ * ` 500 Internal Server Error ` : Something went wrong on the server, check status site and/or report the issue
248
+
249
+ Refer to the [ HTTP response code spec] ( https://tools.ietf.org/html/rfc7231#section-6 )
250
+ for guidance on status codes for user error and server error cases.
251
+
252
+ #### Provide full resources where available
253
+
254
+ Provide the full resource representation (i.e. the object with all
255
+ attributes) whenever possible in the response. Always provide the full
256
+ resource on 200 and 201 responses, including ` PUT ` /` PATCH ` and ` DELETE `
257
+ requests, e.g.:
258
+
259
+ ``` bash
260
+ $ curl -X DELETE \
261
+ https://service.com/apps/1f9b/domains/0fd4
262
+
263
+ HTTP/1.1 200 OK
264
+ Content-Type: application/json; charset=utf-8
265
+ ...
266
+ {
267
+ " created_at" : " 2012-01-01T12:00:00Z" ,
268
+ " hostname" : " subdomain.example.com" ,
269
+ " id" : " 01234567-89ab-cdef-0123-456789abcdef" ,
270
+ " updated_at" : " 2012-01-01T12:00:00Z"
271
+ }
272
+ ```
273
+
274
+ 202 responses will not include the full resource representation,
275
+ e.g.:
276
+
277
+ ``` bash
278
+ $ curl -X DELETE \
279
+ https://service.com/apps/1f9b/dynos/05bd
280
+
281
+ HTTP/1.1 202 Accepted
282
+ Content-Type: application/json; charset=utf-8
283
+ ...
284
+ {}
285
+ ```
286
+
287
287
#### Provide resource (UU)IDs
288
288
289
289
Give each resource an ` id ` attribute by default. Use UUIDs unless you
0 commit comments