> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chamelio.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Continue a Conversation

> Send another message to an existing Chamelio agent conversation.

## Endpoint

```
POST /v2/agent/conversations/{session_id}/messages
```

The agent keeps the earlier context of the conversation, so ask the follow-up as you would ask a
person - there is no need to repeat the whole question.

## Authentication

This endpoint requires an OAuth access token. Send it as a bearer token:

```bash theme={null}
Authorization: Bearer your_access_token
```

**Required scope:** `agent:write`

The agent runs as the access token's user and inherits exactly that user's access.

## Path Parameters

| Parameter    | Type          | Required | Description                                                                                                           |
| ------------ | ------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
| `session_id` | string (UUID) | Yes      | The conversation to continue, from the `session_id` returned by [Ask the Agent](/api-reference/endpoint/v2/agent/ask) |

<Info>
  You can continue a conversation this API started, or one the same user started in the Chamelio web
  app. Conversations that belong to other surfaces (such as the Word add-in or a workflow) return
  `404`.
</Info>

## Query Parameters

| Parameter | Type    | Required | Description                                                                                                               |
| --------- | ------- | -------- | ------------------------------------------------------------------------------------------------------------------------- |
| `stream`  | boolean | No       | Stream the run as Server-Sent Events. Set `false` to wait for the run to finish and get one JSON body. Defaults to `true` |

## Request Body

| Field    | Type   | Required | Description                                             |
| -------- | ------ | -------- | ------------------------------------------------------- |
| `prompt` | string | Yes      | The next message in the conversation. Must not be empty |

Follow-up messages cannot turn on web search. Web search is only set when the conversation starts
(`use_web` on [Ask the Agent](/api-reference/endpoint/v2/agent/ask)).

## Request Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://platform.chamelio.ai/v2/agent/conversations/3f6c2a8e-1b4d-4e7a-9c21-5d8f0e6b7a90/messages?stream=false" \
    -H "Authorization: Bearer your_access_token" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Which of those has the shortest notice period?"
    }'
  ```

  ```python Python theme={null}
  import requests

  session_id = "3f6c2a8e-1b4d-4e7a-9c21-5d8f0e6b7a90"
  url = f"https://platform.chamelio.ai/v2/agent/conversations/{session_id}/messages"
  headers = {
      "Authorization": "Bearer your_access_token",
      "Content-Type": "application/json"
  }

  payload = {"prompt": "Which of those has the shortest notice period?"}

  response = requests.post(url, params={"stream": "false"}, json=payload, headers=headers, timeout=300)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const sessionId = '3f6c2a8e-1b4d-4e7a-9c21-5d8f0e6b7a90';
  const response = await fetch(`https://platform.chamelio.ai/v2/agent/conversations/${sessionId}/messages?stream=false`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_access_token',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      prompt: 'Which of those has the shortest notice period?'
    })
  });

  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

## Response

The response has the same shape as [Ask the Agent](/api-reference/endpoint/v2/agent/ask#response):
a Server-Sent Events stream by default, or a single JSON body with `stream=false`.

### Success Response (`stream=false`)

**Status Code:** `200 OK`

```json theme={null}
{
  "session_id": "3f6c2a8e-1b4d-4e7a-9c21-5d8f0e6b7a90",
  "answer": "The Contoso MSA has the shortest notice period: 30 days before renewal.",
  "status": "completed",
  "pending_approval": null
}
```

See [Response Fields](/api-reference/endpoint/v2/agent/ask#response-fields) for every field.

<Note>
  With `stream=false`, `session_id` is always the conversation from the path. When streaming, a
  follow-up run does not send a new `session_id` event - keep using the one you already have.
</Note>

## Error Responses

### 400 Bad Request

Returned when the access token has no user behind it.
`client_credentials` tokens act as the admin who created the application, so this applies only to
tokens issued before application creators were recorded.

```json theme={null}
{
  "detail": "client_credentials tokens are not associated with a user"
}
```

### 401 Unauthorized

Returned when the access token is missing, unknown, revoked, or expired, or when an `X-API-Key` was
sent instead of a bearer token. See [OAuth error responses](/api-reference/oauth-apps#error-responses).

```json theme={null}
{
  "detail": "Invalid access token"
}
```

### 403 Forbidden

Returned when the token does not carry the required scope.

```json theme={null}
{
  "detail": "Insufficient scope; this endpoint requires: agent:write"
}
```

### 404 Not Found

Returned when the conversation does not exist, or belongs to a surface this API cannot drive (such
as the Word add-in or a workflow). Both cases return the same response on purpose.

```json theme={null}
{
  "detail": "Not found"
}
```

### 409 Conflict

Returned when a run is already active on this conversation. Wait for it to finish, then send your
message. The `detail` is passed through from the agent service.

### 422 Validation Error

Returned when the request is invalid, for example an empty `prompt` or a `session_id` that is not a
UUID.

### 429 Too Many Requests

Returned when your organization exceeds its per-minute request limit.

```json theme={null}
{
  "detail": "Rate limit exceeded"
}
```

### 500 Internal Server Error

Returned when the run could not be started or failed before producing an answer.

```json theme={null}
{
  "detail": "Failed to continue the conversation"
}
```
