# Send Message to AI Agent (Supports SSE Streaming & Structured Blocks)

`POST /api/conversations/{conversation_id}/send`

### Overview
Dispatches a user prompt to the AI Agent. Supports real-time Server-Sent Events (SSE) streaming as well as synchronous one-shot JSON responses.

### Authentication & Headers
- **Auth**: Bearer Token
- **Required Header**: `API-Version: 1`
- **Optional Header**: `X-Pinter-Response-Format`:
  - `blocks`: Receive structured chart, html, and followup artifact blocks via SSE or block items.
  - `blocks,openui`: Same as `blocks`, plus the model may emit ```openui-lang UI fences inside text deltas.
  - `json`: Guarantee a JSON response (`application/json`) without block prompt injection, acting like default mode while ensuring structured JSON output.
  - Without the header, the response stays plain SSE text deltas.

### Parameters & Request Body Fields
- **`conversation_id`** *(path, string, required)*: The target conversation session UUID.
- **`message`** *(string, required)*: The text prompt or user query.
- **`agent_id`** *(string, optional)*: Specific agent UUID to route query to.
- **`stream`** *(boolean, optional, default: false)*: Set to `true` for SSE streaming mode (`text/event-stream`).
- **`attachments`** *(array of strings, optional)*: List of uploaded blob attachment paths for multimodal analysis.
- **`approval_mode`** *(string, optional, default: `full-access`)*: `approval` pauses risky tools (names starting with `create_`, `update_`, `delete_`, `run_`, or `add_`, and non-read-only `query_snowflake` calls) for human confirmation. `full-access` runs them without asking. When the field is omitted, tools run without confirmation, so API clients that want the gate must send `approval`. The chat UI always sends its own choice.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `conversation_id` | path | string | yes | Unique UUID of the conversation session / thread. |
| `x-pinter-response-format` | header | string | no | Comma-separated response mode tokens. `blocks`: structured rich response blocks (charts, html, images, followup). `blocks,openui`: same as `blocks` plus openui-lang UI fences inside text deltas. `json`: collected JSON response. |

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `message` | string | yes |  |
| `agent_id` | string | yes |  |
| `api_key_id` | string \| null | no |  |
| `attachments` | object[] | no |  |
| `attachments[].mime_type` | string | yes |  |
| `attachments[].data_base64` | string | yes |  |
| `attachments[].filename` | string | no |  |
| `attachments[].url` | string \| null | no |  |
| `stream` | boolean | no |  |
| `approval_mode` | enum | no |  |

```json
{
  "message": "string",
  "agent_id": "string",
  "api_key_id": "string",
  "attachments": [],
  "stream": false,
  "approval_mode": "full-access"
}
```

## Responses

### 200 — Agent response (JSON format or text/event-stream depending on stream parameter)

### 400 — Bad Request - The request parameters or headers are invalid (e.g. unsupported API-Version).

### 401 — Unauthorized - Missing, invalid, or expired JWT Bearer token.

### 403 — Forbidden - Insufficient role permissions or resource access denied by RBAC policy.

### 404 — Not Found - The requested resource ID was not found.

### 422 — Validation Error

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | object[] | no |  |
| `detail[].loc` | string | integer[] | yes |  |
| `detail[].msg` | string | yes |  |
| `detail[].type` | string | yes |  |
| `detail[].input` | object | no |  |
| `detail[].ctx` | object | no |  |

```json
{
  "detail": [
    {
      "loc": [
        null
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

## Example

```bash
curl -X POST "$PINTER_URL/api/conversations/018f3a55-234b-76b9-b8d1-561b34e2a101/send" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message":"string","agent_id":"string","api_key_id":"string","attachments":[],"stream":false,"approval_mode":"full-access"}'
```
