**Description**
PUT entities/items/{item_id}/sitelinks/{site_id}
Request payload:
```
{
"sitelink": {
"title": ...,
"badges": [ Q-ID, ... ] (optional)
},
"comment": ... (optional)
"tags": [ ... ] (optional)
"bot": false (optional)
}
```
**Acceptance criteria:**
- The respective successful responses should present the relevant data as a JSON object -- similar to the responses of GET /entities/items/{item_id}/sitelinks/{site_id}.
- If a sitelink in the given wiki didn't exist before the successful request the response should use 201 code.
- If the request changed the existing sitelink, the response code should be 200.
**Error cases to consider**
<table>
<tr>
<th>
</th>
<th>HTTP response code</th>
<th>response payload</th>
</tr>
<tr>
<td>Item does not exist </td>
<td>404</td>
<td>
`"code": "item-not-found"`
`"message": "Could not find an item with the ID: {item_id}"`
</td>
</tr>
<tr>
<td>Invalid item ID </td>
<td>400</td>
<td>
`"code": "invalid-item-id"`
`"message": "Not a valid item ID: {item_id}"`
`"context": {"item": "{item-id}"}`
</td>
</tr>
<tr>
<td>Invalid site ID </td>
<td>400</td>
<td>
`{ "code": "invalid-site-id", "message": "Not a valid site ID: {site_ID}"}`
</td>
</tr>
<tr>
<td>Invalid edit tag</td>
<td>400</td>
<td>
`{ "code": "invalid-edit-tag", "message": "Invalid MediaWiki tag: {tag}" }`
</td>
</tr>
<tr>
<td>Comment too long</td>
<td>400</td>
<td>
`{"code": "comment-too-long", "message": "Comment must not be longer than {limit} characters"}`
</td>
</tr>
<tr>
<td>sitelink title field not provided</td>
<td>400</td>
<td>
`{ "code": "sitelink-data-missing-field", "message": "Mandatory field missing in the sitelink data: {field}", "context": { "path": "{field}"}}`
</td>
</tr>
<tr>
<td>title is empty</td>
<td>400</td>
<td> `{"code": "title-field-empty", "message": "Title must not be empty"}`
</td>
</tr>
<tr>
<td>Invalid title</td>
<td>400</td>
<td> `{"code": "invalid-title-field", "message": "Not a valid input for title field'"}`
</tr>
<tr>
<td>value provided as a badge is not an item ID</td>
<td>400</td>
<td>`{"code": "invalid-input-sitelink-badge", "message": "Badge input is not an item ID'"}`
</td>
</tr>
<tr>
<td>item provided is not allowed as a site link badge </td>
<td>400</td>
<td>`{"code": "item-not-a-badge", "message": "Item ID provided as badge input is not allowed as a badge"}`
</td>
</tr>
<tr>
<td>value of badges field is not a list</td>
<td>400</td>
<td>`{"code": "invalid-sitelink-badge-format", "message": "Badge field is not a list" }`
</td>
<tr>
<td>Title does not exist on given sitelink</td>
<td>400</td>
<td>`{"code": "title-does-not-exist", "message": "Titel does not exist on given sitelink " }`</td>
</tr>
<tr>
<td>Item redirect</td>
<td>409</td>
<td>
`{"code": "redirected-item", "message": "Item {item_id} has been merged into {other_id}"}`
</td>
</tr>
</table>
**Notes**
- Automated edit summaries to be of the form:
- if the edit resulted in adding a site link to a wiki which was not connected before, and no badges: `/* wbsetsitelink-add:1|SITE_ID */ TITLE`
- if the edit resulted in adding a site link to a wiki which was not connected before, and there are badges: `/* wbsetsitelink-add-both:2|SITE_ID */ TITLE, BADGE_ITEMS_FORMATTED`
- if the edit resulted in setting a title to a different page on a wiki which has been connected as a site link before, and there are no badges: `/* wbsetsitelink-set:1|SITE_ID */ TITLE`
- if the edit resulted in setting a title to a different page on a wiki which has been connected as a site link before, and there are badges: `/* wbsetsitelink-set-both:2|SITE_ID */ TITLE, BADGE_ITEMS_FORMATTED`
- if the edit resulted in changes badges of an existing sitelink (and not change the title): `/* wbsetsitelink-set-badges:1|SITE_ID */ BADGE_ITEMS_FORMATTED`
- where BADGE_ITEMS_FORMATTED is a comma-separated list of wikitext links to item pages
- see `Wikibase\Repo\ChangeOp\ChangeOpSiteLink` class, and surrounding classes, for further details of the existing Wikibase automated edit summary logic
- client can provide additional edit metadata: mediawiki tags, edit summary text to append to the automated summary, and a bot edit flag, like in GET /entities/items/{item_id}/labels/{language_code}
- Handle HTTP conditional request headers as in PUT /entities/items/{item_id}/statements
- Handle user authentication/authorization like in PUT /entities/items/{item_id}/statements
**Additional notes:**
How Action API handles it: https://www.wikidata.org/w/api.php?action=help&modules=wbsetsitelink