> For the complete documentation index, see [llms.txt](https://alphamoon.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alphamoon.gitbook.io/documentation/api/metadata/setting-metadata-value.md).

# Setting metadata value

Learn how to update the collection using the Alphamoon's API

Alphamoon's API lets you update collections with metadata in just a few clicks.

Let's say you want to indicate that the given collection has already been printed. In this case, you can use the endpoint below to include such information in the server response:

### Update collection by ID

{% hint style="info" %}
This endpoint only allows you to edit the metadata of the collection. You can read more about metadata [here](/documentation/api/metadata.md).
{% endhint %}

<mark style="color:green;">`PATCH`</mark> `/api/v0.3/collections/{collection_id}`

\
**Path parameters**

| Name                                             | Type   | Description                        |
| ------------------------------------------------ | ------ | ---------------------------------- |
| collection\_id<mark style="color:red;">\*</mark> | String | The ID of the selected collection. |

You can get the **collection\_id** from:

* [Upload a file](/documentation/api/upload-file.md) endpoint (Base64 or Binary)
* Get collections endpoint
* URL\
  **e.g.** <https://workspace.alphamoon.ai/supervision/**223742cc9bca43fd81b2d41b0018e4c7>\*\*

**Request body**<mark style="color:red;">**\***</mark>

Add your metadata in the request body. For the purposes of this tutorial, let's stick with the printing example. Our metadata will be as follows:

```json
{
  "metadata": {"printed": "yes"}
}
```

{% tabs %}
{% tab title="200: OK Successful response" %}

```json
{
  "id": "191719e01ae84f02993168ef95be3c49",
  "name": "Invoice example.pdf",
  "files": [
    {
      "id": "0164f04d3a1e4138b73bb84695395871",
      "collectionId": "191719e01ae84f02993168ef95be3c49",
      "name": "Invoice example.pdf",
      "status": "Accepted",
      "progress": 100,
      "numberOfPages": 1,
      "createdAt": "2024-04-15T15:03:38Z",
      "updatedAt": "2024-04-16T12:29:07Z",
      "metadata": {}
    }
  ],
  "priority": false,
  "split": false,
  "status": "Accepted",
  "progress": 100,
  "numberOfPages": 1,
  "processId": "93580f176efb48cda64f25cba74d8ca4",
  "createdAt": "2024-04-15T15:03:38Z",
  "updatedAt": "2024-04-29T12:07:54Z",
  "metadata": {
    "printed": "yes"
  },
  "availableForTraining": true,
  "duplicates": []
}
```

{% endtab %}

{% tab title="400: Bad request" %}

```json
{
  "action": "The client should not repeat this request without modification.",
  "detail": "Please see the 'errors' field for details.",
  "errors": [
    {
      "location": "body: priority",
      "message": "field required",
      "type": "request_validation_error"
    }
  ],
  "instance": "30e18f59-7c88-4e25-9bed-61863b2abf4b",
  "status": 400,
  "timestamp": "2021-11-09T17:43:36Z",
  "title": "The server cannot process the request due to a client error.",
  "type": "RequestValidationError"
}
```

{% endtab %}

{% tab title="422: Validation error" %}

```json
{
  "detail": [
    {
      "loc": [
        "string",
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

**See the example:**

{% tabs %}
{% tab title="API call" %}

```bash
curl -X 'PATCH' \
  'https://workspace.alphamoon.ai/api/v0.3/collections/191719e01ae84f02993168ef95be3c49' \
  -H 'accept: application/json' \
  -H 'Authorization: Basic API_KEY_BASE64_ENCODED' \
  -H 'Content-Type: application/json' \
  -d '{
  "metadata": {"printed": "yes"}
}'
```

{% endtab %}

{% tab title="Server response" %}

```json
{
  "id": "191719e01ae84f02993168ef95be3c49",
  "name": "Invoice example.pdf",
  "files": [
    {
      "id": "0164f04d3a1e4138b73bb84695395871",
      "collectionId": "191719e01ae84f02993168ef95be3c49",
      "name": "Invoice example.pdf",
      "status": "Accepted",
      "progress": 100,
      "numberOfPages": 1,
      "createdAt": "2024-04-15T15:03:38Z",
      "updatedAt": "2024-04-16T12:29:07Z",
      "metadata": {}
    }
  ],
  "priority": false,
  "split": false,
  "status": "Accepted",
  "progress": 100,
  "numberOfPages": 1,
  "processId": "93580f176efb48cda64f25cba74d8ca4",
  "createdAt": "2024-04-15T15:03:38Z",
  "updatedAt": "2024-04-29T12:07:54Z",
  "metadata": {
    "printed": "yes"
  },
  "availableForTraining": true,
  "duplicates": []
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Go to the [Metadata](/documentation/api/metadata.md) tab to learn more.
{% endhint %}

**See next:**
