Skip to content

Interactions

Every resource exposes a set of interactions. Only the ones a feature requires need to be implemented.

A POST to a collection resource creates a new individual within it. On success, the server returns 201 Created with the new resource in the response body and a Location header pointing to its path. If creation is asynchronous, the server returns 202 Accepted with a workflow identifier in the response body.

POST /players HTTP/1.1
Content-Type: application/json
{
"name": "Smilla",
"surname": "Holmberg",
"position": "RB"
}
HTTP/1.1 201 Created
Content-Type: application/json
Location: /players/23c1221d-8d1e-4d71-9a8a-ab3e9bff8025
{
"id": "23c1221d-8d1e-4d71-9a8a-ab3e9bff8025",
"name": "Smilla",
"surname": "Holmberg",
"position": "RB"
}

A GET to a collection resource retrieves all individuals within it. A GET to an individual resource retrieves that single item. Both return 200 OK on success.

GET /players HTTP/1.1
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": "8a9839e7-da35-4438-9dba-1d3ff0b4171b",
"name": "Caroline",
"surname": "Seger",
"position": "CM"
},
{
"id": "c8bf1fdf-152f-46c0-8679-0e5c8d33b404",
"name": "Linda",
"surname": "Sembrant",
"position": "CB"
},
{
"id": "2044c763-91f3-4c49-928a-037444d36111",
"name": "Fridolina",
"surname": "Rolfö",
"position": "LB"
},
{
"id": "23c1221d-8d1e-4d71-9a8a-ab3e9bff8025",
"name": "Smilla",
"surname": "Holmberg",
"position": "RB"
}
]

A PUT to an individual resource replaces it entirely with the provided data. On success, the server returns 200 OK with the replaced resource in the response body.

PUT /players/c8bf1fdf-152f-46c0-8679-0e5c8d33b404 HTTP/1.1
Content-Type: application/json
{
"name": "Bella",
"surname": "Andersson",
"position": "CB"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "c8bf1fdf-152f-46c0-8679-0e5c8d33b404",
"name": "Bella",
"surname": "Andersson",
"position": "CB"
}

A PATCH to an individual resource applies a partial update, changing only the fields included in the request body. On success, the server returns 200 OK with the updated resource in the response body.

PATCH /players/2044c763-91f3-4c49-928a-037444d36111 HTTP/1.1
Content-Type: application/json
{
"position": "LW"
}
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "2044c763-91f3-4c49-928a-037444d36111",
"name": "Fridolina",
"surname": "Rolfö",
"position": "LW"
}

A DELETE to an individual resource removes it. On success, the server returns 204 No Content with no response body.

DELETE /players/8a9839e7-da35-4438-9dba-1d3ff0b4171b HTTP/1.1
HTTP/1.1 204 No Content