# Update conversation metadata

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Replace all metadata of a local conversation.

```text
POST https://token.moi.matrixorigin.cn/v1/conversations/{conversation_id}
```

## Before you begin

1. Prepare a [personal access token](../../../../guides/billing/credentials.md#personal-access-token) with Genesis access.
2. Use the credential used to [Create a conversation](create-conversation.md), and choose a local conversation that has not been deleted or bound to an upstream model.

## Request example

Replace `$GENESIS_ACCESS_TOKEN` and `$CONVERSATION_ID` with your personal access token and the selected conversation ID.

```bash
curl -X POST "https://token.moi.matrixorigin.cn/v1/conversations/$CONVERSATION_ID" \
  -H "Authorization: Bearer $GENESIS_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{
  "metadata": {
    "purpose": "support"
  }
}'
```

## Path parameters

::::{div} mo-api-parameter-table

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `conversation_id` | string | Yes | The `id` returned when creating the conversation. |

::::

## Request body

::::{div} mo-api-parameter-table

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `metadata` | object | No | Replaces all existing metadata. Omitting this field or passing an empty object clears the metadata. |
| `metadata.<key>` | any | No | Caller-defined keys and values, such as `purpose`. |

::::

## Successful response

A successful request returns the conversation with its replaced metadata.

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "id": "$CONVERSATION_ID",
  "object": "conversation",
  "metadata": {
    "purpose": "support"
  },
  "status": "active",
  "created_at": 1780000000,
  "updated_at": 1780000000
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | Conversation identifier for retrieval, updates, and deletion. |
| `object` | string | Always `conversation`. |
| `metadata` | object | Custom conversation metadata. |
| `metadata.<key>` | any | Caller-defined keys and values, such as `purpose`. |
| `status` | string | Conversation status; `active` after creation. |
| `created_at` | integer | Creation time as a Unix timestamp in seconds. |
| `updated_at` | integer | Last update time as a Unix timestamp in seconds. |

:::::
::::::
:::::::

## Error response

The request returns `404` when the resource is missing, deleted, or inaccessible to the current credential.

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "error": {
    "message": "conversation not found",
    "type": "conversation_not_found",
    "code": "conversation_not_found"
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `error` | object | Error details. |
| `error.message` | string | Error description. |
| `error.type` | string | Error type. |
| `error.code` | string | Error code. |

:::::
::::::
:::::::

## Next steps

Use the conversation `id` to [Retrieve a conversation](get-conversation.md) and check the replaced metadata.
