@@ -1531,17 +1531,15 @@ to create a resource with a client-generated ID.
1531
1531
1532
1532
##### <a href =" #crud-creating-responses-201 " id =" crud-creating-responses-201 " class =" headerlink " ></a > 201 Created
1533
1533
1534
- If a ` POST ` request did not include a [ Client-Generated
1535
- ID] ( #crud-creating-client-ids ) and the requested resource has been created
1536
- successfully, the server ** MUST** return a ` 201 Created ` status code.
1534
+ If the requested resource has been created successfully and the server changes
1535
+ the resource in any way (for example, by assigning an ` id ` ), the server ** MUST**
1536
+ return a ` 201 Created ` response and a document that contains the resource as
1537
+ primary data.
1537
1538
1538
1539
The response ** SHOULD** include a ` Location ` header identifying the location
1539
1540
of the newly created resource, in order to comply with [ RFC
1540
1541
7231] ( http://tools.ietf.org/html/rfc7231#section-6.3.2 ) .
1541
1542
1542
- The response ** MUST** also include a document that contains the primary
1543
- resource created.
1544
-
1545
1543
If the [ resource object] [ resource objects ] returned by the response contains a ` self ` key in its
1546
1544
` links ` member and a ` Location ` header is provided, the value of the ` self `
1547
1545
member ** MUST** match the value of the ` Location ` header.
@@ -1566,6 +1564,15 @@ Content-Type: application/vnd.api+json
1566
1564
}
1567
1565
```
1568
1566
1567
+ A server ** MAY** return a ` 201 Created ` response with a document that contains
1568
+ no primary data if the requested resource has been created successfully and the
1569
+ server does not change the resource in any way (for example, by assigning an
1570
+ ` id ` or ` createdAt ` attribute). Other top-level members, such as [ meta] , could
1571
+ be included in the response document.
1572
+
1573
+ > Note: Only servers that accept [ Client-Generated
1574
+ IDs] ( #crud-creating-client-ids ) can avoid assigning an ` id ` to a new resource.
1575
+
1569
1576
##### <a href =" #crud-creating-responses-202 " id =" crud-creating-responses-202 " class =" headerlink " ></a > 202 Accepted
1570
1577
1571
1578
If a request to create a resource has been accepted for processing, but the
@@ -1574,15 +1581,11 @@ server **MUST** return a `202 Accepted` status code.
1574
1581
1575
1582
##### <a href =" #crud-creating-responses-204 " id =" crud-creating-responses-204 " class =" headerlink " ></a > 204 No Content
1576
1583
1577
- If a ` POST ` request * did* include a [ Client-Generated
1578
- ID] ( #crud-creating-client-ids ) and the requested resource has been created
1579
- successfully, the server ** MUST** return either a ` 201 Created ` status code
1580
- and response document (as described above) or a ` 204 No Content ` status code
1581
- with no response document.
1582
-
1583
- > Note: If a ` 204 ` response is received the client should consider the resource
1584
- object sent in the request to be accepted by the server, as if the server
1585
- had returned it back in a ` 201 ` response.
1584
+ If the requested resource has been created successfully and the server does not
1585
+ change the resource in any way (for example, by assigning an ` id ` or ` createdAt `
1586
+ attribute), the server ** MUST** return either a ` 201 Created ` status code and
1587
+ response document (as described above) or a ` 204 No Content ` status code with no
1588
+ response document.
1586
1589
1587
1590
##### <a href =" #crud-creating-responses-403 " id =" crud-creating-responses-403 " class =" headerlink " ></a > 403 Forbidden
1588
1591
@@ -1745,31 +1748,30 @@ does not want to allow deletion of records the client has not seen.
1745
1748
1746
1749
#### <a href =" #crud-updating-responses " id =" crud-updating-responses " class =" headerlink " ></a > Responses
1747
1750
1751
+ ##### <a href =" #crud-updating-responses-200 " id =" crud-updating-responses-200 " class =" headerlink " ></a > 200 OK
1752
+
1753
+ If a server accepts an update but also changes the targeted resource(s) in ways
1754
+ other than those specified by the request (for example, updating the
1755
+ ` updatedAt ` attribute or a computed ` sha ` ), it ** MUST** return a ` 200 OK `
1756
+ response and a document that contains the updated resource(s) as primary data.
1757
+
1758
+ A server ** MAY** return a ` 200 OK ` response with a document that contains no
1759
+ primary data if an update is successful and the server does not change the
1760
+ targeted resource(s) in ways other than those specified by the request. Other
1761
+ top-level members, such as [ meta] , could be included in the response document.
1762
+
1748
1763
##### <a href =" #crud-updating-responses-202 " id =" crud-updating-responses-202 " class =" headerlink " ></a > 202 Accepted
1749
1764
1750
1765
If an update request has been accepted for processing, but the processing
1751
1766
has not been completed by the time the server responds, the server ** MUST**
1752
1767
return a ` 202 Accepted ` status code.
1753
1768
1754
- ##### <a href =" #crud-updating-responses-200 " id =" crud-updating-responses-200 " class =" headerlink " ></a > 200 OK
1755
-
1756
- If a server accepts an update but also changes the resource(s) in ways other
1757
- than those specified by the request (for example, updating the ` updated-at `
1758
- attribute or a computed ` sha ` ), it ** MUST** return a ` 200 OK ` response. The
1759
- response document ** MUST** include a representation of the updated
1760
- resource(s) as if a ` GET ` request was made to the request URL.
1761
-
1762
- A server ** MUST** return a ` 200 OK ` status code if an update is successful,
1763
- the client's current fields remain up to date, and the server responds only
1764
- with top-level [ meta] data. In this case the server ** MUST NOT** include a
1765
- representation of the updated resource(s).
1766
-
1767
1769
##### <a href =" #crud-updating-responses-204 " id =" crud-updating-responses-204 " class =" headerlink " ></a > 204 No Content
1768
1770
1769
- If an update is successful and the server doesn't update any fields besides
1770
- those provided, the server ** MUST ** return either a ` 200 OK ` status code and
1771
- response document (as described above) or a ` 204 No Content ` status code with no
1772
- response document.
1771
+ If an update is successful and the server doesn't change the targeted
1772
+ resource(s) in ways other than those specified by the request, the server
1773
+ ** MUST ** return either a ` 200 OK ` status code and response document (as
1774
+ described above) or a ` 204 No Content ` status code with no response document.
1773
1775
1774
1776
##### <a href =" #crud-updating-relationship-responses-403 " id =" crud-updating-relationship-responses-403 " class =" headerlink " ></a > 403 Forbidden
1775
1777
@@ -1968,6 +1970,18 @@ server, and we are defining its semantics for JSON:API.
1968
1970
1969
1971
#### <a href =" #crud-updating-relationship-responses " id =" crud-updating-relationship-responses " class =" headerlink " ></a > Responses
1970
1972
1973
+ ##### <a href =" #crud-updating-relationship-responses-200 " id =" crud-updating-relationship-responses-200 " class =" headerlink " ></a > 200 OK
1974
+
1975
+ If a server accepts an update but also changes the targeted relationship in
1976
+ other ways than those specified by the request, it ** MUST** return a ` 200 OK `
1977
+ response and a document that includes the updated relationship data as its
1978
+ primary data.
1979
+
1980
+ A server ** MAY** return a ` 200 OK ` response with a document that contains no
1981
+ primary data if an update is successful and the server does not change the
1982
+ targeted relationship in ways other than those specified by the request. Other
1983
+ top-level members, such as [ meta] , could be included in the response document.
1984
+
1971
1985
##### <a href =" #crud-updating-relationship-responses-202 " id =" crud-updating-relationship-responses-202 " class =" headerlink " ></a > 202 Accepted
1972
1986
1973
1987
If a relationship update request has been accepted for processing, but the
@@ -1976,28 +1990,17 @@ server **MUST** return a `202 Accepted` status code.
1976
1990
1977
1991
##### <a href =" #crud-updating-relationship-responses-204 " id =" crud-updating-relationship-responses-204 " class =" headerlink " ></a > 204 No Content
1978
1992
1979
- A server ** MUST** return a ` 204 No Content ` status code if an update is
1980
- successful and the representation of the resource in the request matches the
1981
- result.
1993
+ If an update is successful and the server doesn't change the targeted
1994
+ relationship in ways other than those specified by the request, the server
1995
+ ** MUST** return either a ` 200 OK ` status code and response document (as
1996
+ described above) or a ` 204 No Content ` status code with no response document.
1982
1997
1983
1998
> Note: This is the appropriate response to a ` POST ` request sent to a URL
1984
1999
from a to-many [ relationship link] [ relationships ] when that relationship already
1985
2000
exists. It is also the appropriate response to a ` DELETE ` request sent to a URL
1986
2001
from a to-many [ relationship link] [ relationships ] when that relationship does
1987
2002
not exist.
1988
2003
1989
- ##### <a href =" #crud-updating-relationship-responses-200 " id =" crud-updating-relationship-responses-200 " class =" headerlink " ></a > 200 OK
1990
-
1991
- If a server accepts an update but also changes the targeted relationship(s)
1992
- in other ways than those specified by the request, it ** MUST** return a `200
1993
- OK` response. The response document ** MUST** include a representation of the
1994
- updated relationship(s).
1995
-
1996
- A server ** MUST** return a ` 200 OK ` status code if an update is successful,
1997
- the client's current data remain up to date, and the server responds
1998
- only with top-level [ meta] data. In this case the server ** MUST NOT**
1999
- include a representation of the updated relationship(s).
2000
-
2001
2004
##### <a href =" #crud-updating-relationship-responses-403 " id =" crud-updating-relationship-responses-403 " class =" headerlink " ></a > 403 Forbidden
2002
2005
2003
2006
A server ** MUST** return ` 403 Forbidden ` in response to an unsupported request
@@ -2025,6 +2028,12 @@ Accept: application/vnd.api+json
2025
2028
2026
2029
#### <a href =" #crud-deleting-responses " id =" crud-deleting-responses " class =" headerlink " ></a > Responses
2027
2030
2031
+ ##### <a href =" #crud-deleting-responses-200 " id =" crud-deleting-responses-200 " class =" headerlink " ></a > 200 OK
2032
+
2033
+ A server ** MAY** return a ` 200 OK ` response with a document that contains no
2034
+ primary data if a deletion request is successful. Other top-level members, such
2035
+ as [ meta] , could be included in the response document.
2036
+
2028
2037
##### <a href =" #crud-deleting-responses-202 " id =" crud-deleting-responses-202 " class =" headerlink " ></a > 202 Accepted
2029
2038
2030
2039
If a deletion request has been accepted for processing, but the processing has
@@ -2033,13 +2042,9 @@ return a `202 Accepted` status code.
2033
2042
2034
2043
##### <a href =" #crud-deleting-responses-204 " id =" crud-deleting-responses-204 " class =" headerlink " ></a > 204 No Content
2035
2044
2036
- A server ** MUST** return a ` 204 No Content ` status code if a deletion
2037
- request is successful and no content is returned.
2038
-
2039
- ##### <a href =" #crud-deleting-responses-200 " id =" crud-deleting-responses-200 " class =" headerlink " ></a > 200 OK
2040
-
2041
- A server ** MUST** return a ` 200 OK ` status code if a deletion request is
2042
- successful and the server responds with only top-level [ meta] data.
2045
+ If a deletion request is successful, the server ** MUST** return either a `200
2046
+ OK` status code and response document (as described above) or a ` 204 No Content`
2047
+ status code with no response document.
2043
2048
2044
2049
##### <a href =" #crud-deleting-responses-404 " id =" crud-deleting-responses-404 " class =" headerlink " ></a > 404 NOT FOUND
2045
2050
0 commit comments