# IRPCConversationOperations.AddOrUpdateChatTurn

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Vault API](https://developer.m-files.com/APIs/gRPC-API/vault/index.md) > [Conversations](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCConversationOperations/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCConversationOperations/AddOrUpdateChatTurn/

Badges: `Vault API / standard` `write` `session`

Adds a chat turn to one of the caller's conversations, or replaces the content of an existing
chat turn.

- **Service:** [Conversations](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCConversationOperations/index.md) `MFiles.IRPCConversationOperations`
- **gRPC method:** `/MFiles.IRPCConversationOperations/AddOrUpdateChatTurn`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/add-or-update-chat-turn`
- **Request:** [`AddOrUpdateChatTurnRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCConversationOperations/AddOrUpdateChatTurn/index.md#request)
- **Response:** [`AddOrUpdateChatTurnResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCConversationOperations/AddOrUpdateChatTurn/index.md#response)
- **Book and level:** Vault API, standard
- **Kind:** write
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** no
- **Returns metadata structure version:** no
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- `conv_id` must name an existing conversation; otherwise the call fails with "The parameter is
  incorrect.".
- With `id` 0, or an ID that does not exist, a new chat turn is added with a new ID and
  `sort_key`. With an existing ID, `chat_turn` replaces the stored content and `modified` is
  updated.
- The content is stored as given; the server does not parse it.

<a id="request"></a>

## Request: AddOrUpdateChatTurnRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `chat_turn` | [`ChatTurn`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ChatTurn/index.md) | The chat turn. Set `conv_id` and `chat_turn` (the content); set `id` to replace an existing turn. |
| `chat_turn.id` | `uint32` | The ID of the chat turn, assigned by the server. |
| `chat_turn.conv_id` | `uint32` | The ID of the conversation the turn belongs to. |
| `chat_turn.chat_turn` | `string` | The content of the turn as text. The server stores it as given and does not parse it; the format is up to the caller. |
| `chat_turn.sort_key` | `uint32` | Orders the turns; newer turns have larger values. Used for paging. |
| `chat_turn.created` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | When the turn was added (UTC). |
| `chat_turn.modified` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | When the turn was added or last replaced (UTC). |

<a id="response"></a>

## Response: AddOrUpdateChatTurnResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `updated_chat_turn` | [`ChatTurn`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ChatTurn/index.md) | The chat turn as stored, with its ID and `sort_key`. |
| `updated_chat_turn.id` | `uint32` | The ID of the chat turn, assigned by the server. |
| `updated_chat_turn.conv_id` | `uint32` | The ID of the conversation the turn belongs to. |
| `updated_chat_turn.chat_turn` | `string` | The content of the turn as text. The server stores it as given and does not parse it; the format is up to the caller. |
| `updated_chat_turn.sort_key` | `uint32` | Orders the turns; newer turns have larger values. Used for paging. |
| `updated_chat_turn.created` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | When the turn was added (UTC). |
| `updated_chat_turn.modified` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | When the turn was added or last replaced (UTC). |
