# Update references

This API is responsible for updating an annotation`s references.

<p class="callout info">**\[PUT\]/api/v1/annotations/{id}/{operation}**</p>

**Response:** The id of the updated annotation.

### Header

Header used on this API are those taken from <span style="color: #3366ff;">[header standards of TS Digital.](https://digital-docs.ts-paas.com/books/utilizzo-api-tsdigital/page/linee-guida-generali-api-ts-digital)</span>

`Content-type` is accepted in `application/json`

### Query Parameters

Parameters used to make a successful request.

- **id**: Unique identifier associated with the requested annotation. (<span style="color: #ff0000;">***required***</span>)
- **operation**: it can be **ATTACH** in case there need to be added references and **DETACH** in case the references need to be removed. (<span style="color: #ff0000;">***required***</span>)

### Body

```JSON
{
  "reference_ids": [
    "string"
  ]
}
```

- **reference\_ids**: the ids of the related documents to be added or removed

### Response

##### On successful response

If successful, the **API** responds with HTTP code **200(OK)** with the following body:

```JSON
{
  "id": "string"
}
```

- **id**: the unique identifier of the annotation

##### On error response

In the event of an error, the **API** responds with a body **JSON** with the following format:

```JSON
{
  "code": "string",
  "timestamp": "2022-10-28T13:01:00.754Z",
  "message": "string",
  "subErrors": [
    {}
  ]
}
```

- **code**: A string representation of the HTTP error code, linked with the returned http error
- **timestamp**: Date and time of the answer, expressed as a string.
- **message**: Message expressing error.

Possible errors are:

- **400**: The request is malformed (parameters with incorrect format, invalid or inconsistent parameters).
- **401**: An authorization token has not been provided or the authorization token provided is invalid (eg: it has expired).
- **403**: The provided token is valid, but the user is not authorized to perform the operation.
- **404**: No annotation found with the given id.
- **500**: An unexpected error occurred.